Repository navigation
[Triton/Gluon] Use a zero default for masked scales in gemm_afp8wfp8 - #6007
Conversation
Signed-off-by: Mehmet Cagri Kaymak <mehmet.kaymak@amd.com>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The claimed LDS-poisoning regression is not covered by a committed test.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Changes masked E8M0 scale defaults to zero to prevent stale-LDS NaNs in Triton MXFP8 GEMM paths.
Changes:
- Uses zero defaults for masked activation and weight scales.
- Covers standard, packed, and preshuffled kernel variants.
| File | Description |
|---|---|
aiter/ops/triton/_triton_kernels/gemm/basic/gemm_afp8wfp8.py |
Zero-fills masked scale lanes. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copy PR from: vllm-project/vllm#59454
Purpose
This fix changes masked scale data from 127 (value 1.0 for e8m0) to 0 (value 2^(-127). This change is benign in terms of accuracy as the main value side already loads corresponding lanes for mfma as 0. So, scales get multiplied by 0 and has no accuracy effect.
When other=127, triton 3.8.0+gitc0a142ff leads to reading stale LDS data for the lanes corresponding to the masked scales due to a compiler bug. This bug is fixed on upstream triton but this fix resolves stale data reading issue for both compiler versions.
With other=127 and triton 3.8.0+gitc0a142ff, if LDS addresses corresponding to the masked lanes have "NaN", this leads to the result and produce inaccurate results. This is a rare case but it can still happen in practice. Reproduction relies on what LDS contains from previous runs.
This is a cleaner solution as hardware can already handle writing 0s to the masked lanes almost for free compared to writing any other value.
As a side effect, it also reduces total instruction count:
Main is upstream triton/main.
3.8.0 is triton 3.8.0+gitc0a142ff.
Instruction counts that differ between the builds (whole kernel)
s_mov_b32s_xor_b64s_and_saveexec_b64s_or_b64s_andn2_saveexec_b64ds_write_b32v_mov_b32_e32s_cbranch_execzv_cndmask_b32_e64s_waitcntv_lshlrev_b16_e32v_or_b32_sdwav_perm_b32s_cbranch_execnzs_movk_i32v_bfrev_b32_e32v_lshl_or_b32v_or_b32_e32s_barriers_load_dwords_nops_or_saveexec_b64v_add_u32_e32v_cmp_lt_i32_e64v_cndmask_b32_e32s_ashr_i32s_bfe_i32s_branchs_load_dwordx2s_lshl_b32v_add3_u32v_and_or_b32v_ashrrev_i32_e32v_cmp_eq_u32_e64v_cmp_le_i32_e64v_lshl_add_u32v_lshrrev_b32_e32v_mad_u64_u32v_mul_lo_u32v_or3_b32Performance is unchanged for triton 3.8.0+gitc0a142ff.
Performance: DeepSeek-V4.1-Flash shapes
aiter
gemm_afp8wfp8(v0.1.24, shipped configs, Triton 3.8.0) on one MI355X. Time per call in us, from HIP-graph replay with weights cold in cache, median of 5-7 replays. Each cell: without fix / withother=0;*marks a point that returns NaN without the fix after the 0xFF LDS fill.Test Plan
Existing tests pass, also the cases with LDS poisoning LDS with NaNs from another kernel.
Test Result
Tests pass.