You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] writer/HF interop: Phi-3/Phi-3.5/Phi-4 and GLM-OCR GPTQ checkpoints save the defused mlp.gate_proj/up_proj, so AutoModelForCausalLM.from_pretrained randomly initializes gate_up_proj (PPL 1e11) and save() gives no warning #6166
For definitions whose HF module is a fused dense mlp.gate_up_proj (Phi-3 family incl. Phi-3.5-mini and Phi-4, GLM-OCR, and per #4620 also GLM/GLM-4/Zamba2), Defuser splits the projection into gate_proj + up_proj before quantization. The writer serializes the split names (mlp.gate_proj.qweight, mlp.up_proj.qweight, ...). Transformers 5.23's Phi3/GLM-OCR modeling only has mlp.gate_up_proj, so plain from_pretrained reports every gate/up tensor UNEXPECTED and gate_up_proj.* MISSING. It randomly initializes the whole first MLP projection of every layer and returns garbage without raising.
The writer already has hf_compat_warnings() for the equivalent MoE case (experts.<n>.*.qweight vs fused 3-D experts, see #4073). It has nothing for defused dense blocks, so this case is completely silent. The native Transformers load bridge from #3503 handled fused-block rewrites, but #4620 removed it. Since then nothing covers this path.
Introduced by
The dense defuse dates from #2765 (Phi-3 defused MLP mapping). Plain-HF loading of these checkpoints lost its last cover when #4620 (d2dfb93) removed the Transformers bridge from #3503 (472f4c8) and defuser.replace_fused_blocks(). GLM-OCR moved onto the same path in #3558 (24d1b77) and later commits.
gptqmodel/models/definitions/phi3.py:27: "mlp": ("gate_proj:0:in=x", "up_proj:0:in=x", "down_proj:1"), (the source checkpoint and HF modeling have mlp.gate_up_proj)
model.layers.{0...31}.mlp.gate_proj.qweight | UNEXPECTED |
model.layers.{0...31}.mlp.up_proj.qweight | UNEXPECTED |
... (scales/qzeros/g_idx likewise)
model.layers.{0...31}.mlp.gate_up_proj.qweight | MISSING |
model.layers.{0...31}.mlp.gate_up_proj.scales | MISSING |
...
HF wikitext2 PPL 110621517293.02 generate("The capital of France is") -> ''
NATIVE (GPTQModel.load, same dir) PPL 6.9043 -> 'Paris.\n\nParis is the capital of France. ...'
GLM-OCR (zai-org/GLM-OCR, quantized with image calibration) behaves the same way. GPTQModel.load reads an OCR test image correctly ('QUANTIZED MODELS\n\nInvoice 4821 total $93.10', same as bf16). AutoModelForImageTextToText.from_pretrained reports mlp.gate_up_proj.* MISSING and generates '_div divid十二章 regener IBtotстра ...'.
Expected vs actual
Expected: a GPTQModel checkpoint either loads correctly through Transformers or, as for MoE experts and lm_head=True, save() warns that only GPTQModel.load/vLLM can read it.
Actual: it loads without error, with every layer's gate/up projection randomly initialized, and nothing warns.
Suggested fix
Preferred: re-fuse on save. For GPTQ/AWQ with desc_act=False, gate_proj and up_proj share in_features and group geometry. Concatenating qweight/scales along the output dim, and qzeros too when N % (32/bits) == 0, gives an exact gate_up_proj that Transformers and vLLM both consume natively. GPTQModel.load would need the inverse split, which Defuser already does for the dense source. At minimum, extend hf_compat_warnings() to flag any definition whose quantized module names differ from the HF module names because of a defused dense block (Phi-3, GLM, GLM-4, GLM-OCR, Zamba2, ...).
Activity
fix(writer): warn when a defused dense gate/up MLP cannot load in HF
fix(writer): HF/vLLM interop for dense towers, excluded linears and d…
fix(writer): HF/vLLM interop for dense towers, excluded linears and d…