Zero the padding of MXFP4 scale tensors allocated in C++ #813
All Vouch review confidence checks passed
Residual risk 0.16 = Change Risk (0.36) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.36 · 208 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.320
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #813"
general
weight: 0.35
matthiasdiener
Problem
tests/pytorch/mxfp4/test_mxfp4_module_exact.pyfails intermittently on MI355X with NaN output, e.g.test_mxfp4_linear_versus_reference[with_hadamard-single_step-torch.bfloat16-no_bias-128-256]in run 45064495409. Beyond the tests, any MXFP4 GEMM with K=128 can return wrong values or NaN, depending on what memory the allocator hands out.Root cause
MXFP4Quantizerallocates its scale tensors in C++ withat::empty. They are padded: rows to a multiple of 256, scale columns to a multiple of 8. The cast kernel writes only the scales of real 32-element blocks, but the AITER a4w4 GEMM also reads the padding when K is not a multiple of 256, so leftover bytes end up in the result (0xFFis NaN in E8M0). The Python allocator,MXFP4Quantizer.make_empty, which the Triton cast path also uses, already zeroes these tensors.Fix
create_tensor,create_grouped_tensorandconvert_and_update_tensorallocate padded scale tensors withat::zeros. Unpadded ones keepat::empty, so aligned shapes pay nothing.Testing (MI355X, ROCm 10.1)
test_quantization_zeroes_scale_paddingmakes uninitialized memory read as0xFF(torch.utils.deterministic.fill_uninitialized_memory) and checks that no scale byte is left unwritten. Without the fix 6 of its 8 cases fail; with it all pass.tests/pytorch/mxfp4/fails 12 tests without the fix (every Linear and LayerNorm/RMSNorm-Linear case with a K=128 GEMM). With the fix it passes, 917 passed and 8 skipped, both poisoned and normally.