Skip to content

fix(awq): search a partial output tile instead of rejecting the width - #4513

Merged
Qubitium merged 1 commit into
mainfrom
fix/issue-4474-awq-clip-tail
Nov 17, 2026
Merged

Qubitium merged 1 commit into
mainfrom
fix/issue-4474-awq-clip-tail

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

Summary

Fixes #4474. AWQ clip search chose oc_batch_size = 256 if out_features % 256 == 0 else 64 and then asserted out_features % oc_batch_size == 0, while the portable AWQ packer only requires divisibility by its own packing factor (torch_awq.py, 8). A supported quantize() therefore aborted with a bare AssertionError after scale search and final scale folds, before packing/saving:

# Qwen3 hidden_size=96, intermediate_size=192, AWQ W4 GEMM group_size=32, CPU BACKEND.TORCH
# AssertionError at awq_processor.py:_compute_best_clip  (96 % 64 != 0)

What Changed

  • gptqmodel/looper/awq_processor.py (_compute_best_clip): clip search now owns only a tile size. The loop walks range(0, out_features, oc_batch_size) and every scratch slice on the output-channel axis is cropped to the tile's row count, so the final tile may be partial.
  • oc_batch_size is clamped to out_features so widths below the tile size run as a single tile.
  • A final check raises a clear RuntimeError if the returned bounds do not cover every output row before the caller mutates the weight (replacing the old bare assert).
  • tests/test_awq_clip_consistency.py: tile-independence tests for out_features 96/100/130 (group_size -1 and 32), comparing the full search against the same search over each tile's rows, plus exact-oracle coverage for widths 1/7/63/65.

Clip search is row-independent, so results for widths that were already accepted are bitwise unchanged — the new tile tests assert exactly that.

Tests

CPU-only (GPTQ_BYPASS_SAFETY_CHECKS=1, CUDA_VISIBLE_DEVICES="", PYTHONPATH = worktree):

pytest tests/test_awq_clip_consistency.py -q
# 41 passed, 30 skipped

pytest tests/test_awq_clip_consistency.py tests/test_awq_weight_mean.py \
       tests/test_awq_gptq_lifecycle.py tests/test_awq_rank_and_empty.py -q
# 159 passed, 58 skipped

ruff check gptqmodel/looper/awq_processor.py tests/test_awq_clip_consistency.py
# All checks passed

The 10 new parametrizations fail on unmodified main (AssertionError: 96 % 64 != 0 / 1 % 64 != 0) and pass with the fix.

The issue's own repro now completes end to end:

INFO  Quantization coverage for `Qwen3QModel`: all 7 layer-module spec(s) matched at least one layer.
INFO  Quantize summary: 1 layer(s), 7 module(s), 1s
OK quantized; q_proj out_features 96

Notes

  • The CUDA-only clip tests in the same file stay skipped on this host; the tiling code path is device-agnostic and shared.
  • No API change: _compute_best_clip still returns the same [out_features, n_group, 1] bounds.

AWQ clip search picked oc_batch_size=256/64 and asserted out_features was
divisible by it, while the portable packer only requires divisibility by its
own packing factor. A supported quantize() therefore aborted with a bare
AssertionError after scale search and never reached packing:

  Qwen3 hidden_size=96, AWQ W4 GEMM g32, CPU BACKEND.TORCH
  -> AssertionError: 96 % 64 != 0

Iterate tiles of oc_batch_size and crop every scratch slice to the tile's row
count, so the final tile may be partial. Clip search is row-independent, so the
bounds are unchanged for widths that were already accepted. Assert that the
returned bounds cover every output row before the caller mutates the weight.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] AWQ clipping rejects output widths accepted by its portable backend

1 participant