Skip to content

[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

Closed

Description

@Qubitium

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.

import gptqmodel                      # bridge installed first, as the warning says
from transformers import AutoModelForCausalLM
m = AutoModelForCausalLM.from_pretrained(awq_ckpt, dtype=torch.bfloat16, device_map="cpu")

Output:

model.layers.{0, 1, 2, 3}.mlp.experts.{0...63}.gate_proj.qweight | UNEXPECTED |
model.layers.{0, 1, 2, 3}.mlp.experts.{0...63}.down_proj.scales  | UNEXPECTED |
...
model.layers.{0, 1, 2, 3}.mlp.experts.gate_up_proj               | MISSING    |
model.layers.{0, 1, 2, 3}.mlp.experts.down_proj                  | MISSING    |
HF module kinds: {'TorchCpuAvx512AwqLinear': 16, 'OlmoeExperts': 4, 'Linear': 1}   # only attention quantized
load path KL vs bf16
GPTQModel.load(awq_ckpt) 0.0704
AutoModelForCausalLM.from_pretrained(awq_ckpt) (after import gptqmodel) 3.262 (experts random)
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.

🤖 Generated with Claude Code

Activity

  1. ZX-ModelCloud commented on Nov 17, 2026

    @ZX-ModelCloud
    Collaborator

    Claimed. I'm working on this issue and will submit a fix PR. Please avoid duplicate work in the meantime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions