|
30 | 30 | from accelerate import Accelerator |
31 | 31 | from example_utils import build_quant_cfg, get_tokenizer |
32 | 32 | from tqdm import tqdm |
33 | | -from transformers import ( |
34 | | - AutoConfig, |
35 | | - AutoModelForCausalLM, |
36 | | - AutoProcessor, |
37 | | - PreTrainedTokenizer, |
38 | | - PreTrainedTokenizerFast, |
39 | | -) |
| 33 | +from transformers import AutoModelForCausalLM, PreTrainedTokenizer, PreTrainedTokenizerFast |
40 | 34 |
|
41 | 35 | import modelopt.torch.opt as mto |
42 | 36 | import modelopt.torch.quantization as mtq |
43 | 37 | from modelopt.torch.export import get_model_type |
44 | 38 | from modelopt.torch.export.convert_hf_config import convert_hf_quant_config_format |
45 | | -from modelopt.torch.export.model_utils import is_multimodal_model |
46 | 39 | from modelopt.torch.export.unified_export_hf import _export_hf_checkpoint |
47 | 40 | from modelopt.torch.quantization.config import need_calibration |
48 | 41 | from modelopt.torch.quantization.utils import patch_fsdp_mp_dtypes |
@@ -250,28 +243,6 @@ def export_model( |
250 | 243 | export_dir = Path(export_path) |
251 | 244 | export_dir.mkdir(parents=True, exist_ok=True) |
252 | 245 |
|
253 | | - # Check if the model is a multimodal/VLM model |
254 | | - is_vlm = is_multimodal_model(model) |
255 | | - |
256 | | - if is_vlm: |
257 | | - # Save original model config and the processor config to the export path for VLMs. |
258 | | - print(f"Saving original model config to {export_path}") |
259 | | - |
260 | | - config_kwargs = {"trust_remote_code": args.trust_remote_code} |
261 | | - if args.attn_implementation is not None: |
262 | | - config_kwargs["attn_implementation"] = args.attn_implementation |
263 | | - AutoConfig.from_pretrained(args.pyt_ckpt_path, **config_kwargs).save_pretrained(export_path) |
264 | | - |
265 | | - # Try to save processor config if available |
266 | | - try: |
267 | | - print(f"Saving processor config to {export_path}") |
268 | | - AutoProcessor.from_pretrained( |
269 | | - args.pyt_ckpt_path, trust_remote_code=args.trust_remote_code |
270 | | - ).save_pretrained(export_path) |
271 | | - except Exception as e: |
272 | | - print(f"Warning: Could not save processor config: {e}") |
273 | | - print("This is normal for some VLM architectures that don't use AutoProcessor") |
274 | | - |
275 | 246 | post_state_dict, hf_quant_config = _export_hf_checkpoint( |
276 | 247 | model, torch.bfloat16, accelerator=accelerator |
277 | 248 | ) |
|
0 commit comments