Skip to content

fix(awq): keep implicit lm_head at the global quant contract (#6195) - #6240

Closed
Qubitium wants to merge 1 commit into
mainfrom
fix/6195-issue
Closed

Qubitium wants to merge 1 commit into
mainfrom
fix/6195-issue

Conversation

@Qubitium

@Qubitium Qubitium commented Nov 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes #6195.

For AWQ, the implicit lm_head=True rule now leaves the head at the checkpoint-wide bits/group_size instead of emitting {"bits": 8, "group_size": 32, ...}. AWQ loaders (vLLM, AutoAWQ and Transformers) build every layer from the global settings and ignore dynamic, so the 8-bit/g32 override produced a saved head those loaders cannot read even though save() recommended vLLM.

Red evidence (HEAD 2d3261d, fix reverted, test kept)

cd /root/openai-audit/issue-6195/tests
CUDA_VISIBLE_DEVICES= PYTHONPATH=/root/openai-audit/issue-6195:/root/openai-audit/issue-6195/tests \
  /root/venv/bin/python -m pytest \
  test_checkpoint_compat.py::test_awq_implicit_lm_head_uses_the_global_contract -q -rs
>       assert "lm_head" not in dynamic
E       AssertionError: assert 'lm_head' not in {'lm_head': {'bits': 8, 'group_size': 32, 'sym': True, 'desc_act': False, ...}}
1 failed in 6.76s

The emitted quantization_config["dynamic"] carries the implicit 8-bit/g32 AWQ head; the saved head module is AwqTorchLinear(..., bits=8, group_size=32).

Green evidence (this PR)

cd /root/openai-audit/issue-6195/tests
CUDA_VISIBLE_DEVICES= PYTHONPATH=/root/openai-audit/issue-6195:/root/openai-audit/issue-6195/tests \
  /root/venv/bin/python -m pytest \
  test_checkpoint_compat.py::test_awq_implicit_lm_head_uses_the_global_contract \
  test_checkpoint_compat.py::test_awq_explicit_lm_head_override_is_preserved -q -rs
# 2 passed in 11.63s

Affected family (CPU-only):

cd /root/openai-audit/issue-6195/tests
CUDA_VISIBLE_DEVICES= PYTHONPATH=/root/openai-audit/issue-6195:/root/openai-audit/issue-6195/tests \
  /root/venv/bin/python -m pytest test_checkpoint_compat.py -q -rs
# 24 passed, 3 skipped in 12.77s

Skips are the three lm_head quantization needs an accelerator CUDA-gated tests. The explicit 8-bit control is covered by test_awq_explicit_lm_head_override_is_preserved on CPU. The existing test_untied_lm_head_quantizes_and_reloads now also asserts GPTQ still writes the 8-bit dynamic head (runs on CUDA CI).

Lint:

/root/venv/bin/ruff check gptqmodel/looper/module_looper.py tests/test_checkpoint_compat.py
# All checks passed!

Unverified

  • No vLLM load was run on this CPU-only worker. The regression asserts the checkpoint contract vLLM reads: no lm_head dynamic override, and a reloaded 4-bit/g32 AWQ head.
  • GPU-only tests above were skipped locally.

AWQ loaders (vLLM, AutoAWQ and Transformers) build every layer from the global bits/group_size and ignore dynamic. The implicit 8-bit/g32 lm_head override therefore saved a head those loaders cannot read, even though save() recommended vLLM. Leave the AWQ head at the base contract; GPTQ keeps its 8-bit default and an explicit AWQ lm_head override is still honored.
@Qubitium

Copy link
Copy Markdown
Collaborator Author

Consolidated into #6235.

#6194 and #6195 both edit the same _loop_impl lm_head block in gptqmodel/looper/module_looper.py (the lm_head_quant_config = {...} / dynamic[...] = ... lines), so the two branches cannot both apply. I merged them on fix/6194-issue:

Combined behaviour: AWQ emits no implicit head rule at all; GPTQ emits it under the engine-facing key.

Verified on the combined tree, CPU-only:

cd tests && CUDA_VISIBLE_DEVICES="" PYTHONPATH=... /root/venv/bin/python -m pytest \
  test_qwen2_5_vl_local_port.py test_writer_dynamic_order.py test_checkpoint_compat.py -q -rs
55 passed, 3 skipped, 1 warning in 20.40s

ruff check on all five changed files: All checks passed!

This PR's tests (test_awq_implicit_lm_head_uses_the_global_contract, test_awq_explicit_lm_head_override_is_preserved, and the extended test_untied_lm_head_quantizes_and_reloads) moved to #6235 unchanged. Closing this one so there is a single conflict-free PR for both issues.

@Qubitium Qubitium closed this Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant