Repository navigation
fix: native class for natively supported remote-code checkpoints; keep checkpoint dtype/device on dequant/export; accept VLM calibration metadata (#4453, #4455) - #4491
Merged
Conversation
The #4373 fix treated any auto_map class-name difference from the native Transformers class as a layout override, so an explicit trust_remote_code=True ran stale remote code for natively supported Phi-3.5-MoE / Phi-tiny-MoE (PhiMoE vs Phimoe), MPT (MPT vs Mpt) and MiniMax-M2 (MiniMaxM2 vs MiniMax) checkpoints. Replace the name comparison with a declared per-model_type table of config fields that select a layout the native class cannot load (_REMOTE_ONLY_LAYOUT_CONFIG_MARKERS; bailing_hybrid q_lora_rank for the Ling-2.6-flash MLA branch). Over all 226 local configs with an auto_map, the decision now differs from def6e61 only for Ling-2.6-flash. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…alibration metadata (#4455) - VLM calibration accepts scalar/string metadata columns (id, url, ...) next to input_ids; multimodal names (pixel_values, image_grid_thw, image_url, ...) and tensor/array/numeric/bytes/mapping values are still rejected. - utils.model_dequant.dequantize_model defaults target_dtype to the checkpoint's own float dtype (dtype / torch_dtype / text_config), so GPTQModel.export(..., "hf") keeps an fp16 checkpoint fp16; bf16 only when the checkpoint declares none. - torch / torch_fused / torch_aten in-memory dequantize_model build the dense Linear on the quantized module's device instead of CPU. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4453
Fixes #4455
#4453: explicit
trust_remote_code=Trueran stale remote code_checkpoint_remote_layout_overrides_native(gptqmodel/utils/hf.py:995at d01e8fd) kept remote code whenever the class name in the checkpoint'sauto_mapdiffered from the native class. These checkpoints then ran stale remote code and failed with an ImportError or a rope TypeError:PhiMoEvsPhimoe)MPTvsMpt)MiniMaxM2vsMiniMax)The class-name comparison is replaced by a declared table,
_REMOTE_ONLY_LAYOUT_CONFIG_MARKERS. Its one entry isbailing_hybrid: q_lora_rank, the Ling-2.6-flash MLA branch that nativeBailingHybridAttentioncannot represent. Nativebailing_hybridalready mapsattention.*→self_attn.*, so a remote class name on its own is not a layout signal.flowchart TD A["resolve_trust_remote_code(path, True)"] --> C{"native AutoModelForCausalLM class?"} C -- no --> T["True: remote code"] C -- yes --> D{"auto_map.AutoModelForCausalLM?"} D -- "no / unreadable" --> N["False: native (warn once)"] D -- yes --> E{"config sets _REMOTE_ONLY_LAYOUT_CONFIG_MARKERS[model_type]?"} E -- no --> N E -- "yes (bailing_hybrid q_lora_rank)" --> Tauto_map, the result differs from def6e61 only for Ling-2.6-flash. Before this change, origin/main differed for 6.GPTQModel.load(Phi-tiny-MoE, trust_remote_code=True)raised ImportError before; it now loads nativePhimoeForCausalLM.docs/trust-remote-code-isolation.md#native-override-of-explicit-trust.#4455
id,url, ...). Still rejected, so the [BUG] VLM calibration silently dropspixel_values/image_grid_thwfrom processor-produced rows (regression from 2b51d4d, #4311) #4371 protection is kept:pixel_values,image_grid_thw,image_url, ...);export(..., "hf")dtype:utils.model_dequant.dequantize_modelnow defaultstarget_dtypeto the checkpoint's own float dtype, read fromdtype,torch_dtypeortext_config. bf16 is used only when none is declared. An fp16 checkpoint now exports as fp16, and a bf16 GPTQ Llama-3.2-1B export is bitwise identical to before.dequantize_model(torch, torch_fused, torch_aten): the densenn.Linearstays on the quantized module's device instead of moving to CPU.Tests
tests/test_remote_code_layout_marker_4453.py,tests/test_vlm_calibration_metadata_columns_4455.py,tests/test_export_dtype_4455.py,tests/test_dequantize_model_device_4455.py(the CUDA case is markedcuda).tests/test_ling_remote_code_4373.py. The Ling fixtures now carryq_lora_rank, like the real config.🤖 Generated with Claude Code