Skip to content

[NUMERICS] bf16 accuracy deviations: ParoQuant rounds after every Givens stage, MACaQ W4A16/Torch W4A4 skip FP32 reduce, MLX QQQ narrows bf16 to fp16 #4221

Closed

Description

@Qubitium

Severity: low
Version: 7.11.0 @ 9dad249

1. ParoQuant bf16 rotation rounds after each Givens stage (about 3× the error of one rounding)

  • Where: utils/paroquant.py apply_paroquant_rotation_reference / _vectorized cast cos/sin and the output to the activation dtype at each of the krot stages. The fused CUDA/HIP op behaves similarly for gs -1 and 16.
  • Measured (bf16, CUDA and ROCm):
Quantity Per-stage rounding (current) Single rounding
Rotated activation error 1.1–1.3e-2 1.6–3.3e-3
ParoLinear output error 9.2e-3 (sweep worst 1.4e-2) 3.0e-3
ParoQuantTritonLinear sweep worst 1.7e-2 —

fp16 is fine.

2. MACaQ W4A16 and Torch W4A4 use a plain bf16 F.linear

  • Where: nn_modules/qlinear/macaq.py _forward_torch and utils/macaq_triton.py mxfp4_w4a16_linear (last line) skip the repo's linear_fp32_reduce helper (_numerics.py), so cuBLAS uses reduced-precision bf16 reduction.
  • Measured: K=11008, N=512, M=256: 6.5e-3 vs 3.3e-3 with an fp32-reduce matmul (about 1.7 ulp) on CUDA. ROCm is fine.

3. MlxQQQLinear narrows bf16 activations to fp16 before quantizing (static read, no Apple hardware)


Found during an AI-assisted review (Claude Code) of 9dad249; repros were run on RTX 4090/5090 (CUDA 13) and/or Radeon AI PRO R9700 (ROCm) unless marked static/suspected.

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

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions