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] AWQ MoE checkpoints load in plain transformers with random experts (KL 3.26): #4084's HF bridge only patches Optimum GPTQ, and the save warning's 'import gptqmodel first' remedy does not apply to AWQ #4661
Found on main @ 12c1273: quantized on a ROCm GPU, plain-HF load on CPU (torch 2.15, transformers 5.22.1, optimum 2.3.0).
What is wrong
A GPTQModel AWQ MoE checkpoint loads in plain AutoModelForCausalLM.from_pretrained with every routed expert random-initialized. There is no error, and the output is garbage. This happens even when gptqmodel is imported first, which is the remedy the save-time warning gives.
#4073 item 1 was fixed (#4084) only for GPTQ. _patch_optimum_gptqmodel_load_bridge (gptqmodel/__init__.py:416-475) wraps optimum.gptq.GPTQQuantizer.convert_model/post_init_model and routes them through hf_gptqmodel_prepare_model_for_load. Transformers loads quant_method: "awq" through its own AwqQuantizer, though: _process_model_before_weight_loading calls integrations/awq.py::replace_with_awq_linear, which only swaps nn.Linear. Nothing patches that path. The fused OlmoeExperts.gate_up_proj / down_proj 3-D parameters stay dense and are reported MISSING (random init). Every experts.N.*.qweight/qzeros/scales is reported UNEXPECTED and dropped.
hf_compat_warnings (gptqmodel/models/writer.py:345-356) fires for this checkpoint at save time. It tells the user to "import gptqmodel before Transformers so its native loading bridge is installed". For AWQ that advice is wrong, because the bridge never runs.
Repro
OLMoE-1B-7B-0924 truncated to 4 layers, AWQConfig(bits=4, group_size=128), 16 C4 samples, saved with GPTQModel.save. The KL is the mean token KL vs. the bf16 model on 4×256 wikitext-2 tokens.
importgptqmodel# bridge installed first, as the warning saysfromtransformersimportAutoModelForCausalLMm=AutoModelForCausalLM.from_pretrained(awq_ckpt, dtype=torch.bfloat16, device_map="cpu")
same flow, GPTQ checkpoint of the same model (Optimum bridge)
0.0606 (= GPTQModel 0.0607)
Suggested fix
Install the same bridge for transformers' AWQ quantizer, for example by wrapping transformers.quantizers.quantizer_awq.AwqQuantizer._process_model_before_weight_loading / _process_model_after_weight_loading to call hf_gptqmodel_prepare_model_for_load / hf_gptqmodel_post_init_for_load when the checkpoint is GPTQModel-native. hf_gptqmodel_prepare_model_for_load is format-generic already: it reads quantize_config and .qweight keys. Failing that, make the save-time warning say that AWQ MoE checkpoints cannot be loaded by plain transformers, and do not point users to a bridge that does not apply.
Test that should have caught it
The #4073 regression test covers only GPTQ. Add the AWQ variant: tiny fused-expert MoE (OLMoE/Qwen3-MoE config, 2 layers, 4 experts) → AWQConfig quantize → save → AutoModelForCausalLM.from_pretrained → assert no MISSING expert params and logits match GPTQModel.load.
Severity
High for anyone who publishes AWQ MoE checkpoints: they load in transformers, vLLM-adjacent tooling and PEFT flows as silent garbage, and the warning sends users to a remedy that does not work.
Activity
ZX-ModelCloud commentedon Nov 17, 2026
Claimed. I'm working on this issue and will submit a fix PR. Please avoid duplicate work in the meantime.
fix(awq): load packed AWQ experts through the native HF bridge (#4661) (