You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] AwqGEMMLinear permanently rewrites checkpoint scales/bias to the activation dtype #4178
Severity: medium — accuracy drifts after a forward in a different dtype; state_dict() no longer equals the checkpoint Version: 7.11.0 @ 6c3421c
Summary
nn_modules/qlinear/gemm_awq.py:262-266 (_ensure_runtime_dtype, called on every forward) casts self.scales and self.bias in place to the activation dtype. One bf16 forward on an fp16 checkpoint narrows the stored scales for good.
Reproduce (2048×1024, g128)
fp16 forward rel err vs oracle: 3.5e-4
-> one bf16 forward
fp16 forward rel err vs oracle afterwards: 2.1e-3 (6x worse, permanent)
87% of scales changed; state_dict() != checkpoint
AwqTorchLinear was already fixed for the same pattern (see its _scales_for_compute docstring).
Suggested fix
Use a per-call cast (scales.to(x.dtype) into a temporary), or the _scales_for_compute approach from AwqTorchLinear. Never assign the cast back to the registered buffer.
Related (low): CPU int4pack kernels with BF16 activations
These are TorchAten, TorchFused and their AWQ twins.
_cpu_int4pack_scale_dtype (torch_aten_kernel.py:52) narrows fp16 scales to bf16 whenever the offsets are exact, i.e. every sym=True checkpoint, without checking that the scales survive the cast. It also mutates self.scales.
The FP32 product is requested only for fp16 (torch_aten_kernel.py:418, torch_fused.py:514, torch_fused_awq.py:286, torch_aten_kernel_awq.py:211). BF16 layers with bias round the product to bf16 before adding the bias.
Each is about one bf16 ulp (2.5–6e-3 normalised), above the 2e-3 oracle tolerance.
Found during an AI-assisted review (Claude Code) of 6c3421c; repros were run on RTX 4090/5090 (CUDA 13) and Radeon AI PRO R9700 (ROCm) unless marked static/suspected.
Activity
fix(awq): keep checkpoint scales and bias out of the activation dtype (…
fix: realign stale test expectations and two product defects (#4358) (#…
fix(cpu): detach the Fused and Paro int4 operands from the checkpoint…
fix(cpu): detach the Fused and Paro int4 operands from the checkpoint…
test: realign residual suite triage with current kernels and layouts (M…