Repository navigation
fix(writer): HF/vLLM interop for dense towers, excluded linears and defused MLPs (#6192, #6163, #6166) - #6269
Conversation
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.
…p it for AWQ (#6194, #6195) (#6235) * fix(looper): key implicit lm_head rule for nested engine heads (#6194) 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 * test(qwen2_5_vl): drop redundant local json import Addresses the code-quality bot note on #6235: json is already imported at module scope, so the function-local import is redundant. * fix(looper): key the implicit lm_head rule per engine prefix and drop 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. * test(qwen2_5_vl): place the #6194 head-rule test before the AWQ block 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.
cf7aee0 to
90af7b2
Compare
|
Rebased onto |
90af7b2 to
bbae869
Compare
…efix A definition may rename its keys on save: the Qwen VL port writes the Transformers source layout (`visual.*`, `model.layers.*`) instead of the runtime names (`model.visual.*`, `model.language_model.*`). The #6192 regression pinned the runtime prefix, so it failed as soon as a key map existed even though the checkpoint was correct. Match the dense vision weight and the packed decoder projection by suffix so the assertion holds for both layouts, and keep the `modules_to_not_convert` assertions in runtime spelling: `should_convert_module` is start-anchored against the live module names, so that list must stay in runtime form.
|
Cross-PR note for #6192, fixed here in #6374 ( Two conclusions, both now encoded in the test:
Combined-tree evidence (main + #6269 + #6374): the whole |
Summary
Consolidates three draft PRs that all edit
gptqmodel/models/writer.pyat the same helper-insertion point: #6230, #6232 and #6233. Each change is preserved in full (helpers, docstrings, tests, docs) on one conflict-free branch.Fixes #6192
Fixes #6163
Fixes #6166
Fixes
AWQ dense towers ([BUG] AWQ export of VL models: the dense vision tower is not listed in
modules_to_not_convert, so a GPT-QModel Qwen2.5-VL AWQ checkpoint crashes infrom_pretrainedand SGLang #6192, from fix(awq): publish definition-owned dense towers in modules_to_not_convert (#6192) #6230)._awq_dense_base_modules()reads the definition'sget_base_modules()inventory and adds containers that still own a densenn.Linearand contain noBaseQuantLineartomodules_to_not_convertbeforeconfig.json/quantize_config.jsonare written. This is definition-derived, not a per-model list, so Qwen2-VL/2.5-VL publishmodel.visualand Gemma 3 publishes its vision tower/projector.Definition-excluded GPTQ linears ([BUG] writer/HF interop: GPTQ checkpoints of models whose definition keeps a decoder
nn.Linearunquantized (LFM3self_attn.g_proj) omitmodules_in_block_to_quantize, soAutoModelForCausalLM.from_pretrainedfails on them #6163, from fix(writer): list definition-excluded linears for GPTQ HF interop #6232; the broadermodules_in_block_to_quantizeinterop work was [BUG] writer/HF interop: GPTQ checkpoints never recordblock_name_to_quantize, sofrom_pretrainedfails with "Block pattern could not be match" for SmolVLM2 (and other models whose decoder is not atmodel.layers) #6182)._definition_dense_decoder_linears()walks block-residentnn.Linearmodules and resolves each layer-relative path through the compiledModulePlan, returning leaves whose spec hasquantize=False(a:!leaf)._gptq_explicit_quantized_modules()now emits the explicit Optimum inclusion list when either dynamic-:exclusions or definition-declared dense decoder linears exist; the writer passesowner=self.docs/quantization-features.mddocuments the new source.Defused dense gate/up MLP warning ([BUG] writer/HF interop: Phi-3/Phi-3.5/Phi-4 and GLM-OCR GPTQ checkpoints save the defused
mlp.gate_proj/up_proj, soAutoModelForCausalLM.from_pretrainedrandomly initializesgate_up_proj(PPL 1e11) andsave()gives no warning #6166, from fix(writer): warn when a defused dense gate/up MLP cannot load in HF (#6166) #6233)._defuser_split_gate_up_class_names()reads Defuser's_STANDARD_SPLIT_GATE_UP_CLASSESregistry and_defused_dense_gate_up_modules()detects parents carryinggate_proj/up_projwithoutgate_up_proj, using Defuser's runtime split marker or the class registry.hf_compat_warnings()then warns with the exact split keys and the fused key that plain HF reports as MISSING/UNEXPECTED, and points atGPTQModel.load.Conflict resolution
All three PRs inserted a helper into the same
writer.pyblock, and #6232 also edited_gptq_explicit_quantized_modules()next to #6230's helper. The combined tree keeps all helpers with docstrings intact:_defuser_split_gate_up_class_names()and_defused_dense_gate_up_modules()(fix(writer): warn when a defused dense gate/up MLP cannot load in HF (#6166) #6233) before_has_per_expert_quantized_modules(); fix(writer): warn when a defused dense gate/up MLP cannot load in HF (#6166) #6233's warning block inhf_compat_warnings()is unchanged._awq_dense_base_modules()(fix(awq): publish definition-owned dense towers in modules_to_not_convert (#6192) #6230) followed by_definition_dense_decoder_linears()(fix(writer): list definition-excluded linears for GPTQ HF interop #6232), both before_gptq_explicit_quantized_modules().ownerparameter and_gptq_explicit_quantized_modules(..., owner=self)call-site update are kept, and fix(awq): publish definition-owned dense towers in modules_to_not_convert (#6192) #6230's AWQ seeding block insave()is kept separately before the config save block.FUSED_PROJECTION_UNITS(fix(writer): warn when a defused dense gate/up MLP cannot load in HF (#6166) #6233) andget_module(fix(awq): publish definition-owned dense towers in modules_to_not_convert (#6192) #6230).No helper, test or doc line was dropped or renamed.
Files
gptqmodel/models/writer.pydocs/quantization-features.mdtests/test_qwen2_5_vl_local_port.pytests/test_qwen2_vl_local_port.pytests/test_lfm3_local_port.pytests/test_checkpoint_compat.pyTest commands
CPU-only (
CUDA_VISIBLE_DEVICES=""), fromtests/:Per-PR named nodes:
Green evidence (combined tree, HEAD cf7aee0)
Red evidence (combined
writer.pyreverted tomain, tests kept)git checkout origin/main -- gptqmodel/models/writer.py, then the four named nodes:The
writer.pychange was restored immediately after the red run; the worktree is clean.Skips / unverified
test_checkpoint_compat.pyskips 3lm_headquantization tests that need an accelerator.from_pretrainedand CUDA Marlin loads are not covered here.docs/quantization-features.mdis Markdown, soruff checkdoes not lint it; all changed Python files pass.Rebase verification
90af7b2dis rebased ontocc10a7a5. The singlegptqmodel/models/writer.pyconflict was the..utils.modelimport list; bothFUSED_PROJECTION_UNITS(this PR) andMODALITY(fix(writer): stop copying remote-code .py files when a native definition owns the config #6287) are kept. No PR hunks were dropped.81ac1769produced a patch-identical tree (same six files, same changes; only hunk line offsets differ).90af7b2dacross the four PR test files plustest_hf_config_compat.py, the remote-code family andtest_writer_*(15 files): 218 passed, 3 skipped, 1 failed.tests/test_checkpoint_compat.py::test_gptq_block_name_loads_through_plain_hf(not added here) hits [BUG] HF bridge:AutoModelForCausalLM.from_pretrainedof a GPT-QModel GPTQ checkpoint crashes when anyin_featuresis not a multiple ofgroup_size(SmolLM2 hidden=576, g128): bridge returns MarlinLinear without shape info #6149's shape-blind grouped-kernel refusal in the HF bridge on this AVX512 CPU host. It passes on this PR's original base2d3261ddand fails on81ac1769without these writer changes.ruff checkon all changed Python files: All checks passed.