Repository navigation
fix(awq,qqq): validate the packing kernel per module and fail early for QQQ (#4567) - #4624
Merged
Merged
Conversation
…or QQQ AWQ picked one model-wide packing kernel before any module shape was known, so a width the checkpoint format supports (FalconMamba/Mamba x_proj 8192->288) still raised inside create_quant_module after the whole calibration. Resolve the kernel against each module's real geometry at preprocess/pack time and fall back to the portable AwqTorchLinear of the same GEMM layout when the requested kernel cannot pack the shape. QQQ has no portable kernel, so validate each planned module against the selected kernel's tile contract at preprocess time and fail on the first offending module with its name and a -: dynamic-rule suggestion. Issue #4567.
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.
Root cause
AWQ chose one model-wide packing kernel in
AWQProcessor._resolve_qlinear_kernelbefore any module shape was known.AwqGEMMLinearonly packsout_features % 64 == 0, so a width the checkpoint format itself supports (FalconMamba/Mambax_proj8192 -> 288) raised insidesubmodule_finalize -> pack_module -> create_quant_moduleafter the whole calibration had run.AwqTorchLinearpacks the sameFORMAT.GEMMlayout for that shape, but the fallback only covered non-4-bit modules and unsupported group sizes.QQQ had the same late failure:
QQQTorchLinear.validatetiles(64,256)/(128,128)/(128,64)/(64,128)and was only consulted at finalize.Changes
gptqmodel/looper/awq_processor.py): threadin_features/out_featuresthrough_resolve_qlinear_kernel/_resolve_module_kerneland validate the candidate against the kernel's own static shape contract (_validate_shape_constraints, not the full runtime-probingvalidate). When the requested kernel cannot pack the shape, fall back toAwqTorchLinear(same GEMM checkpoint layout) with a warning; if neither kernel fits, keep the requested one so its module-specific error still surfaces. The pack step now resolves from the real source module geometry.gptqmodel/looper/qqq_processor.py): validate each planned module atpreprocesstime against the selected kernel'sIN_OUTPUT_FEATURES_DIVISIBLE_BYtiles and raise on the first offending module with its name and a-:dynamic-rule suggestion instead of losing the run at finalize. Capture-only modules (never packed) are skipped._quant_linear_kernelis also tolerant of partially constructed processors.Tests
New
tests/test_awq_qqq_pack_shape_4567.py(12 tests) covers the AWQ fallback/native/no-shape/no-kernel-fits cases, an end-to-end tiny-Qwen3 AWQ quantize that asserts the pack step sees the real module geometry, QQQ early rejection (8192x288, 256x288, 96x96), QQQ acceptance of valid tiles, and the error text. It fails on unmodifiedmain(8 failed) and passes with the fix.Broad
pytest tests/ -k "qqq or awq" -m "not model and not slow"(CPU) shows no new failures versusorigin/main: the remaining AWQ CPU-AVX512/granite/flint/CUDA-JIT failures reproduce on unmodified main.Note: #4513 fixed AWQ clip search for a partial output tile but never reached
AwqGEMMLinearwith the default backend; this is the end-to-end half.Closes #4567.