Repository navigation
fix(looper): key the implicit lm_head rule per engine prefix, and drop it for AWQ (#6194, #6195) - #6235
Merged
Conversation
lm_head=True adds an implicit 8-bit/g32 head override keyed by the definition-owned head name. On a text model that is lm_head, which vLLM matches directly. A composite wrapper such as Qwen2.5-VL keeps the head at the Transformers root but vLLM re-homes it under language_model, so the bare key never matched and vLLM built a 4-bit head before loading the 8-bit tensors. Emit a prefix-agnostic, end-anchored regex for a root-level head on a composite model. It still matches the runtime name and now matches the engine prefix (language_model.lm_head). Plain text models and heads the definition already qualifies keep their exact name. Apply the same key form to the requantize endpoint defaults. Fixes #6194
Addresses the code-quality bot note on #6235: json is already imported at module scope, so the function-local import is redundant.
… it for AWQ (#6194, #6195) Two draft PRs changed the same `_loop_impl` lm_head block and could not both apply. This commit carries both contracts on one branch. #6194: the implicit `lm_head` dynamic rule used the definition-owned module name. A composite wrapper keeps the text tower at a nested runtime path while vLLM/SGLang re-home the head under `language_model`, so a root-level `lm_head` key never matched. `BaseQModel.dynamic_module_pattern()` now returns the engine-facing, end-anchored regex for such a model and the bare name otherwise; `missing_defaults` uses it too. #6195: AWQ consumers (vLLM, AutoAWQ, Transformers) build every quantized module from the global `bits`/`group_size` and ignore `dynamic`, so the implicit 8-bit/g32 head produced a checkpoint they cannot read. AWQ now leaves the head at the base contract via `_implicit_lm_head_dynamic()`; GPTQ keeps the 8-bit default and explicit user overrides are still honored. Combined, AWQ emits no implicit head rule at all and GPTQ emits it under the engine-facing key.
Both this PR and the writer-interop PR (#6269) appended a test at the end of this file, which made the two diffs conflict on the same EOF anchor. Moving the head-rule test next to the other composite-head coverage keeps the file readable and removes the overlap; no test content changed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6194
Fixes #6195
Problem
lm_head=Trueadds an implicit 8-bit/g32dynamicoverride keyed by the definition-owned head name. On a text model that islm_head, which vLLM matches directly. On a composite wrapper such as Qwen2.5-VL the Transformers runtime keeps the head at the root (lm_head), but vLLM maps the checkpoint'slm_head.tensors tolanguage_model.lm_head.:vLLM therefore builds a 4-bit head and rejects the checkpoint's 8-bit g32 tensors.
Reproduced on CPU with a tiny Qwen2.5-VL composite (2 layers, hidden 32), GPTQ 4-bit/g32,
lm_head=True. At HEAD the saveddynamicis:{"lm_head": {"bits": 8, "group_size": 32, "sym": true, "desc_act": false, "mse": 2.4}}Fix
BaseQModel.dynamic_module_pattern()keeps the exact definition-owned name for:lm_head, the key vLLM already accepts), andlanguage_model.lm_head,thinker.lm_head).For a root-level head on a composite wrapper (a nested
text_configor a declared non-text modality) it emits a prefix-agnostic, end-anchored regex built from the same definition-owned name:This matches both
lm_head(GPT-QModel runtime) andlanguage_model.lm_head(vLLM). The same key form is used for the requantize endpoint defaults. The rule's bits/group_size are unchanged.Also fixes #6195 (consolidated)
This branch now carries both
#6194and#6195. They edited the same_loop_impllm_headblock, so the two draft PRs could not both apply; #6240 is closed in favour of this one.#6195 covers the value of the implicit rule for AWQ: AWQ consumers (vLLM, AutoAWQ, Transformers) build every quantized module from the global
bits/group_sizeand ignoredynamic, so an implicit 8-bit/g32 head produced a checkpoint they cannot read. AWQ now leaves the head at the base contract via_implicit_lm_head_dynamic(); GPTQ keeps the 8-bit default, and explicit user overrides are still honored.Combined, AWQ emits no implicit head rule at all and GPTQ emits it under the engine-facing key.
Additional tests (from #6195):
tests/test_checkpoint_compat.py::test_awq_implicit_lm_head_uses_the_global_contracttests/test_checkpoint_compat.py::test_awq_explicit_lm_head_override_is_preservedtests/test_checkpoint_compat.py::test_untied_lm_head_quantizes_and_reloads(extended with GPTQ 8-bit/dynamic assertions, CUDA-gated)#6195 red evidence (its source change reverted, tests kept)
Combined-tree verification
Both contracts together, CPU-only:
The 3 skips are the CUDA-only
lm_headtests.Tests
tests/test_qwen2_5_vl_local_port.py::test_composite_lm_head_dynamic_rule_matches_vllm_prefix(new): quantizes a tiny Qwen2.5-VL composite on CPU, saves, checks bothconfig.jsonandquantize_config.json, and reloads with GPT-QModel to prove the regex still selects the 8-bit g32 head.tests/test_writer_dynamic_order.py::test_plain_text_model_keeps_bare_dynamic_head_key(new): plain text keepslm_head.Red (source reverted, test kept)
Green
The 3 skips are the CUDA-only
lm_headtests (lm_head quantization needs an accelerator).Unverified
re.match(pattern.removeprefix("+:"), prefix)): it matcheslanguage_model.lm_headand does not matchlm_head_extra.test_checkpoint_compat.pyrun hit the shared-host mixed-GPU capability guard (cuda:0-3=8.9, cuda:4=12.0), which is unrelated to this change.