Repository navigation
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
WAITING ON AUTHORPR Self-ReviewRevision 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
Edit the Missing or invalid answers
Shadow mode reports what would block but keeps the status successful. Set |
There was a problem hiding this comment.
🟡 Changes recommended
Padded B and scale loads can contaminate otherwise finite outputs with neighboring NaNs, and the ragged-K regressions do not fail on numerical mismatches.
2 open issues
What changed in this PR
Extends the gfx950 FlyDSL MXFP8 GEMM to support K values divisible by 32, targeting DeepSeek-V4.1’s TP8 shared-expert projection with K=288 from issue #7967.
Changes:
- Generalizes partial-step masking and adds a BF16 batched-GEMM fallback.
- Expands ragged-K regression cases and fused-quantization checks.
- Adds 77 tuned configurations for N=5120, K=288.
| File | Description |
|---|---|
op_tests/test_gemm_a8w8_mxfp8_bpreshuffle.py |
Adds K=288 public-entry regression shapes. |
op_tests/test_flydsl_batched_gemm.py |
Expands ragged-K kernel and fused-quantization coverage. |
aiter/ops/gemm_op_a8w8.py |
Adds the BF16 batched-GEMM heuristic fallback. |
aiter/ops/flydsl/kernels/bmm_a8w8_mxscale_gfx950.py |
Accepts 32-wide K granularity and generalizes A-tail masking. |
aiter/configs/model_configs/dsv41_a8w8_blockscale_mxscale_bpreshuffle_tuned_gemm.csv |
Adds tuned K=288 configurations across M sizes. |
Review effort: Balanced
| if const_expr(k_tail and last): | ||
| masks = tuple( | ||
| _tail_mask(start, final) for start in (0, MFMA_K // 2) | ||
| ) |
| shapes = args.mnk or tuned_shapes() | ||
| if args.mnk is None and get_gfx() == "gfx950": | ||
| shapes = shapes + RAGGED_K_MNK_GFX950 | ||
| df = pd.DataFrame([test_gemm(*mnk) for mnk in shapes]) |
There was a problem hiding this comment.
🔵 Needs a closer look
Tail masking leaves B fragments and scale operands unsanitized, allowing neighboring NaNs to contaminate finite outputs, while the added regression cases do not assert numerical correctness.
2 open issues
Review effort: Balanced
valarLip
left a comment
There was a problem hiding this comment.
⚠️ Action required before merge (5)
Thanks, the tail mask itself checks out: for every K that 32 divides, _tail_mask keeps exactly the 16-K lane chunks inside K, and for K % 128 in {0, 64} it emits the same masks as half_step did, so existing shapes compile to the same kernel. The last K tile is always a static tail step, and the new 32x32 ragged-K cases ran and passed in CI (MI35X shard 1).
- Keep a neighbour token's A scale out of the partial step, or answer the Copilot thread at
:942.bmm_a8w8_mxscale_gfx950.py:931-1000masks only A's codes in the last step:- The lane groups whose 32-K group lies past K still feed the next row's (or next batch's) x_scale bytes to the MFMA. For K = 288 that is groups 1-3; for K % 128 == 64 it was already groups 2-3.
- If that token's scale is E8M0 0xFF (an inf/NaN activation), the zero codes meet a NaN scale. One bad token then turns another request's row into NaN. Issue #7967 asked for this case.
- Suggested fix: in the final split's partial step, select 127 (1.0) for
sain those lane groups. It is static and runs only in the tail. - Say in the comment at
:931-935that B and w_scale past K are real weight bytes or zeros past the buffer. - Add a case that sets the next row's x_scale to 0xFF and checks that the row before it stays finite.
- Make the new ragged-K checks fail on a mismatch.
op_tests/test_gemm_a8w8_mxfp8_bpreshuffle.py:145-148only logs thecheckAllcloseratio, and the new fallback atgemm_op_a8w8.py:3076is tested only there. This is the second Copilot thread.- The gfx950 1x32 ragged-K shapes in
test_batched_gemm((33,1024,544),(4096,512,576)) are also only logged bysummarize. - Assert on both.
- Fold the new branch and fix the text it makes stale.
gemm_op_a8w8.py:3074-3080can be the single lineis_bmm = kernel_name is None or kernel_name.startswith(f"{_BMM_MFMA_NAME_PREFIX}_"). It behaves the same: a non-bf16 output still goes to mxpsh withNone.- Stale text:
:2968-2971says "an untuned gfx950 shape runs the mxpsh heuristic tile".:3049-3050says the bmm runs only "where a tuned row (kernelId "bmm") picked it".- The warning at
:2998-3002logs "falling back to flydsl kernel 'None'" for K = 288 (seen in the CI log). bmm_a8w8_mxscale_gfx950.py:265still says "half step".test_flydsl_batched_gemm.py:746says "(32x32 scale only)", but gfx950 now runs 1x32 too.
- Give the perf table a baseline that exists today. "heuristic → tuned" compares the CSV rows against this PR's own bmm heuristic. Main cannot run K = 288 at all. ATOM runs it today through ROCm/ATOM#3361, padded to K = 320 with two pad launches. Please compare tuned K = 288 against that path, pad launches included, for a few M (1, 64, 512, 2048, 8192).
- Write a PR description and squash text.
- Description: the problem (#7967: V4.1 TP8 shared-expert down projection,
check_bmm_configrejects K % 64 == 32), the fix (thek_tailmask, the untuned-entry fallback, 76 tuned cu256 32x32 rows), the tests and their CI lane, and the baseline. - Title: "mm_a8w8" should be "bmm_a8w8".
- Squash: one message instead of "retune N=5120 K=288 bmm rows" plus a merge commit, without the
[email protected](sic) co-author line.
- Description: the problem (#7967: V4.1 TP8 shared-expert down projection,
Reviewed at f640c21 (Deep, first review: hunter A + independent pass B, CPU only, CI logs checked). Open review threads: 2 (Copilot, items 1-2).
#8978) * K3 TP1 a8w8 GEMM: compute N tail, underfilled tiles, aligned A-scale loads, retuned rows (#8778 @ ea7a5d8) #8778 (aoli26; base main; open) applied to k3-455-dev as its net change on its 19 files at head ea7a5d8 (2026-11-26T14:47:07Z), 3-way against the PR's main base adbb6ac. The 8 files k3-455-dev had changed (all only by #8246 @ 15808c7) take the PR's version, so all 19 files equal the PR head. It carries the newer #8246 (ccc4270), the table PRs #8579 / #8586 / #8601 and main's #8566 (its compute guard, which #8778 replaces); no other main change rides in. Validated in the K3 1P1D integration branch (aiter zejun/k3-455-dev 627e1eb) on 16 MI455X (wuhuikx/LLM-Booster#578). The PR head has moved on since (204ce9d: merges of #8246 @ 0d6cf15 and of main, which brings #8737); those can follow when #8778 lands. Co-authored-by: zejunchen-zejun <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * Update K3 FP8 kernels to c997 and add exact-M tuning Preserve the existing dev wrappers and bucket tables. Add 162 accepted retuned exact configurations and 3 c997-default compatibility records, with CPU dispatch coverage for all 675 measured points. Backport the three kernel files from c99781c without merging main history. Integrated-head GPU validation remains outstanding. --------- Co-authored-by: aoli26 <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Zhang <[email protected]> (cherry picked from commit 1cc9d02) Rebase onto main 12-03: the 19 files keep this commit's content; only main's later changes are added: the AOT launcher factories of #8678 (mxfp8 / batched wrappers launch gemm_a8w8_launcher.lazy(), _gemm_a8w8_compute_bound_launcher.lazy(), splitk_reduce_launcher.lazy(); _lazy_import keeps _data_ptr), #7449's deferred split-K entry points and #8636's ragged-K fallback. gemm_a8w8_gfx1250.py: this commit's rank0 split-K epilogue and flush_addr (it already carries #8737's flush). gemm_op_a8w8.py: main's #8566 guard in get_mxscale_bpreshuffle_config (no padded row below a compute kernel's M tile) is removed, as on the #8778 head, because the c997 compute kernel serves underfilled tiles; test_gemm_host_dispatch_cache.py takes #8778's test_mxscale_compute_row_serves_underfilled_m_tile in place of main's two guard tests. kimik3 mxscale tuned CSV: this commit's rows (626 changed or added) replayed by key; the result equals this commit's table. Rebase onto main 12-03: main #7449 moved the bpreshuffle row lookup into _bpreshuffle_config(XQ, WQ); this commit's Kimi-K3 exact-row lookup there needs x_scale, w_scale and Y, so _bpreshuffle_config takes them (the deferred split-K path passes a meta tensor of the output's shape and dtype, so it picks the same row as gemm_a8w8_bpreshuffle). Rebase onto main 12-03: op_tests/test_gemm_a8w8_mxfp8_bpreshuffle.py counts reduce launches through splitk_reduce_launcher.lazy (main #8678 replaced _compile_splitk_reduce).

perf :