Skip to content

[ASM] Fix MLA PS mode nan error for kv page0 has nan data and the LTD OOB read page0 data - #7872

Merged
shengnxu merged 7 commits into
mainfrom
mmd/dev/ltd_nan
Nov 15, 2026
Merged

shengnxu merged 7 commits into
mainfrom
mmd/dev/ltd_nan

Conversation

@minmengdie

@minmengdie minmengdie commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Stop the gfx950 persistent (PS) MLA decode kernels from reading KV slot 0 on the out-of-range lanes of a work item's last KV tile. With a NaN anywhere in the latent part of KV slot 0, those lanes turned whole output rows into NaN even when no kv_indices entry pointed at slot 0. The kernels now clamp every page-table read to the last valid entry of the work item. 34 .co are rebuilt; each one is main's .co plus only the clamp instructions. There are no source, CSV or dispatch changes in aiter.

Motivation

The persistent decode kernels load the page table (kv_indices) through a buffer resource whose num_records is set to this work item's count * 4 bytes, and then gather KV rows by the loaded page ids. The last SUB_KV tile of a work item still runs full width, and the page-table prefetch runs one tile ahead. Lanes past the end of the work item are out of range, the OOB buffer_load returns 0, and those lanes gather KV slot 0.

  • Their score is selected to -inf, so P = 0 and finite data in slot 0 never changes the output (bit-identical).
  • The V side is still multiplied: P * V = 0 * V. If any element of the 512 latent dims of slot 0 is NaN (fp8 0x7f / 0xff, bf16 NaN), 0 * NaN = NaN reaches the accumulator. MLA has one shared KV head, so every head of the row gets NaN on those dims. The LSE stays correct.
  • A row is clean only when every work item length is a multiple of the tile width. The auto split (max_split_per_batch = -1) makes that rare.

This contract (slot 0 must hold finite data even when nothing references it) is not documented, and real callers break it:

Any other caller whose slot 0 can hold non-finite bytes (freed / reused blocks, padding targets) is exposed until this lands.

Changes

Kernel source: poc_kl_merg mmd/fix/mla_kv_page0_nan.

  • bd608c9: page-table clamp in MLA_A16W16_QH32_1TG_4W_32mx4_32nx1_PS_gqaratio96.sp3 and MLA_A8W8_QH16_1TG_4W_16mx1_32nx4_PS.sp3.
  • d9381a8: the same clamp in the other PS kernels of mla_kernel_list_mi350.csv (MLA_A16W16_QH32_..._PS, MLA_A16W16_QH64_..._mtp0_v3_PS, MLA_A16W16_QH16_..._16mx4_32nx1_PS, MLA_A8W8_QH32_..._32mx4_64nx1_PS, MLA_A8W8_QH64_..._32mx2_32nx2_PS, MLA_A8W8_QH32_..._32mx1_32nx2_PS, MLA_A8W8_QH16_..._16mx4_64nx1_PS, plus the mtp0 / mtp1 sources that aiter does not ship).
  • d06974a: ports the [ASM] Fix LDS races in gfx950 FP8 QH16 qseqlen1 persistent MLA decode #7622 LDS race fixes into MLA_A8W8_QH16_1TG_4W_16mx1_32nx4_PS.sp3. [ASM] Fix LDS races in gfx950 FP8 QH16 qseqlen1 persistent MLA decode #7622 patched them into the .co directly, so a rebuild from the SP3 would otherwise have dropped them.

The clamp: s_LTD_last = (s_total_ps - 1) * 4 per work item, and a v_min_u32 after every page-table address update (address generation, the two prefetch increments, LTD_mem_va_upd). Tail lanes then repeat the last valid page id instead of reading id 0; their weight is still 0, so the result is unchanged for finite data.

Rebuilt hsa/gfx950/mla/*.co (34):

.co count
mla_a16w16_qh32_qseqlen4_gqaratio96_{,lse_,cprr_,lse_cprr_,msk0_,msk0_lse_,msk0_cprr_,msk0_lse_cprr_}ps 8
mla_a16w16_qh32_qseqlen4_gqaratio32_{,lse_,cprr_,lse_cprr_,msk0_,msk0_lse_,msk0_cprr_,msk0_lse_cprr_}ps 8
mla_a16w16_qh64_qseqlen1_gqaratio64_{,cprr_,lse_cprr_}v3_ps 3
mla_a16w16_qh16_qseqlen4_gqaratio16_{,lse_}ps (not in mla_asm.csv) 2
mla_a8w8_qh16_qseqlen1_gqaratio16_{,lse_}ps 2
mla_a8w8_qh32_qseqlen4_gqaratio32_{,lse_,cprr_,lse_cprr_}ps 4
mla_a8w8_qh16_qseqlen4_gqaratio16_{,lse_,cprr_,lse_cprr_}v3_ps 4
mla_a8w8_qh32_qseqlen4_gqaratio8_{,lse_}ps 2
mla_a8w8_qh16_qseqlen4_gqaratio16_ps (not in mla_asm.csv) 1

For every one of them, a normalized llvm-objdump diff against main's .co shows no removed or changed instruction; the only additions are the clamp (v_min_u32 and the two s_LTD_last setup instructions, 13 to 21 instructions per kernel).

Not changed:

  • mla_a16w16_qh64_qseqlen1_gqaratio64_lse_v3_ps: its SP3 source has a different LSE sanitize bound (+-64) than the shipped .co (+-inf), so a rebuild would change behavior beyond this fix.
  • mla_a16w16_qh16_m16x4_n16x1_coex0_mask1{,_lse}_ps: the SP3 source is not in poc_kl_merg.
  • The fp8 gqaratio8 / gqaratio32 msk0 PS .co: they are not built from the kernel list, so their source is unknown.

Performance (if applicable)

decode:asm_576 from op_tests/test_mla_persistent.py. Each of 3 rounds ran on its own idle MI355X, with Before and After alternating on that GPU; the table shows the median of the 3 rounds. "Before" is main's .co.

Over all 28 shapes, the After/Before geomean is 0.9986 (range 0.984 .. 1.010). Running the same .co again varies by 1.15% (median of max-min over median) and up to 3.18%, so the change is within noise.

Hardware Workload/configuration Kernel Before After Change
MI355X fp8, nhead 16, qlen 1, B 128, ctx 8192 a8w8_qh16_qseqlen1_gqaratio16_ps 122.09 us 122.13 us +0.03%
MI355X fp8, nhead 16, qlen 4, B 128, ctx 8192 a8w8_qh16_qseqlen4_gqaratio16_v3_ps 150.69 us 150.67 us -0.02%
MI355X fp8, nhead 32, qlen 4, B 128, ctx 8192 a8w8_qh32_qseqlen4_gqaratio32_ps 222.37 us 221.24 us -0.51%
MI355X fp8, nhead 64, qlen 1, B 128, ctx 8192 a8w8_qh16_qseqlen4_gqaratio16_v3_ps 152.82 us 153.27 us +0.30%
MI355X bf16, nhead 16, qlen 1, B 128, ctx 8192 a16w16_qh64_qseqlen1_gqaratio64_v3_ps 225.14 us 226.17 us +0.46%
MI355X bf16, nhead 128, qlen 1, B 128, ctx 8192 a16w16_qh32_qseqlen4_gqaratio32_ps 365.25 us 365.16 us -0.02%
MI355X bf16, nhead 96, qlen 1, LSE, B 128, ctx 8192 a16w16_qh32_qseqlen4_gqaratio96_lse_ps 332.72 us 330.20 us -0.76%
All 28 shapes (B {32, 128} x ctx {4096, 8192})
Hardware Workload/configuration Kernel Before After Change
MI355X fp8, nhead 16, qlen 1, B 32, ctx 4096 a8w8_qh16_qseqlen1_gqaratio16_ps 29.83 us 29.99 us +0.56%
MI355X fp8, nhead 16, qlen 1, B 32, ctx 8192 a8w8_qh16_qseqlen1_gqaratio16_ps 41.73 us 41.68 us -0.14%
MI355X fp8, nhead 16, qlen 1, B 128, ctx 4096 a8w8_qh16_qseqlen1_gqaratio16_ps 69.01 us 68.87 us -0.21%
MI355X fp8, nhead 16, qlen 1, B 128, ctx 8192 a8w8_qh16_qseqlen1_gqaratio16_ps 122.09 us 122.13 us +0.03%
MI355X fp8, nhead 16, qlen 4, B 32, ctx 4096 a8w8_qh16_qseqlen4_gqaratio16_v3_ps 39.79 us 39.73 us -0.13%
MI355X fp8, nhead 16, qlen 4, B 32, ctx 8192 a8w8_qh16_qseqlen4_gqaratio16_v3_ps 56.30 us 56.39 us +0.14%
MI355X fp8, nhead 16, qlen 4, B 128, ctx 4096 a8w8_qh16_qseqlen4_gqaratio16_v3_ps 91.76 us 91.39 us -0.40%
MI355X fp8, nhead 16, qlen 4, B 128, ctx 8192 a8w8_qh16_qseqlen4_gqaratio16_v3_ps 150.69 us 150.67 us -0.02%
MI355X fp8, nhead 32, qlen 4, B 32, ctx 4096 a8w8_qh32_qseqlen4_gqaratio32_ps 60.69 us 60.50 us -0.31%
MI355X fp8, nhead 32, qlen 4, B 32, ctx 8192 a8w8_qh32_qseqlen4_gqaratio32_ps 87.13 us 87.31 us +0.20%
MI355X fp8, nhead 32, qlen 4, B 128, ctx 4096 a8w8_qh32_qseqlen4_gqaratio32_ps 135.30 us 136.63 us +0.98%
MI355X fp8, nhead 32, qlen 4, B 128, ctx 8192 a8w8_qh32_qseqlen4_gqaratio32_ps 222.37 us 221.24 us -0.51%
MI355X fp8, nhead 64, qlen 1, B 32, ctx 4096 a8w8_qh16_qseqlen4_gqaratio16_v3_ps 39.72 us 39.53 us -0.48%
MI355X fp8, nhead 64, qlen 1, B 32, ctx 8192 a8w8_qh16_qseqlen4_gqaratio16_v3_ps 55.92 us 55.93 us +0.02%
MI355X fp8, nhead 64, qlen 1, B 128, ctx 4096 a8w8_qh16_qseqlen4_gqaratio16_v3_ps 93.50 us 93.20 us -0.32%
MI355X fp8, nhead 64, qlen 1, B 128, ctx 8192 a8w8_qh16_qseqlen4_gqaratio16_v3_ps 152.82 us 153.27 us +0.30%
MI355X bf16, nhead 16, qlen 1, B 32, ctx 4096 a16w16_qh64_qseqlen1_gqaratio64_v3_ps 43.66 us 43.51 us -0.34%
MI355X bf16, nhead 16, qlen 1, B 32, ctx 8192 a16w16_qh64_qseqlen1_gqaratio64_v3_ps 70.59 us 69.82 us -1.09%
MI355X bf16, nhead 16, qlen 1, B 128, ctx 4096 a16w16_qh64_qseqlen1_gqaratio64_v3_ps 124.70 us 124.95 us +0.20%
MI355X bf16, nhead 16, qlen 1, B 128, ctx 8192 a16w16_qh64_qseqlen1_gqaratio64_v3_ps 225.14 us 226.17 us +0.46%
MI355X bf16, nhead 128, qlen 1, B 32, ctx 4096 a16w16_qh32_qseqlen4_gqaratio32_ps 84.34 us 82.99 us -1.60%
MI355X bf16, nhead 128, qlen 1, B 32, ctx 8192 a16w16_qh32_qseqlen4_gqaratio32_ps 125.12 us 124.79 us -0.26%
MI355X bf16, nhead 128, qlen 1, B 128, ctx 4096 a16w16_qh32_qseqlen4_gqaratio32_ps 207.33 us 209.40 us +1.00%
MI355X bf16, nhead 128, qlen 1, B 128, ctx 8192 a16w16_qh32_qseqlen4_gqaratio32_ps 365.25 us 365.16 us -0.02%
MI355X bf16, nhead 96, qlen 1, LSE, B 32, ctx 4096 a16w16_qh32_qseqlen4_gqaratio96_lse_ps 72.10 us 71.52 us -0.80%
MI355X bf16, nhead 96, qlen 1, LSE, B 32, ctx 8192 a16w16_qh32_qseqlen4_gqaratio96_lse_ps 116.97 us 115.77 us -1.02%
MI355X bf16, nhead 96, qlen 1, LSE, B 128, ctx 4096 a16w16_qh32_qseqlen4_gqaratio96_lse_ps 188.96 us 190.02 us +0.56%
MI355X bf16, nhead 96, qlen 1, LSE, B 128, ctx 8192 a16w16_qh32_qseqlen4_gqaratio96_lse_ps 332.72 us 330.20 us -0.76%

Testing

  • Unit tests added or updated
  • Performance benchmarks run
  • Tested on MI250X
  • Tested on MI300X
  • Tested on MI355X (gfx950). Only gfx950 .co change.

Every run swapped main's or this PR's 34 .co in through AITER_ASM_DIR, with all other kernels identical, and LoadKernel in the logs confirmed which file was used. Before and After ran the same commands.

Command Before (main) After (this PR)
test_mla_persistent.py -d bf16 -kvd bf16 -b 1 5 32 128 -c 21 256 1200 8192 with -n 16,1, 128,1 (+-lse), 32,4 (+--no-causal, --no-causal -lse), 96,1 (+-lse), 96,2 --no-causal (+-lse); 16,1, 128,1, 96,1 also with --varlen (13 configs x 16 shapes) all err == 0 all err == 0
test_mla_persistent.py -d fp8 -kvd fp8, same shapes, -n 16,1 (+-lse, --varlen), 16,4 (+-lse), 64,1, 32,4 (+-lse, --varlen), 8,4 (+-lse) (11 configs x 16 shapes) err > 0 only at ctx 21 (~0.13-0.21) and ctx 256 (~0.001), the usual fp8 tolerance pattern same pattern and magnitudes (the test draws new random inputs per run)
test_mla_persistent_round_robin.py -cp -cpw 2 8 -b 1 32 -c 64 1200 5200, bf16 -n 128,1 (+-lse), 96,1 (+-lse), 16,1 -lse; fp8 -n 32,4 -lse, 64,1 -lse bf16 all pass; fp8 4/12 rows err > 0 identical
KV slot 0 poisoning: no index references slots 0..255; slot 0 gets NaN in all / latent-only / one element / rope-only, other unreferenced slots get NaN as controls; row lengths 16..2048 with max_split_per_batch 1 and -1; 27 dispatch configs reaching every changed kernel except the two msk0_*cprr NaN rows in every config whenever the latent part of slot 0 holds a NaN (rope-only and other slots: no effect) no NaN and no changed output in any case
Clean outputs, same inputs, Before vs After (from the poisoning runs) 642 / 648 cases bit-identical; the 6 others are a8w8_qh16_qseqlen4_gqaratio16_*v3_ps, which is nondeterministic run to run on main already (same input, same .co, 29/29 runs differ in O)
#7622 race test (check_fp8_gqa16_multi_tile_batch, 3 repeats, with and without LSE) for mla_a8w8_qh16_qseqlen1_gqaratio16{,_lse}_ps 0 wrong (the pre-#7622 .co gives 6064 / 1182 wrong on the same machine) 0 wrong

Documentation

  • Docstrings updated
  • User guide updated
  • Performance guide updated
  • No documentation change is needed, with the reason stated below

Kernel binaries only; no API, behavior or tuning change. Callers no longer need to keep KV slot 0 finite.

Dependencies

  • No new third-party dependencies added
  • New dependencies are listed and justified below

Breaking Changes

None. Kernel names, kernarg layout, mla_asm.csv and dispatch are unchanged.

PR Self-Review

Reviewed revision

6589f37

Behavior and intent

The output of the changed gfx950 persistent MLA decode kernels now depends only on the KV slots listed in kv_indices[kv_indptr[b] : kv_indptr[b + 1]] for each row. Before this PR, the out-of-range lanes of a work item's last KV tile (and of the one-tile-ahead page-table prefetch) got page id 0 from the OOB page-table load and gathered KV slot 0. Their softmax weight is 0, but 0 * V still made the row NaN whenever the latent part of slot 0 held a NaN. That broke callers that reuse block 0 (ROCm/ATOM#3099), and nothing documented that slot 0 must stay finite. The existing behavior is insufficient because any caller can hold non-finite bytes in an unreferenced slot. Each changed kernel clamps every page-table address to the last valid entry of its work item, so tail lanes re-read a page the work item owns.

Validation and unverified scope

Validated on MI355X (gfx950), rocm/atom-dev container, with main's and this PR's .co swapped in through AITER_ASM_DIR:

  • Instruction-level: each of the 34 .co equals main's .co plus only clamp instructions (normalized llvm-objdump diff, nothing removed). Each one also rebuilds instruction-identically from poc_kl_merg d06974a.
  • Correctness: the op tests, the slot 0 poisoning matrix, the clean bit-identity check and the [ASM] Fix LDS races in gfx950 FP8 QH16 qseqlen1 persistent MLA decode #7622 race test in the Testing section.
  • Perf: see the Performance section; within noise.

Not verified:

  • ATOM end-to-end with this PR (ATOM#3099 currently reserves block 0 instead).
  • mla_a16w16_qh32_qseqlen4_gqaratio{32,96}_msk0_{,lse_}cprr_ps at runtime: cprr is only selected with causal, so dispatch never reaches them. Their instruction diff is the same clamp.
  • mla_a16w16_qh16_qseqlen4_gqaratio16_{,lse_}ps and mla_a8w8_qh16_qseqlen4_gqaratio16_ps at runtime: they are not in mla_asm.csv. Their instruction diff is the same clamp.
  • The bf16 gqaratio32_cprr_ps / gqaratio96_cprr_ps non-LSE variants are covered by the poisoning matrix only; the round-robin op test always requests LSE.
  • gfx942 is not affected: no gfx942 .co changed. The kernels listed under "Not changed" keep the old behavior.

PR-specific question

The changed kernels are selected only on gfx950 in persistent mode (csrc/py_itfs_cu/asm_mla.cu, mla_asm_decode_config), by the exact tuple (qType, kvType, Gqa, ps, qSeqLen, prefill, causal, lse, cprr) in hsa/gfx950/mla/mla_asm.csv. This PR does not change that selection or any input check. The clamp only changes which page id an out-of-range lane loads, which the kernel already masks to weight 0, so in-range lanes see the same data and instruction order as before.

Changed op tests

None.

GwilliamHu and others added 2 commits October 30, 2026 06:55
Narrow 8081b4e to the kernels whose fixed SP3 source is committed in
poc_kl_merg mmd/fix/mla_kv_page0_nan and verified:
  MLA_A8W8_QH16_1TG_4W_16mx1_32nx4_PS.sp3 (e52636d)
    mla_a8w8_qh16_qseqlen1_gqaratio16{,_lse}_ps
  MLA_A16W16_QH32_1TG_4W_32mx4_32nx1_PS_gqaratio96.sp3 (fd1911a)
    mla_a16w16_qh32_qseqlen4_gqaratio96{,_lse}{,_msk0}{,_cprr}_ps

Each kept .co is instruction-identical to a rebuild from that source, and the
pre-fix .co is instruction-identical to a rebuild from the pre-fix source, so
the only change is the page-table clamp that stops OOB tail lanes from reading
KV slot 0. With NaN written into slot 0, the old .co files produce NaN output
and the kept ones stay bit-identical to clean runs.

Every other .co touched by 8081b4e goes back to its previous version, and
the files it added (including the unregistered qh32ctl A/B control) are removed.
@minmengdie
minmengdie requested review from a team and a balanced review from Copilot November 12, 2026 10:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request. Check if the Files changed in this pull request are included in default exclusions.

@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter standard tests on MI35X
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:mi300x Run Aiter standard tests on MI300X in PRs; main branch always runs them
ci:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs (added automatically when gfx942 configs change); main branch always runs both MI35X and MI300X
ci:triton-355 Run the full Triton test suite on MI35X, not only the tests the change affects
ci:windows Windows JIT op smoke test on the Radeon R9700 ROCm runner
ci:multi-gpu Aiter multi-GPU tests on the 8-GPU runner
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: DeepSeek-V4-Pro, MiniMax-M3-MXFP4
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 7872 --add-label <label>

One backend per PR:
A PR changes one kernel backend: [Triton/Gluon] (Triton and Gluon count as one), [HIP], [ASM], [CK], [OPUS] or [FlyDSL]. If the title ends up with two backend tags, split the PR -- as stacked pull requests when one part cannot merge without the other.

PR title tags & labels:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title and as PR labels automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf], op tags like [MLA], and human labels (ci:*) are left untouched. Add the no-auto-title label to stop the title rewrites; labels stay in sync either way.

Reviews:
A reviewer is usually assigned within one working day after the PR is ready for review (see Code Review Process). If nobody has responded for about a week, mention the area contact listed in CONTACTS.md. Want to help review? See REVIEWERS.md.

@github-actions github-actions Bot changed the title Fix MLA PS mode nan error for kv page0 has nan data and the LTD OOB read page0 data [ASM] Fix MLA PS mode nan error for kv page0 has nan data and the LTD OOB read page0 data Nov 12, 2026
@github-actions github-actions Bot added the ASM label Nov 12, 2026
@aiter-bot

aiter-bot commented Nov 12, 2026 •

Copy link
Copy Markdown

WAITING ON AUTHOR

PR Self-Review

Revision 6589f3790836 · mode shadow

Waiting for the PR author. The readiness report will appear after the self-review answers are complete for this revision.

Questions to answer in the PR description

  1. What behavior does this PR change, and why is the existing behavior insufficient?
  2. What did you validate, and what remains unverified? Include commands, hardware/configuration and results.
  3. Which architecture, dtype and shape boundaries select the changed kernel path, and what invariant prevents unsupported inputs from reaching it?
  4. For every changed op_tests/ file, what behavior does it cover and why is it not redundant? Write None if no op test changed.

Edit the PR Self-Review section in the PR description. Include the current revision SHA; this comment refreshes automatically.

Missing or invalid answers

  • FAIL — validation answer must explicitly state what remains unverified (or say none with a reason)

Shadow mode reports what would block but keeps the status successful. Set AITER_PR_SELF_REVIEW_MODE=enforce only after reviewing real false positives.

The 10 .co files changed on this branch were also rebuilt on main
(#7574 for the BF16 QH32 gqaratio96 kernels, #7622 for the FP8 QH16
qseqlen1 PS kernels). Take main's version of all of them; the LTD clamp
is re-applied on top of main in the next commit.
The last SUB_KV tile of a work item runs full width. Its out-of-range lanes
got page id 0 from the OOB buffer_load of kv_indices and read KV slot 0.
Their softmax weight is 0, but P*V still computes 0 * V, so a NaN in slot 0
(e.g. a reused or never-written block) turned whole output rows into NaN.

Rebuild from poc_kl_merg mmd/fix/mla_kv_page0_nan (d9381a8), which clamps
every page-table address, prefetches included, to the last valid entry of
the work item:

  mla_a16w16_qh32_qseqlen4_gqaratio96{,_lse}{,_msk0}{,_cprr}_ps
  mla_a16w16_qh32_qseqlen4_gqaratio32{,_lse}{,_msk0}{,_cprr}_ps
  mla_a16w16_qh64_qseqlen1_gqaratio64{,_cprr}_v3_ps, ..._lse_cprr_v3_ps
  mla_a8w8_qh32_qseqlen4_gqaratio32{,_lse}{,_cprr}_ps
  mla_a8w8_qh16_qseqlen4_gqaratio16{,_lse}{,_cprr}_v3_ps
  mla_a8w8_qh32_qseqlen4_gqaratio8{,_lse}_ps
  mla_a16w16_qh16_qseqlen4_gqaratio16{,_lse}_ps, mla_a8w8_qh16_qseqlen4_gqaratio16_ps

Each .co differs from main's only by the added clamp instructions (no
instruction removed or changed). With NaN written into an unreferenced
KV slot 0, main's .co files return NaN rows and these stay clean; clean
outputs match main bit for bit except for the FP8 QH16 qseqlen4 v3 kernels,
which are already nondeterministic run to run on main.

Not rebuilt: mla_a8w8_qh16_qseqlen1_gqaratio16{,_lse}_ps (the SP3 source
lacks the #7622 LDS fixes, which were patched into the .co directly) and
mla_a16w16_qh64_qseqlen1_gqaratio64_lse_v3_ps (its SP3 source has a
different LSE sanitize bound than the shipped .co).
Rebuild mla_a8w8_qh16_qseqlen1_gqaratio16{,_lse}_ps from poc_kl_merg
mmd/fix/mla_kv_page0_nan (d06974a), which now carries the #7622 LDS race
fixes in the SP3 source as well as the KV slot 0 page-table clamp.

Both .co files are main's (#7622) plus only the clamp instructions. With NaN
written into an unreferenced KV slot 0 main returns NaN rows and these stay
clean; clean outputs match main bit for bit, and #7622's multi-tile race test
passes (the pre-#7622 .co fails it on the same machine).
Copilot AI balanced review requested due to automatic review settings November 13, 2026 06:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request. Check if the Files changed in this pull request are included in default exclusions.

Copilot AI balanced review requested due to automatic review settings November 13, 2026 08:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request. Check if the Files changed in this pull request are included in default exclusions.

@shengnxu
shengnxu merged commit 95d2112 into main Nov 15, 2026
@shengnxu
shengnxu deleted the mmd/dev/ltd_nan branch November 15, 2026 03:19
AndreasKaratzas added a commit that referenced this pull request Nov 15, 2026
#7872 rebuilt four of the FP8 QH16 qseqlen4 v3_ps kernels (v3_ps,
lse_v3_ps, cprr_v3_ps, lse_cprr_v3_ps) with the KV page-table clamp.
Resolve each by taking main's binary and re-applying this branch's
rotation (the a[120:127] MFMA moved ahead of the six ds_read_b128 that
overwrite a[104:127], 4 windows of 76 bytes per file). main vs merged
differs only by those rotations; file size, ELF headers and branch
targets are unchanged. The msk0 variants were not touched by main and
keep this branch's versions.

op_tests/test_mla_persistent.py: run both the qlen 1 (#7622) and qlen 4
multi-tile batch checks.

Co-Authored-By: Claude <[email protected]>
Signed-off-by: Andreas Karatzas <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants