Skip to content

[BUG] Real MoE/VL: GPTQModel MoE ckpts load in HF transformers as garbage (experts MISSING, PPL 39570), legacy-layout VL GPTQ ckpts (Qwen2-VL Int8) fail GPTQModel.load, AWQ crashes when in_features % group_size != 0, dangling auto_map after trust_remote_code override #4073

Closed

Description

@Qubitium

Audit of main @ ad0525c, RTX 4090. End-to-end runs on real MoE and VL models (earlier rounds mostly used tiny random-weight models), 4-bit g128 bf16, 128 C4 docs (MoE) / 32 image+caption chats (VL), wikitext-2 20×512.

1. GPTQModel MoE checkpoints load in plain transformers 5.22 as garbage (or crash), without an error (high)

GPTQModel saves per-expert experts.N.*.qweight. HF 5.x builds fused 3-D experts, and optimum 2.3.0 only swaps nn.Linear. As a result, every expert tensor is reported MISSING (random init) and every saved expert tensor UNEXPECTED, but the model still loads. The bridge meant to defuse experts, hf_gptqmodel_prepare_model_for_load (utils/hf_load.py:42), is exported but called by neither optimum nor transformers. hf_compat_warnings (models/writer.py:215) warns about lm_head and AWQ 8-bit, but says nothing about MoE.

checkpoint GPTQModel.load AutoModelForCausalLM.from_pretrained
published OLMoE-1B-7B-0924-GPTQ-4bit-gp128-gp32-dynamic PPL 11.34 64 MarlinLinear (attention only), experts.gate_up_proj MISSING, PPL 39570, "domest domest domest…"
fresh OLMoE GPTQ4 11.35 PPL 49616
fresh Phi-tiny-MoE GPTQ4 11.50 "The capital of France is a, in a,,,, a a a azzszz"
fresh Qwen1.5-MoE-A2.7B GPTQ4 9.99 crash: Marlin packed dimensions must be divisible by pack_factor=8; got K=2048, N=1; optimum tries to quantize shared_expert_gate

Fix: make the bridge actually run, for example by patching optimum's GPTQ quantizer from gptqmodel/__init__, as is already done for other transformers compat. At minimum, warn at save time for defused-MoE checkpoints. Also write modules_to_not_convert for unquantized gates such as Qwen's shared_expert_gate.

2. GPTQModel.load can't load legacy-layout quantized VL checkpoints (Qwen2-VL-2B-Instruct-GPTQ-Int8), although HF loads them fine (high)

The checkpoint uses the transformers-4.45 key layout (model.layers.*, visual.*). The quantized-load path (models/loader.py:2522 validation, :2806-2816 load) reads keys verbatim. HF's HF_CONVERSION_MAP_REVERSED key conversion is only applied on the LazyTurtle quantization path (loader.py:1786), which is why the fp16 Qwen2-VL-2B-Instruct with the same legacy layout quantizes fine. base_qwen2_vl.py defines no checkpoint_key_for_load; only gemma3.py:72 does.

GPTQModel.load(Qwen2-VL-2B-Instruct-GPTQ-Int8) -> ValueError: Missing required quantized weights in checkpoint ... model.language_model.layers.0.mlp.down_proj.qweight, ...
  (validation disabled: accelerate reports every model.layers.* / visual.* key unused -> garbage model)
AutoModelForImageTextToText.from_pretrained(same) -> 196 MarlinLinear, answers match bf16 ("Paris", correct image caption)

This probably affects every older-layout GPTQ/AWQ checkpoint of Qwen2/2.5-VL, LLaVA and similar. Fix: apply the HF checkpoint conversion map through key_converter in the quantized loader, or add a checkpoint_key_for_load (^model. → model.language_model., ^visual → model.visual) to these families. Add a test that loads a legacy-layout quantized VL checkpoint.

3. AWQ with default settings crashes on any module whose in_features isn't a multiple of group_size (Phi-tiny-MoE) (medium)

looper/awq_processor.py:124 (_accumulate_awq_weight_mean, called from _search_best_scale :1925) raises ValueError: Expected in_features (448) to be divisible by group_size (128). Phi-tiny-MoE has intermediate_size=448, so expert down_proj fails in layer 0 after about 95 s of calibration. GPTQ quantizes the same model fine (PPL 11.50 vs base 11.18). On a tiny dense Llama with intermediate 448, AWQ crashes the same way and GPTQ saves OK. Fix: check divisibility up front, then pick a per-module group size that divides in_features, or skip/fallback that module with a warning, the way GPTQ handles it.

4. A remote-code model saved under the native trust_remote_code override keeps a dangling auto_map (low)

utils/hf.py:749 resolve_trust_remote_code turns remote code off for natively supported types, and models/writer.py:1810/2289 then skip copying the .py files. The saved Phi-tiny-MoE config.json still has auto_map -> configuration_slimmoe.PhiMoEConfig, so AutoConfig.from_pretrained(out, trust_remote_code=True) (as the model card instructs) fails with OSError: ... does not appear to have a file named configuration_slimmoe.py. Fix: drop auto_map when the override applies, or copy the .py files whenever the source has auto_map.

Checked, healthy

model base GPTQ4 AWQ4
OLMoE-1B-7B 10.77 11.35 11.42
Qwen1.5-MoE-A2.7B 9.46 9.99 9.87
Phi-tiny-MoE 11.18 11.50 crash (item 3)
PowerMoE-3b 8.82 9.33 9.58

Plausible, not verified

  • GRIN-MoE-gptq-4bit loads all 1664 MarlinLinear correctly, but the first forward crashes inside its remote modeling_grinmoe.py (written for transformers 4.44) with an attention-mask shape error.

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions