Skip to content

fix(awq,qqq): validate the packing kernel per module and fail early for QQQ (#4567) - #4624

Merged
Qubitium merged 1 commit into
mainfrom
fix/issue-4567-pack-shape
Nov 17, 2026
Merged

Qubitium merged 1 commit into
mainfrom
fix/issue-4567-pack-shape

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

Root cause

AWQ chose one model-wide packing kernel in AWQProcessor._resolve_qlinear_kernel before any module shape was known. AwqGEMMLinear only packs out_features % 64 == 0, so a width the checkpoint format itself supports (FalconMamba/Mamba x_proj 8192 -> 288) raised inside submodule_finalize -> pack_module -> create_quant_module after the whole calibration had run. AwqTorchLinear packs the same FORMAT.GEMM layout for that shape, but the fallback only covered non-4-bit modules and unsupported group sizes.

QQQ had the same late failure: QQQTorchLinear.validate tiles (64,256)/(128,128)/(128,64)/(64,128) and was only consulted at finalize.

Changes

  • AWQ (gptqmodel/looper/awq_processor.py): thread in_features/out_features through _resolve_qlinear_kernel / _resolve_module_kernel and validate the candidate against the kernel's own static shape contract (_validate_shape_constraints, not the full runtime-probing validate). When the requested kernel cannot pack the shape, fall back to AwqTorchLinear (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.
  • QQQ (gptqmodel/looper/qqq_processor.py): validate each planned module at preprocess time against the selected kernel's IN_OUTPUT_FEATURES_DIVISIBLE_BY tiles 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_kernel is also tolerant of partially constructed processors.
  • Updated two pre-existing unit fixtures whose arbitrary tiny shapes (32x32, 64->8) can no longer be packed by any QQQ kernel, so they now use a packable 64x256 shape; the assertions are unchanged.

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 unmodified main (8 failed) and passes with the fix.

tests/test_awq_qqq_pack_shape_4567.py tests/test_qqq_dynamic_group_size.py
tests/test_fallback.py::test_processor_merges_the_processor_fallback_under_the_override
tests/test_shared_input_hessian_dedup_methods.py
tests/test_awq_clip_consistency.py tests/test_qqq_uncaptured_fallback_4468.py
-> 79 passed, 30 skipped

Broad pytest tests/ -k "qqq or awq" -m "not model and not slow" (CPU) shows no new failures versus origin/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 AwqGEMMLinear with the default backend; this is the end-to-end half.

Closes #4567.

…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.
@Qubitium
Qubitium merged commit ff5d593 into main Nov 17, 2026
9 checks passed
@Qubitium
Qubitium deleted the fix/issue-4567-pack-shape branch November 17, 2026 05:41
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