Repository navigation
Conversation
Phi-3/Phi-3.5/Phi-4, GLM/GLM-4, GLM-OCR and Zamba2 definitions expose one fused mlp.gate_up_proj in their HF module, but Defuser splits it into gate_proj/up_proj before quantization. The writer then serializes the split tensors, so AutoModelForCausalLM.from_pretrained reports them UNEXPECTED, leaves gate_up_proj MISSING and random-initializes it without raising. Re-fusing quantized kernel modules into a fused container is forbidden by contracts/model/refusion.md R2, so report the hazard through hf_compat_warnings() instead. Detection comes from Defuser's own split marker/class registry and the existing FUSED_PROJECTION_UNITS mapping, not a per-model list. Fixes #6166
Qubitium
force-pushed
the
fix/6166-issue
branch
from
November 29, 2026 02:24
6c15062 to
37c361f
Compare
Collaborator
Author
This was referenced Nov 29, 2026
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 #6166
What changed
save()now warns when a GPTQ/AWQ checkpoint contains a dense MLP that Defuser split from the HF fusedmlp.gate_up_projintomlp.gate_proj+mlp.up_proj. The warning names the exact checkpoint keys, says Transformers reports the split keys as UNEXPECTED and the fused key as MISSING, and points atGPTQModel.load.Detection is generic and comes from Defuser's own conversion state, not a model list:
_defuser_split_gate_up_runtime(set bydefuser.modeling.runtime_defusion.patch_split_gate_up_mlp()), and_STANDARD_SPLIT_GATE_UP_CLASSESregistry for sources that were already defused before loading.The fused/shard suffixes are read from the existing
gptqmodel.utils.model.FUSED_PROJECTION_UNITSmapping.Why this is the warning path, not re-fusion
contracts/model/refusion.mdR2 forbids merging quantized kernel modules back into a fused container ("Quantized kernel modules ... are never merged back into a packed container"). Re-fusinggate_proj.qweight/up_proj.qweightintogate_up_proj.qweightwould also require an inverse split inGPTQModel.load. The issue explicitly accepts the save-time warning as the minimum fix, anddocs/hf-interop.mdalready documents structural rewrites as a plain-HF hazard reported byhf_compat_warnings().Reproduction at HEAD
Tiny 1-layer Phi-3 (fused source
model.layers.0.mlp.gate_up_proj.weight), CPU GPTQ 4-bit g32:Saved keys before the fix:
AutoModelForCausalLM.from_pretrained(out)loads the config but forward fails on the uninitialized fused projection:Tests
New nodes (extend the existing checkpoint-compat/defused-writer family):
tests/test_checkpoint_compat.py::test_hf_compat_warning_for_defused_dense_gate_up_moduletests/test_checkpoint_compat.py::test_defused_dense_gate_up_checkpoint_warns_and_keeps_split_keysThe second test builds a real tiny Phi-3, quantizes and saves it on CPU, asserts the checkpoint still carries the defused
gate_proj/up_projkeys and nogate_up_proj, then asserts the warning namesmodel.layers.0.mlp.gate_up_proj,gate_proj.*, andup_proj.*.Red
Reverted only
gptqmodel/models/writer.py(tests kept):cd /root/openai-audit/issue-6166/tests CUDA_VISIBLE_DEVICES= PYTHONPATH=/root/openai-audit/issue-6166:/root/openai-audit/issue-6166/tests \ /root/venv/bin/python -m pytest \ test_checkpoint_compat.py::test_hf_compat_warning_for_defused_dense_gate_up_module \ test_checkpoint_compat.py::test_defused_dense_gate_up_checkpoint_warns_and_keeps_split_keys -q -rsResult:
2 failed; both fail atassert len(warnings) == 1withassert 0 == 1(no warning before the fix). The end-to-end test already proves the split keys were written.Green
Affected family:
Adjacent interop family:
CUDA_VISIBLE_DEVICES= PYTHONPATH=/root/openai-audit/issue-6166:/root/openai-audit/issue-6166/tests \ /root/venv/bin/python -m pytest test_checkpoint_interop_4053.py -q -rs # 19 passed, 6 skippedLint:
/root/venv/bin/ruff check gptqmodel/models/writer.py tests/test_checkpoint_compat.py # All checks passed!Skips
test_checkpoint_compat.py: 3lm_headquantization tests need an accelerator.test_checkpoint_interop_4053.py: 6 Marlin/ExLlamaV2/GPTQ-Triton tests need CUDA.Unverified
microsoft/Phi-3.5-mini-instruct, Phi-4, GLM/GLM-4 andzai-org/GLM-OCRcheckpoints on GPU. The fix is exercised on a real tiny Phi-3 port on CPU; GLM-OCR's multimodal calibration path was not run.Overlap note
gptqmodel/models/writer.pyis also touched by #6182 (block_name_to_quantize) and #6190 (AWQ exclusions). This branch is rebased onto currentmain(2d3261d) and adds a separate helper block before_has_per_expert_quantized_modules()plus a separate warning block; it does not rewrite block-name or modules-in-block emission.