Skip to content

[BUG] Default AWQ (and QQQ) quantize crashes at pack time for out_features % 64 != 0 (FalconMamba/Mamba x_proj 8192->288): packer AwqGEMMLinear not re-validated per module; #4513 incomplete end-to-end #4567

Closed

Description

@Qubitium

Found on main @ 4b65923, RTX 4090 (sm89), torch 2.15 + CUDA 13.2.

What is wrong

With the default backend, AWQ quantize picks one packing kernel for the whole model: AWQProcessor._resolve_qlinear_kernel returns self.gptq_model.qlinear_kernel, which is AwqGEMMLinear for FORMAT.GEMM on CUDA (gptqmodel/looper/awq_processor.py:570-588). That kernel is never re-validated against the module's shape. AwqGEMMLinear declares SUPPORTS_OUT_FEATURES_DIVISIBLE_BY = [64] (gemm_awq.py:196). Any quantized linear whose out_features % 64 != 0 therefore raises in submodule_finalize -> pack_module -> create_quant_module after the whole calibration has run:

NotImplementedError: <class 'gptqmodel.nn_modules.qlinear.gemm_awq.AwqGEMMLinear'>: `out_features`: 288 must be divisible by [64].

The checkpoint format (GEMM) has a portable packer that accepts this shape: AwqTorchLinear, SUPPORTS_OUT_FEATURES_DIVISIBLE_BY = [8]. quantize(..., backend=BACKEND.AWQ_TORCH) succeeds on the same model. _resolve_qlinear_kernel already falls back to AwqTorchLinear for non-4-bit modules and unsupported group sizes, but not for unsupported widths.

Real models hit this. FalconMamba-7B's Mamba x_proj is 8192 -> 288 (time_step_rank 256 + 2*state 16). Mamba-1/Jamba/Zamba have the same x_proj = dt_rank + 2*d_state layout. x_proj was added to the Jamba plan in #4041. #4513 (fix for #4474) made AWQ clip search handle a partial output tile so that these widths could be quantized. With the default backend, the run still crashes at pack time, so that fix is incomplete end to end. #4474's repro used BACKEND.TORCH and never reached AwqGEMMLinear.

QQQConfig has the same late failure on the same shape. QQQTorchLinear.validate (qqq.py:376-383) raises ValueError: ... not supported infeatures: 8192 and outfeatures: 288 from finalize after calibration, because nothing checks the module shape against the QQQ tiles (64,256)/(128,128)/(128,64)/(64,128) before the run. That method has no portable fallback, so the right behavior is to reject at plan time, or to leave such a module dense with a warning, rather than lose the whole run at the end.

Repro

A 2-layer FalconMamba built from the falcon-mamba-7b-instruct config (only num_hidden_layers=2, random weights, saved locally):

m = GPTQModel.load(tiny_falcon_mamba, AWQConfig(bits=4, group_size=128), dtype=torch.bfloat16)
m.quantize([tok("The quick brown fox jumps over the lazy dog. " * 20)["input_ids"]] * 8)
# NotImplementedError: <class '...gemm_awq.AwqGEMMLinear'>: `out_features`: 288 must be divisible by [64].
# (raised from AWQProcessor.submodule_finalize -> pack_module, after all layers were processed)

m.quantize(..., backend=BACKEND.AWQ_TORCH)   # OK -> ['AwqTorchLinear']

m = GPTQModel.load(tiny_falcon_mamba, QQQConfig(bits=4, group_size=128), dtype=torch.bfloat16)
m.quantize(...)
# ValueError: <class '...qqq.QQQTorchLinear'> not supported `infeatures`: 8192 and `outfeatures`: 288.

On the full 7B model the failure comes after the entire calibration.

Suggested fix

  • AWQ: in _resolve_qlinear_kernel, validate the candidate with the module's in_features/out_features. If it rejects them, fall back to AwqTorchLinear (same GEMM checkpoint layout). Inference AUTO already picks a compatible kernel per layer at load, so the saved checkpoint stays loadable.
  • QQQ (and any method whose packers all have tile constraints): check every planned module's shape before calibration starts. Raise early with the module name, or exclude the module with a warning.

Test that should have caught it

tests/test_awq_clip_consistency.py / test_awq_clip_partial_tile_4474.py cover clip search only with BACKEND.TORCH. Add an end-to-end AWQ quantize with the default backend on a model with out_features % 64 != 0, such as a tiny FalconMamba/Mamba or the existing hidden=96 Qwen3 fixture on CUDA.

Severity

High for affected architectures: default AWQ/QQQ quantization of FalconMamba/Mamba-family models always fails, and only at the very end.

🤖 Generated with Claude Code

Activity

  1. Qubitium commented on Nov 17, 2026

    @Qubitium
    CollaboratorAuthor

    Claimed. This issue is now owned by a dedicated worker; a fix PR referencing it will follow.

  2. Qubitium commented on Nov 17, 2026

    @Qubitium
    CollaboratorAuthor

    Taking this — it is the end-to-end half of #4513, which I merged. I'll validate the packing kernel against each module's shape (with the AwqTorchLinear fallback) and add a plan-time shape check for QQQ, then open a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions