Skip to content

Fix overflow and underflow across quantized packing paths - #3519

Merged
Qubitium merged 1 commit into
mainfrom
fix/packing-numeric-boundaries
Nov 3, 2026
Merged

Qubitium merged 1 commit into
mainfrom
fix/packing-numeric-boundaries

Conversation

@Qubitium

@Qubitium Qubitium commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

Fix silent packing corruption across GPTQ, AWQ, QQQ, FP8 and GGUF MXFP4. For example, valid BF16 AWQ weights could recover code 255 as 256 and serialize it as 0; QQQ could divide a nonzero FP16 scale to zero before storing it as FP32.

  • Recover GPTQ/AWQ/QQQ codes in FP32, saturate before integer conversion, and mask individual AWQ fields before shifting. Correct QQQ's channelwise signed INT4 bounds.
  • Widen QQQ channel scales before division; bound FP8 inverse scales and MXFP4 exponents before overflow/unsigned conversion. Apply the corresponding fixes to the Metal packers, including subnormal MXFP4 inputs.
  • Reject unrepresentable scaled zero offsets before changing GEMV_FAST/LLM_AWQ or Machete state.
  • Add independent complete-byte/code oracles for rounding neighbors, endpoints, finite FP16 overflow, BF16 endpoints and tiny scales. Update old tests that preserved unsafe arithmetic, and correct the Marlin comparison's v1/v2 reference setup.

Validation on this host:

Suite RTX 4090 / CUDA Radeon AI PRO R9700 / ROCm
Boundary + BitBLAS buffer tests 139 passed, 28 optional skips 139 passed, 28 optional skips
Existing packing/numerical regressions 192 passed, 2 Metal skips 145 passed
Native load/API checks 74 passed, 3 skips 37 passed, 2 skips

The same applicable boundary tests reproduce 53 failures on the base revision. A separate run with the real BitBLAS compressor passes all 56 tests. Repository-wide Ruff and diff checks pass.

Byte/code comparisons are exact, with no mismatches in the passing matrix. Packing cases cover FP16/BF16, 2–8-bit GPTQ, 4/8-bit AWQ, and 64×128/64×256 layers. FP8 scale comparisons use rtol ≤ 1e-6; the Marlin comparison now uses atol=rtol=2e-3.

Limits: this Linux host cannot execute Metal or the Qwen projection benchmarks for MLX. Machete's rejection path is tested on CPU/CUDA/ROCm, but its SM90 native kernel is not exercised. BitBLAS validation covers real compression and buffer installation, not native matmul code generation. No throughput benchmark or full-model evaluation is claimed.

@Qubitium
Qubitium merged commit 72cde6d into main Nov 3, 2026
6 checks passed
@Qubitium
Qubitium deleted the fix/packing-numeric-boundaries branch November 3, 2026 15:46
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.

1 participant