Skip to content

[FlyDSL] [JIT] jagged_dense_bmm_broadcast_add (MI300X, MI355X) - #4136

Open
anhminhnguyenhoang wants to merge 56 commits into
mainfrom
flydsl-jdbba
Open

anhminhnguyenhoang wants to merge 56 commits into
mainfrom
flydsl-jdbba

Conversation

@anhminhnguyenhoang

@anhminhnguyenhoang anhminhnguyenhoang commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

jagged_dense_bmm_broadcast_add is a grouped GEMM for recommendation-style workloads with variable per-group lengths. For each group b, over its packed rows [s, e):

Out[s:e, :] = Jagged[s:e, :] @ Dense[b] + Bias[b][None, :]

Row boundaries come from a device-resident seq_offsets prefix sum. The host does not know group sizes at launch, so the group-to-row mapping is resolved on the GPU.

Summary

  • gfx942 (MI300X): 1.40x to 1.85x faster than the Triton baseline on the 10 benchmark rows. Geomean 1.56x (median of 10 rounds).
  • gfx950 (MI355X): 1.19x to 1.52x faster than the Triton baseline on the same 10 rows. Geomean 1.32x (median of 7 rounds).
  • Dense weights are (n_groups, K, N), read directly with no transpose. Any other rank raises ValueError.

Technical Details

Kernel

  • Output tile 128x128. Default block_k 64. 256 threads: 4 waves, split 1x4 along N.
  • A is staged through LDS, two stages, with Swizzle(3,3,3).
  • Dense B is loaded into registers ahead of use and reordered in registers for the MFMA layout.
  • The accumulator starts at the bias (FP32). The output is rounded to BF16 with round-to-nearest-even in integer form. A NaN input must have zero low 16 bits; any other NaN can round to Inf.

Arch traits

All arch differences live in one ARCH_TRAITS record per arch. The kernel reads the record and has no arch branches.

Trait gfx942 gfx950 Effect on gfx950
MFMA 16x16x16 bf16 16x16x32 bf16 Half the MFMA instructions, same accumulators
A global to LDS through VGPRs async LDS DMA No A ds_write; frees VGPRs
Dense B prefetch stages 3 2 Frees VGPRs
LDS 64 KB 160 KB

The freed VGPRs give gfx950 3 to 4 waves per SIMD, against 2 before.

Dispatch

Config order: explicit override, then the tuned CSV row for (gfx, cu_num, K, N, tiles_log2), then the analytic default. gfx is the live GPU arch, so a GPU_ARCHS build setting does not pick another arch's row. block_k is validated before compile.

The skew path now also reads skew_xcd_c and skew_xcd_w from the row. An empty cell keeps the previous fallback, so the gfx942 rows select the same config as before.

Launch modes

Mode When Idea
Uniform Every group has the same length Dense (group, M-tile, N-tile) grid
Compact (skew) Variable lengths Grid skips empty tiles; the group is found on the device

Test Plan

The op test runs these checks on gfx942 and gfx950:

  1. Headline shapes: correctness against the torch reference (err = 0) and timing against Triton.
  2. Skew regime: empty groups, partial tiles, max_seq_len much larger than the mean.
  3. block_k values (test_jdbba_block_k). An invalid block_k, xcd_c, or xcd_w must raise ValueError and leave C untouched (test_jdbba_config_invalid).
  4. Reuse with new seq_offsets, an in-place offsets update, and a side stream (test_jdbba_seq_offsets_reuse).
  5. Config selection: the live GPU arch picks the tuned row, and an explicit override wins (test_jdbba_config_selection).
  6. Launcher reuse: a new length or batch does not compile a new launcher (test_jdbba_launcher_reuse).
  7. Tuning collision guard (op_tests/tuning_tests/test_config_shape_collision.py).
  8. Input limits: a grid past the device limits, an Int32 or 32-bit buffer overflow, N = 0, a 2-D B, a stream on another device, and an output that overlaps an input must raise ValueError with C untouched. K = 0 gives C = bias.
  9. Devices and strides: two devices in one process, and size-1 dims with any stride (test_jdbba_two_devices, test_jdbba_size1_dim_strides).
  10. Bounds on the device: no row past C.shape[0] is written, and a group whose A or C spans more than 4 GiB is correct (test_jdbba_rows_past_c, test_jdbba_wide_group).

Commands (replace <gpu>, <aiter> and <generative-recommenders>):

HIP_VISIBLE_DEVICES=<gpu> PYTORCH_ALLOC_CONF=expandable_segments:True \
PYTHONPATH=<aiter>:<generative-recommenders>:$PYTHONPATH \
    python op_tests/test_jagged_dense_bmm.py

python3 -m unittest op_tests.tuning_tests.test_config_shape_collision

Test Result

gfx950 (MI355X)

ROCm 7.2.4, torch 2.10.0, Python 3.12, FlyDSL 0.5.0, Triton 3.6.0, at 3db6de7. Each of 10 rounds is one process. In it, the FlyDSL kernel and Triton run in rotated order on one GPU after 3 untimed calls, and run_perftest times 101 iterations. Each time is the median of the 10 rounds. Dense input is (n_groups, K, N).

  • At 3db6de7 with FlyDSL 0.5.0, the op test gives err = 0 in all 53 error cells. The two-device, config-selection, launcher-reuse, and invalid-config checks pass, and the collision test passes (33 tests). A kernel trace shows jdbba_kernel_0 dispatched. The gfx950 ISA matches the AOT build of the same tree for the four benchmark kernel types.
  • The earlier table used CUDA events, 7 rounds in one process, and FlyDSL 0.4.1. With the method above, both kernels read 4.7% slower (geomean), and the Triton / FlyDSL geomean stays at 1.32x.
  • B64 D512 N1024 uniform reaches 762 TFLOPS, 30% of the 2.5 PFLOPS bf16 peak. B1024 D512 uniform moves 3.00 TB/s, 37% of the 8 TB/s HBM peak, counting A, dense B, bias, and output once. The kernel is at neither roof.
B D Kout Mi Regime FlyDSL (us) Triton (us) Triton / FlyDSL
120 256 256 7680 uniform 220 282 1.28x
120 256 256 7680 skew 33 54 1.62x
120 512 512 7680 uniform 678 804 1.19x
120 512 512 7680 skew 129 170 1.31x
1024 256 256 7680 uniform 1737 2189 1.26x
1024 256 256 7680 skew 306 428 1.40x
1024 512 512 7680 uniform 5555 6600 1.19x
1024 512 512 7680 skew 914 1189 1.30x
64 512 1024 8192 uniform 721 944 1.31x
64 512 1024 8192 skew 152 207 1.36x

Gain of each gfx950 trait, measured by removing it from the final kernel (geomean of the 10 rows):

Removed Slower by
16x16x32 MFMA 13.6%
A via LDS DMA 9.5%
2 B prefetch stages 2.3%

gfx942 (MI300X)

10 rounds, one process per round. ROCm 7.2.4, torch 2.10.0, Python 3.12, FlyDSL 0.4.0. With FlyDSL 0.4.2, and with FlyDSL 0.5.0 at 910fa44, the four benchmark kernel types compile to the same gfx942 ISA, so the timing holds. At 230b7e1 the per-tile A and C bound changes the ISA. An A/B against 99b839b, which has the measured ISA, gives a time ratio geomean of 0.989 over the 10 shapes (per shape 0.914 to 1.013, 10 rounds each, with overlapping ranges).

  • The op test gives err = 0 in all 300 error cells (30 per round). The collision test passes (31 tests) in every round.
  • Invalid block_k values (0, 24, 96) raise ValueError and leave C untouched. A 2-D B raises ValueError.

Each process times FlyDSL and Triton per row with run_perftest (101 iterations after 2 warm-up calls). Each cell is the median of the 10 rounds. Dense input is (n_groups, K, N). FlyDSL is 1.40x to 1.85x faster than Triton, geomean 1.56x. The uniform rows reach 264 to 363 TFLOPS, 20% to 28% of the 1307 TFLOPS bf16 dense peak.

B D Kout Mi Regime FlyDSL (us) Triton (us) Triton / FlyDSL Range of ratio
120 256 256 7680 uniform 457 672 1.47x 1.46 to 1.48
120 512 512 7680 uniform 1427 1999 1.40x 1.40 to 1.41
1024 256 256 7680 uniform 3907 5772 1.48x 1.47 to 1.48
1024 512 512 7680 uniform 12138 17501 1.44x 1.43 to 1.45
64 512 1024 8192 uniform 1515 2289 1.51x 1.50 to 1.52
120 256 256 7680 skew 75 139 1.85x 1.78 to 1.91
120 512 512 7680 skew 260 406 1.56x 1.54 to 1.60
1024 256 256 7680 skew 642 1100 1.72x 1.71 to 1.72
1024 512 512 7680 skew 1989 3321 1.67x 1.67 to 1.68
64 512 1024 8192 skew 312 490 1.57x 1.53 to 1.61

Tuned configs

The tuned configs live in aiter/configs/jagged_dense_bmm_tuned.csv, read through AITER_CONFIG_JAGGED_DENSE_BMM. Only jagged_dense_bmm_dispatched reads it. The key is (gfx, cu_num, K, N, tiles_log2), where tiles_log2 = floor(log2(n_groups * ceil(max_seq_len / 128) * (N // 128))). There are five gfx942 rows (304 CUs) and five gfx950 rows (256 CUs), one per headline shape.

The uniform path reads xcd_c, xcd_w and block_k from the row. The kernel always runs 256 threads. The skew path reads block_k, skew_xcd_c and skew_xcd_w. Shapes with no matching row take the analytic default.

PR Self-Review

Reviewed revision

070a0f8

Behavior and intent

This PR adds gfx950 (MI355X) support to the jagged_dense_bmm kernel, with five gfx950 tuned rows. The gfx942 settings do not use the gfx950 16x16x32 MFMA, the 160 KB LDS, or async LDS DMA. The arch-traits record lets gfx950 use them. The last commit removes the 2-D dense layout (n_groups * N, K). The 3-D layout is faster, and callers no longer need a host transpose. The review-round commits make every input the kernel cannot run raise ValueError before launch, with C untouched. They also compile one launcher per device, and bound each A and C buffer to one tile and to C.shape[0] rows, so no row past C is read or written.

Validation and unverified scope

  • gfx942 (MI300X), c31627f: op test gives err = 0 in all 300 error cells over 10 rounds. Collision test passes (31 tests) in every round. Commands as in Test Plan. With the K-divide check removed from the kernel, the invalid-block_k check fails, so it catches a real break.
  • gfx942, f39e3b0 (no GPU): with FlyDSL 0.4.2, the four benchmark kernel types compile to the same ISA as at c31627f with FlyDSL 0.4.0. The tuned-row lookup picks the same configs as at c31627f.
  • gfx942 (MI300X) and gfx950 (MI355X), f25fb82 with FlyDSL 0.4.2: on each machine, all 34 op-test error cells are 0, the config-selection, launcher-reuse, and invalid-block_k tests pass, and all 32 collision tests pass. On MI300X, a kernel trace shows jdbba_kernel_0 dispatched, so the FlyDSL kernel ran, and the ISA built there matches the AOT build for the four benchmark kernel types. Timing in Test Result, measured at c31627f on the same ISA.
  • f39e3b0 is the same jdbba change rebased onto newer main. The jdbba files and the FlyDSL pin match f25fb82, and the four benchmark kernel types compile to the same gfx942 and gfx950 ISA (no GPU).
  • 910fa44 is the same jdbba change rebased onto newer main, which requires FlyDSL 0.5.0 or later ([FlyDSL] [CI] [Build] Bump FlyDSL pin to v0.5.0 #7600). With FlyDSL 0.4.2, import aiter fails at this revision.
  • gfx942 (MI300X) and gfx950 (MI355X), 910fa44 with FlyDSL 0.5.0: on each machine, all 34 op-test error cells are 0, the three new checks pass, and all 33 collision tests pass. The four benchmark kernel types compile to the same gfx942 and gfx950 ISA as with FlyDSL 0.4.2 (no GPU).
  • gfx942 (MI300X), 3db6de7 with FlyDSL 0.5.0: all 53 op-test checks pass, and all 33 collision tests pass. Each new test fails or faults the GPU on its commit's parent. The A/B time ratio against 99b839b is above.
  • gfx950 (MI355X), 3db6de7 with FlyDSL 0.5.0: all 53 op-test checks pass, including the rows-past-C and over-4-GiB cases, and all 33 collision tests pass. The ISA matches the AOT build. Triton / FlyDSL is 1.19x to 1.62x per row, geomean 1.32x over 10 rounds.
  • 070a0f8 merges newer main into 8a4c460, which moves the FlyDSL pin to 0.5.3. With FlyDSL 0.5.0, the four benchmark kernel types compile to the same gfx942 and gfx950 ISA as at 3db6de7. With FlyDSL 0.5.3, the gfx950 ISA is unchanged, and the gfx942 ISA differs by one or two lines per kernel type (no GPU).
  • Unverified: speed on gfx950 shapes outside the 10 benchmark rows, which take the analytic default, is not measured. The per-tile bound has no same-method A/B on gfx950, so its own cost there is not separated from the timing-method change. On gfx942 that A/B gives 0.989. No GPU run at 070a0f8, and no gfx942 run with FlyDSL 0.5.3.

PR-specific question

The tuned rows match on (gfx, cu_num, K, N, tiles_log2). The five new rows have gfx950 and cu_num 256. Only gfx950 shapes with the same K, N, and tiles_log2 match them. A gfx942 shape never reads a gfx950 row, because gfx and cu_num are in the key. The CSV is new in this PR, so no shape on main had a previous selection. Evidence: the CSV keys, and the gfx942 op test at 99b839b. gfx950 shapes with no matching row take the analytic gfx950 default.

Changed op tests

  • op_tests/test_jagged_dense_bmm.py (new in this PR): headline shapes against the torch reference and Triton, a skew regime with empty groups and partial tiles, block_k values, and reuse with new seq_offsets, an in-place update, and a side stream. The reuse checks are the only checks in op_tests for in-place offsets and new lengths. The review found a wrong result after an in-place offsets update. The reuse test covers that path. The invalid-block_k check covers the guard that stops a block_k that does not divide K from dropping the K tail.
  • test_jdbba_config_selection (new): the live GPU arch, not GPU_ARCHS, picks the tuned row. It fails on the previous lookup, which read GPU_ARCHS. test_jdbba_launcher_reuse (new): a new length or batch must not compile a new launcher, which cost about 27 ms per call before the review fix. No other test checks either behavior.
  • Review-round tests (new): rows past C.shape[0], groups over 4 GiB, two devices, size-1 dim strides, copy tiling and XCD bounds for overrides and tuned rows, grid and buffer limits, N = 0 and K = 0, a stream on another device, output overlap, a tuned CSV cell that is not an integer, and the skew fallback. Every correctness check now fails on any mismatch. No other test in op_tests covers these inputs.
  • op_tests/tuning_tests/test_config_shape_collision.py (+1 line): adds AITER_CONFIG_JAGGED_DENSE_BMM to the collision guard. Without this line, duplicate keys in jagged_dense_bmm_tuned.csv would not fail the guard. No other family covers this CSV, so the line is not redundant.

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

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

Extended tests (opt-in via labels):

Label Tests
ci:triton-300x Run an additional Triton test job on MI300X in PRs; main branch always runs both MI35X and MI300X
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: GPT-OSS-120B, DeepSeek-R1-0528, Kimi-K2.5
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 4136 --add-label <label>

@anhminhnguyenhoang anhminhnguyenhoang self-assigned this Jul 8, 2026
@anhminhnguyenhoang
anhminhnguyenhoang marked this pull request as ready for review July 8, 2026 10:49
@anhminhnguyenhoang
anhminhnguyenhoang requested a review from a team July 8, 2026 10:49
fhuizing added a commit to fhuizing/aiter that referenced this pull request Jul 13, 2026
Address PR review feedback (ROCm#4136): ChunkK was hardcoded to
_BLOCK_KV in the public flydsl_fp8_paged_mqa_logits call despite
compile_fp8_paged_mqa_logits already accepting block_kv. Now ChunkK is
forwarded, defaulting to _BLOCK_KV (128) and validated to be a multiple
of MFMA_N before dispatch.
Comment thread op_tests/test_jagged_dense_bmm.py Resolved
Comment thread op_tests/test_jagged_dense_bmm.py Resolved
@anhminhnguyenhoang
anhminhnguyenhoang marked this pull request as draft August 27, 2026 10:46
anhminhnguyenhoang added a commit that referenced this pull request Sep 1, 2026
Use the AITER MIT (C) 2026 header on the five new Python files, and
remove test_jdbba_compile_reraise plus the block_k=32/256 ValueError
assertions that the reviewer flagged as unnecessary.

Co-authored-by: Cursor <[email protected]>
anhminhnguyenhoang added a commit that referenced this pull request Sep 1, 2026
Use the AITER MIT (C) 2026 header on the five new Python files, and
remove test_jdbba_compile_reraise plus the block_k=32/256 ValueError
assertions that the reviewer flagged as unnecessary.

Co-authored-by: Cursor <[email protected]>
@anhminhnguyenhoang
anhminhnguyenhoang marked this pull request as ready for review September 1, 2026 18:27
@github-actions github-actions Bot added the FlyDSL label Sep 1, 2026
SamiAario-AMD pushed a commit that referenced this pull request Sep 3, 2026
Use the AITER MIT (C) 2026 header on the five new Python files, and
remove test_jdbba_compile_reraise plus the block_k=32/256 ValueError
assertions that the reviewer flagged as unnecessary.

Co-authored-by: Cursor <[email protected]>
anhminhnguyenhoang added a commit that referenced this pull request Sep 29, 2026
Use the AITER MIT (C) 2026 header on the five new Python files, and
remove test_jdbba_compile_reraise plus the block_k=32/256 ValueError
assertions that the reviewer flagged as unnecessary.

Co-authored-by: Cursor <[email protected]>
amd-yashagar added a commit that referenced this pull request Sep 30, 2026
* initial kernel and tests

* fix bench to not use random avg context length

* simplify fp8_paged_mqa_logits: operator style for i32 arithmetic, flatten variant scaffolding

* perf: upgrade paged MQA logits to mfma_scale_f32_32x32x64 (K_STEPS 8→2, 6-13% faster)

* review: un-hardcode ChunkK / block_kv in paged mqa logits host

Address PR review feedback (#4136): ChunkK was hardcoded to
_BLOCK_KV in the public flydsl_fp8_paged_mqa_logits call despite
compile_fp8_paged_mqa_logits already accepting block_kv. Now ChunkK is
forwarded, defaulting to _BLOCK_KV (128) and validated to be a multiple
of MFMA_N before dispatch.

* style: apply ruff + black to flydsl mqa-logits files

* feat(flydsl): paged mqa-logits KVBlockSize>=1 + correctness-only test

Kernel: extend fp8_paged_mqa_logits from KVBlockSize==1 to KVBlockSize>=1
(block-flat co-packed layout: KVB fp8 key rows grouped first, then KVB f32
scales). Per-lane gather resolves each logical KV column independently
through the block table (kv_indices[b, col // KVB] -> block, col % KVB ->
token), so KVB is a compile-time constant that folds to the per-token slot
layout at KVB==1. i32 gather-offset ceiling now accounts for KVB*index_dim.

Test: add --kv-block-size sweep axis (1, 64) and reference block-flat
dequant; convert to a pure correctness test -- drop run_perftest / the
fn() wrapper for a direct kernel call, and remove the timing-derived
us/TFLOPS output columns (gate stays exact -inf mask + calc_diff < 1e-3).

Verified on gfx950 from a fresh compile cache across KVB {1,64}, dtypes
{fnuz,fn}, SplitKV {auto,1,4}, heads/head_dim {64,128}, short/long context.

* feat(flydsl): add Preshuffle support to paged fp8 mqa-logits + isolation bench

Support the production shuffle_weight(16x16) KV data layout in the FlyDSL paged
fp8 MQA-logits kernel (Preshuffle=True, KVBlockSize % 16 == 0), making it a true
drop-in for deepgemm_fp8_paged_mqa_logits(Preshuffle=True). Only the intra-block
key-byte offset changes; the block-table gather, co-packed/token-ordered scale
gather, MFMA, and causal mask are unchanged.

- _mqa_logits_common: add load_pack_v8i32_preshuffle (closed-form offset into
  the shuffle_weight(16x16) data section; 8-byte halves stay contiguous).
- fp8_paged_mqa_logits: thread a compile-time preshuffle flag through the kernel
  builder (with a _ps name tag), compile_* cache key, and the public API; replace
  the NotImplementedError guard with the KVBlockSize % 16 == 0 assert.
- test: add a preshuffle path (oracle from the unshuffled cache, kernel fed the
  shuffled copy) and a small dedicated case set (kvb 16/64, D 64/128, FN patch).
- bench_flydsl_vs_gluon: note the A/B is fixed at KVBlockSize=1 (Gluon faults at
  KVBlockSize>1); KVBlockSize>1 / Preshuffle coverage lives in the flydsl test.
- add bench_flydsl_paged_mqa_logits.py: standalone single-config bench (no Gluon)
  for rocprofv3 isolation profiling, covering both block-flat and preshuffle paths.

Validated on gfx950: block-flat and preshuffle correctness pass the unchanged
gate (exact -inf mask + calc_diff < 1e-3); rocprofv3 traces the _ps kernel.

* refactor(flydsl): move paged mqa-logits kernel into mqa_logits subpackage

Upstream relocated the mqa-logits kernels into
aiter/ops/flydsl/kernels/mqa_logits/. Move the paged FP8 kernel and its
shared helper module there too for consistency:

  kernels/fp8_paged_mqa_logits.py -> kernels/mqa_logits/fp8_paged_mqa_logits.py
  kernels/_mqa_logits_common.py   -> kernels/mqa_logits/_mqa_logits_common.py

Fix the sibling .tensor_shim imports to ..tensor_shim (now one level up)
and update the public __init__ import path. No behavior change; public API
(flydsl_fp8_paged_mqa_logits) is unchanged.

* fix(flydsl): size paged mqa-logits bench KV pool from real block demand

Both paged benchmarks sized the block pool from max_model_len and then
handed blocks out with `pool[counter % num_blocks]`, so the block table
wrapped and every sequence reused the same physical blocks. At B=16,
kv_len=32768 that is a 1024-block pool serving 8192 block references: an
8.65 MB KV working set standing in for 69 MB, small enough to live in
cache. Every number measured against it was therefore a cache benchmark.

That flattered the kernel by ~13% on its own, and distorted the
head-to-head against production Gluon unevenly -- given the honest
footprint FlyDSL loses 31-51% while the reference loses only 1-4%, since
the reference is slow enough that memory is not its constraint. The
reported speedup falls from 1.3-4.2x to 1.7-3.1x.

Size the pool from the blocks the batch actually needs, build the block
table vectorized rather than one element per GPU write, and report the
touched footprint alongside the requested bytes. --pool-blocks shrinks
the pool deliberately for cache-residency studies, and the vs-gluon
bench now fails with a clear message when a shape would exceed the
kernel's 2^31 i32 gather-offset limit instead of tripping an assert
inside the launch path.

Co-authored-by: Cursor <[email protected]>

* perf(flydsl): retune paged mqa-logits launch geometry (9.3% across shapes)

SplitKV was auto-computed with the production Triton host formula, which
ignores how many waves a CTA contains and so drifts with shape: it lands
2.5 waves per SIMD at B=16 but 10 at B=128. Resident wave count is the
lever that matters here -- this kernel is bound by memory throughput
rather than per-wave latency, so too few waves leaves the memory system
idle and too many just queue. Measured across six shapes (batch 4..128,
kv_len 4k..128k) the curve is flat between 2.0 and 2.5 waves/SIMD and
rises steeply either side: 1.0/SIMD costs 33.9us and 4.0/SIMD 29.4us
against 27.6us at the optimum.

Target WavePerEU waves per SIMD directly, accounting for the CTA's wave
count, and default to paged_w1. At equal resident wave count, splitting a
CTA across 2 or 4 waves is slower on every shape measured: a 1-wave CTA
schedules more freely, and the waves have no work to share anyway since
each owns a disjoint set of KV columns with no barrier or LDS between
them.

Worth 4.6-14.4% per shape, 9.3% aggregate, and it removes the shape
sensitivity -- all six shapes now land within 1% of 27.7us for the same
total KV work, where the old defaults spread them over 29.2-32.5us.
Verified against the full 870-case correctness sweep (max error 5.3e-4,
tolerance 1e-3); the block-flat KVBlockSize=1 path is unchanged.

Two public-surface notes for reviewers. This deliberately diverges from
the deepgemm_fp8_paged_mqa_logits host formula it previously mirrored.
And WavePerEU changes meaning, from a multiplier in the old formula to
the target waves per SIMD; its default of 2 is where the curve bottoms
out. FP8_PAGED_MQA_LOGITS_DEFAULT_VARIANT changes paged_w4 -> paged_w1.

Co-authored-by: Cursor <[email protected]>

* refactor(flydsl): use FlyDSL operator sugar in paged mqa-logits

The kernel was written against raw MLIR builders -- 58 _to_raw() calls and
65 arith.* calls -- for arithmetic FlyDSL already overloads. The worst case
was the store predicate, 17 lines of nested arith.andi/arith.cmpi to say
`(lane_div_N == 0) & (col <= q_limit)`.

Route unsigned division and modulo through new udiv/umod helpers rather
than the bare `//` and `%` operators: fx.Int32 is signed, so `//` lowers to
floordivsi, which expands to several instructions to get negative-operand
rounding right. Every quantity divided here is non-negative, so going via
fx.Uint32 keeps the single-instruction divui/remui the hand-written calls
emitted.

Verified codegen-neutral: the ATT-decoded ISA is byte-identical to the
previous commit, 655 instructions in the same order. 870/870 correctness
cases pass at 5.3e-4, timing is unchanged at 28.0us, and ruff reports the
same findings as before.

Co-authored-by: Cursor <[email protected]>

* refactor(flydsl): drop dead helpers and tighten mqa-logits docs

_mqa_logits_common carried three helpers nothing referenced: fn_to_fnuz_i64
(45 lines -- the dense kernel defines its own local copy), load_pack_i64
(likewise), and i32_add. Removing them is the bulk of the shrink.

Comments and docstrings were 30% of the two files, much of it restating the
code or duplicating the PR description. Trimmed to what a reader cannot
derive: the co-pack layout contract, the ReLU scale-hoist identity, the i32
gather ceiling, the D-reg-to-head mapping, and the warning that a Python
`if` on KVB would become a runtime scf.if and drop branch-local addresses.

932 -> 770 lines across the two files. ISA byte-identical to the previous
commit (655 instructions), 870/870 correctness at 5.3e-4, 27.8us unchanged,
no new ruff findings.

Co-authored-by: Cursor <[email protected]>

* refactor(flydsl): drive the paged mqa-logits tile loop with scf.for_

Replaces the hand-built scf.ForOp plus `with ir.InsertionPoint(body)` and
trailing scf.YieldOp with the scf.for_ generator, which owns the insertion
point and terminator. Same pattern the fmha_gfx1250 kernel already uses.

Only two lines, but it removes the last raw MLIR region plumbing from the
kernel's main loop. The masked store keeps scf.IfOp: FlyDSL exposes no `if_`
helper, and switching to a predicated store would change codegen.

ISA byte-identical (655 instructions), 870/870 correctness at 5.3e-4,
27.7us.

Also investigated expressing the preshuffle as a FlyDSL layout, as
examples/04-preshuffle_gemm.py does in two lines. Not adopted: that example
indexes a whole contiguous tensor, whereas our access is a paged gather off
a per-lane runtime base. GTensor._linear_offset is element-granular, and
while every preshuffle stride happens to be dword-aligned, a 5-D view would
just replace one multiply-add chain with another for about two lines. It
only pays off alongside FlyDSL-native tensors and copy atoms.

Co-authored-by: Cursor <[email protected]>

* refactor(flydsl): express the KV preshuffle as a layout, not a code path

The paged gather hand-computed byte offsets and branched on Preshuffle to
pick between two of them. Both layouts are actually the same coordinate
space -- (block, token//16, token%16, K-step, sub-group, lane half) -- and
differ only in the stride vector:

    block-flat  (blk, 4D, D/4, 16,  4,  2)   token c at c*D
    shuffled    (blk, 4D, 4,   256, 64, 2)   token c at (c//16)*16D + (c%16)*16

So the choice moves into make_kv_key_view and the kernel loses its `if
preshuffle` branch entirely; one load_pack_kv serves both. The co-packed
scale tail becomes a (block, token) view whose base absorbs the KVB*D key
offset, replacing the manual scale_byte arithmetic.

load_pack_kv slices the view down to the `sub` axis once rather than
indexing all six coordinates per load. Without that the invariant part of
the address is re-derived in each of the four loads and the kernel grows 49
instructions; with it, 14.

Trade, measured rather than assumed: the kernel file drops 15 lines and a
branch, the shared module gains 21 for the two view constructors, so the
pair is +6 overall. Codegen is 14 instructions larger (669 vs 655) because
the hand-written version exploited disjoint bit-fields to fuse addresses
into v_or3_b32/v_add3_u32 that the general dot product does not reach for.

Speed holds on every path (3 reps each, layout vs previous): preshuffle
27.58 vs 27.83us, block-flat KVB=64 9.78 vs 9.98us, KVB=1 10.20 vs 10.53us.
870/870 correctness at 5.3e-4, no new ruff findings.

Co-authored-by: Cursor <[email protected]>

* test(flydsl): curate the paged mqa-logits matrix, 870 cases -> 29

The sweep crossed seven axes into 864 cases that compiled only 12 distinct
kernels, re-running each about 72 times. The kernel specialises at compile
time on (heads, head_dim, KVBlockSize, Preshuffle); batch, next_n, context
length, SplitKV and the Q dtype are runtime values, and none of the axes
interact -- nothing couples head_dim to SplitKV or the dtype to KVBlockSize
-- so the product was testing interactions that cannot exist. q_dtype alone
cost 432 cases while selecting no different code path on gfx950, where
convert_q_fn is always False.

Now: a full cross of the compile-time axes (16 cases, one per distinct
kernel -- more preshuffle coverage than before, which only hand-picked 4),
each runtime axis varied alone off a base, and four interaction cases where
the tile-range arithmetic genuinely couples. --exhaustive still runs the
original 870 for release validation.

Validated by mutation testing rather than by the suite passing, since a
suite cut too far also passes. Eleven deliberate kernel bugs -- swapped
preshuffle and block-flat strides, causal off-by-one, dropped tail clamp,
wrong lane half, wrong block-table index, dropped kv_scale, wrong head
weight, floor-instead-of-ceil split (needs SplitKV>1), batch-blind output
row (needs batch>1), next_n-blind causal bound (needs next_n>1). The full
suite catches 11/11; the curated matrix also catches 11/11.

29 cases in 8.7s against 870 in 79s. Harness in att_profiles/mutation_check.py.

Co-authored-by: Cursor <[email protected]>

* test(flydsl): cover the wave-split and ChunkK axes

Neither was ever exercised: every case ran the default variant at
ChunkK=128, so paged_w2 and paged_w4 had no coverage at all, and the Tier-1
change of DEFAULT_VARIANT silently moved which one CI touched.

That hole was real, not theoretical. A mutation of the wave-to-column-tile
assignment (`wave * N_TILES_PER_WAVE` -> `wave * (N_TILES_PER_WAVE - 1)`) is
correct by construction at one wave per CTA, where `wave` is always 0, and
wrong for any multi-wave variant. It survived both the curated suite *and*
the original 870-case exhaustive sweep.

Adds variant and chunk_k parameters plumbed through to the kernel, reported
in the results table, and six cases: paged_w2 and paged_w4 at the default
tile width, ChunkK 64 and 256 against the variants that divide them, and a
preshuffle x paged_w4 cross. 35 cases in 9.0s, and the mutation set now runs
12/12 where the exhaustive suite manages 11/12.

Co-authored-by: Cursor <[email protected]>

* test(flydsl): condense the paged mqa-logits test prose and plumbing

Docstrings trimmed to what a reader cannot derive -- the oracle's formula
and mask rule, the co-pack byte layout, what the preshuffled copy is for --
dropping the restatement and the cross-references to other files.

_build_inputs returned an 8-tuple that was unpacked over ten lines at the
call site; it now returns a NamedTuple, so the test body reads inp.q_fp8
rather than positional unpacking, and the contract is documented by the
type. Its block table is also built vectorized instead of one element per
GPU write, which is why the suite went from 9.0s to 7.5s. Same values: the
per-case errors are unchanged to the digit.

The pool there is still sized from max_model_len, so sequences share blocks
once the batch outgrows it. Left alone deliberately, with a comment saying
why: harmless for correctness and arguably extra coverage of block reuse,
unlike in the benchmarks where it shrank the measured working set into cache.

Still 35 cases, still 12/12 on the mutation set.

Co-authored-by: Cursor <[email protected]>

* docs(flydsl): drop benchmark figures from the paged mqa-logits source

Timings and percentages go stale as soon as anything around them changes,
and the source is the wrong place to keep them -- the numbers behind these
choices are in the commit history and the PR description.

Removes the measured wave-count curve from _auto_split_kv, the "4-14%
slower" claim from the DEFAULT_VARIANT note, and the "where the measured
curve bottoms out" aside from the WavePerEU docs, keeping what the formula
computes and why resident wave count is the lever. In the test, the block
table comment keeps its warning that shared blocks are deliberate but no
longer cross-references what that would cost a benchmark.

Comments only; 35/35 correctness cases unchanged at 3.97e-4.

Co-authored-by: Cursor <[email protected]>

* docs(flydsl): fix stale --variant default in the paged bench help

The help text still advertised paged_w4 after DEFAULT_VARIANT moved to
paged_w1. Read it from the constant so it cannot drift again.

Co-authored-by: Cursor <[email protected]>

* refactor: move the FlyDSL benchmarks out of op_benchmarks/triton

They were sitting in the Triton benchmark directory alongside 73 unrelated
files, which is misleading -- neither uses Triton. op_benchmarks/flydsl/ now
holds both, matching how op_tests/flydsl_tests/ already separates the FlyDSL
correctness tests.

No __init__.py needed: op_benchmarks subdirectories are namespace packages,
which is also why the vs-gluon benchmark keeps importing kv_cache_cast_to_fp8
from op_benchmarks.triton.bench_deepgemm_attention -- that file is genuinely
a Triton benchmark and stays put.

Paths updated in the bench's own rocprofv3 example and in pr.md. Both run
clean from the new location: microbenchmark 27.8us with its correctness gate
passing, head-to-head 3.11x at B=16.

Co-authored-by: Cursor <[email protected]>

* style(flydsl): satisfy the Black and Ruff pre-checks on PR #4221

CI reported five failures; only two are real. check-signal waits on the
pre-checks workflow and Aiter Test Gate depends on check-signal, so the
gate failed in four seconds without running a single GPU test. Fixing
style unblocks all three.

These findings were invisible locally because I had been diffing ruff
against the branch's own history. CI runs it through reviewdog with
filter-mode=diff_context against upstream/main, where none of these files
exist -- so every line is an added line and every finding is in the diff.

Seven auto-fixed: import ordering in five files plus __all__ ordering in
aiter/ops/flydsl/__init__.py. Five needed a decision, taken to match what
the repo already does rather than inventing a convention -- it carries 214
BLE001, 21 B008 and 19 PLR0124 suppressions, including this exact
`fx.Stream(None)` default in moe_route_maps.py and this exact NaN-check
idiom in test_fused_qk_norm_rope_group_quant.py. So noqa for the blind
except, the FlyDSL stream default and the self-comparison, and the two
unused `heads` unpackings renamed to `_heads`. Black reformatted one file.

Verified as CI runs them, repo-wide: `black --check .` leaves 1063 files
unchanged, and `ruff check .` leaves five findings, all in upstream files
this PR does not touch. Behaviour unchanged: 35/35 correctness at 3.97e-4,
27.93us, and the public exports still resolve after __init__ was resorted.

Co-authored-by: Cursor <[email protected]>

* refactor(flydsl): drop dead conversion plumbing from the paged kernel

convert_q_fn and convert_kv_fn were threaded through the kernel builder, the
compile cache and the host, and neither is ever read inside the emitted
kernel -- they only appended a name tag. convert_kv_fn was additionally
hardcoded False at every call site. Only scale_mul reaches codegen, so it is
now the sole carrier of the FN->FNUZ compensation and tags the kernel name
itself.

That exposed a docstring that was simply untrue: compile_fp8_paged_mqa_logits
claimed these flags "mark an FP8 FN operand whose -0 (0x80) byte the kernel
patches to FNUZ +0". No such patch exists on this path -- the vector<8xi32>
operand has no byte-patch, which the kernel body's own comment admitted. The
host comment now states the actual gfx942 behaviour, including that FN -0
decodes to FNUZ NaN unpatched. Flagged rather than fixed: it needs gfx942 to
validate.

Also: mfma_head_reduce now derives res_ty and f32_0 and defaults fm_fast, so
the call site is one line instead of eleven and the kernel drops two locals;
make_out_row_view takes the i32 stride and widens it itself. Both are safe
because _mqa_logits_common turns out to have exactly one consumer -- upstream's
dense fp8_mqa_logits carries its own copies and does not import it, so the
module docstring claiming otherwise is corrected too.

569 -> 535 lines in the kernel. ISA byte-identical to HEAD (669 instructions),
35/35 correctness at 3.97e-4, 27.92us, black and ruff clean.

Co-authored-by: Cursor <[email protected]>

* fix(flydsl): pass buffer load/store aux as an i32 SSA operand

upstream/main treated aux as an optional IntegerAttr, but RawPtrBufferLoadOp
expects it as the fourth operand Value. With cache_modifier=0 that left aux
None and broke JIT compilation of kernels using GTensor buffer loads.

Co-authored-by: Cursor <[email protected]>

* fix(flydsl): align buffer_ops and MFMA helpers with flydsl 0.3.1

Revert buffer load/store aux to the upstream IntegerAttr form expected by
flydsl 0.3.1, and route scaled MFMA through the expr wrapper so cbsz/blgp
attributes lower correctly during paged MQA kernel JIT.

Co-authored-by: Cursor <[email protected]>

* perf(flydsl): software-pipeline block-table and K0 prefetch in paged MQA logits

Prefetch kv_indices one tile ahead (skip reload when ind_off unchanged) and
carry K-step-0 across the inner column loop to hide VMEM latency on the
production kvb64/preshuffle decode path.

Co-authored-by: Cursor <[email protected]>

* style(flydsl): fix Black/Ruff on paged MQA logits prefetch helpers

Bind loop SSA values via default args (B023) and apply Black formatting.

Co-authored-by: Cursor <[email protected]>

* address comments by Sami

* style(flydsl): fix Black/Ruff on paged MQA logits files

Apply Black formatting and resolve Ruff PLR0124/I001 so CI pre-checks pass.

Co-authored-by: Cursor <[email protected]>

* feat(flydsl): add gfx950 H64 16x16x128 paged FP8 MQA logits kernel

Land the production indexer mapping (resident Q, depth-4 NT B-ring, SplitKV)
without the v2/v3 experiments or local profiling artifacts.

Co-authored-by: Cursor <[email protected]>

* feat(flydsl): specialize gfx950 paged MQA logits for H=32 and H=64

Compile a separate 16x16x128 kernel per head count so the indexer matches
gluon's ChunkQ=heads set without changing the FlyDSL page pipeline.

Co-authored-by: Cursor <[email protected]>

* feat(flydsl): compile-time next_n for gfx950 paged MQA logits

Drop the unused second query row on next_n=1 so MFMA/VALU and store waits match the actual decode shape.

Co-authored-by: Cursor <[email protected]>

* feat(flydsl): dual-bank page pipeline for gfx950 paged MQA logits

Keep next-page K in fixed register banks instead of scf.for yield copies, store one wave-wide page of logits, and prefetch the page table so gather latency stays overlapped.

Co-authored-by: Cursor <[email protected]>

* feat(flydsl): dispatch gfx950 paged MQA logits as the default decode path

Route H32/H64 D128 KVB64 preshuffle next_n in {1,2} through the 16x16x128 kernel, keep the 32x32x64 implementation as the generic fallback, and satisfy Black/Ruff.

Co-authored-by: Cursor <[email protected]>

* refactor(flydsl): make gfx950 the only paged FP8 MQA logits path

Drop the generic 32x32x64 kernel and fold helpers into the gfx950 decoder so
H32/H64 stays on the tuned 16x16x128 pipeline, with i64 output-row addressing
and idiomatic FlyDSL MMA/scheduling that still matches the previous ISA.

Co-authored-by: Cursor <[email protected]>

* style(flydsl): black-format gfx950 paged MQA logits and tests

Co-authored-by: Cursor <[email protected]>

* dynamic next_n scheduling WIP.

* cleanup

* feat(flydsl): accept compact Q[B, next_n, 32, 128] for gfx950 paged MQA logits

Match the Gluon contract so next_n can be 1..8 without padding Q to 8 rows;
optional next_n_lens still selects live rows per sequence.

Co-authored-by: Cursor <[email protected]>

* perf(flydsl): raise wave priority around scaled MFMA

Give compute waves s_setprio 3 during gemm so they win over helper G2L.

Co-authored-by: Cursor <[email protected]>

* perf(flydsl): hold s_setprio across both scaled MFMAs per row

Avoid dropping priority between the two 16x16x128 gems.

Co-authored-by: Cursor <[email protected]>

* perf(flydsl): hint waves_per_eu=6 to match LDS-bound occupancy

Compiler was told 2 waves/EU while the CTA actually lands 6.

Co-authored-by: Cursor <[email protected]>

* perf(flydsl): unroll next_n scoring by two rows

Issue a pair of Q/weight LDS packs per iteration of the row loop.

Co-authored-by: Cursor <[email protected]>

* perf(flydsl): unroll next_n scoring by four rows

Give the compiler a larger Q/weight LDS pack window per tile.

Co-authored-by: Cursor <[email protected]>

* perf(flydsl): fully unroll next_n scoring over MAX_NN

Replace the 4/2/1 while ladder with predicated constexpr rows.

Co-authored-by: Cursor <[email protected]>

* perf(flydsl): cache paged MQA logit stores for the following topk

Write logits with buffer cache policy 0 so L2 can retain the row for the next kernel; keep KV page DMA nontemporal so those loads do not evict it.

Co-authored-by: Cursor <[email protected]>

* refactor(flydsl): drop dead gfx950 paged-MQA helpers and restore scalar logit stores

Scalar GTensor writes already lower to cached buffer_store; the explicit store path and unused arith/B_RING bits did not change ISA. Share MAX_NN from the kernel in tests.

Co-authored-by: Cursor <[email protected]>

* test(flydsl): keep paged MQA driver out of pytest collection

Co-authored-by: Cursor <[email protected]>

* cleanup(flydsl): remove stale paged MQA test paths

Co-authored-by: Cursor <[email protected]>

* test(flydsl): put paged MQA logits on the aiter op_test template

Move the gfx950 indexer tests to op_tests/test_*.py with @benchmark
candidates, TFLOPS/TB/s, a torch-only reference, and one markdown table
per signature so CI runs python3 op_tests/test_flydsl_fp8_paged_mqa_logits.py.

Co-authored-by: Cursor <[email protected]>

* test(flydsl): fold paged MQA pytest coverage into the op_test tables

Keep a single gfx950-gated test_*.py as the source of truth, grade wide
output against torch, and leave the flydsl_tests files as shims.

Co-authored-by: Cursor <[email protected]>

* test(flydsl): drop paged-MQA shims and add the probe_1079 decode table

Keep a single op_test as the source of truth, with the production
scattered-pool contract (mean Nq, next_n × ctx) graded against torch.

Co-authored-by: Cursor <[email protected]>

---------

Co-authored-by: yashagar <[email protected]>
Co-authored-by: Folkert Huizinga <[email protected]>
Co-authored-by: Cursor <[email protected]>
anhminhnguyenhoang and others added 26 commits December 3, 2026 15:38
The B global-to-register copy is now the MMA's B thread-value layout with
each lane's values reordered n-rep first, instead of a hand-written stride
table. The ring-to-operand shuffle is that copy's value layout inverted and
composed with the MMA's. The bias loads through the epilogue copy's retile
of an accumulator-shaped fragment, so it lands in accumulator order with no
shuffle, on both dense layouts.

Signed-off-by: Anh Minh Nguyen Hoang <[email protected]>
Co-authored-by: Cursor <[email protected]>
Signed-off-by: Anh Minh Nguyen Hoang <[email protected]>
Co-authored-by: Cursor <[email protected]>
The K=32 atom halves the MFMA issue count with the same accumulators per lane. A fragment K index is flat for one atom per K step, so k_coord picks the flat or nested form.

Signed-off-by: Anh Minh Nguyen Hoang <[email protected]>
Co-authored-by: Cursor <[email protected]>
A goes global to LDS by async LDS DMA instead of through VGPRs. The DMA writes each wave's lanes contiguously, so each lane fetches the element that the swizzled A layout places at its slot. gfx942 keeps the register path (a_lds_dma=False).

Signed-off-by: Anh Minh Nguyen Hoang <[email protected]>
Co-authored-by: Cursor <[email protected]>
B_STAGES becomes an arch trait. Two stages free 8 to 24 VGPRs, which lets the K=512 kernels keep a third wave per SIMD. gfx942 keeps three.

Signed-off-by: Anh Minh Nguyen Hoang <[email protected]>
Co-authored-by: Cursor <[email protected]>
New skew_xcd_c and skew_xcd_w columns. An empty cell keeps the _skew_compact_xcd fallback, so gfx942 rows select the same config as before.

Signed-off-by: Anh Minh Nguyen Hoang <[email protected]>
Co-authored-by: Cursor <[email protected]>
Rows for the five headline shapes on 256 CUs. Cells that did not beat the default by more than 1% stay empty.

Signed-off-by: Anh Minh Nguyen Hoang <[email protected]>
Co-authored-by: Cursor <[email protected]>
The 3-D layout is faster and the 2-D one needed a host transpose.
Remove the DENSE_KN branches, the 2-D validate path, and the tuned
threads column, which only the 2-D uniform path read. The 3-D kernels
compile to the same ISA and give bit-identical outputs.
A block_k that does not divide K would drop the K tail and give a
wrong result. The test checks block_k 0, 24, and 3K/8 raise ValueError
and leave C untouched.
…r reuse.

- resolve_config keys the tuned CSV on get_gfx_runtime(), as the kernel already
  does. get_gfx() follows GPU_ARCHS, so GPU_ARCHS="gfx950;gfx942" on MI355X
  looked up gfx942 rows and fell back to the untuned default.
- test_jdbba_config_selection checks that the live arch owns the row and that
  an explicit override wins.
- test_jdbba_launcher_reuse fails if a new length or batch compiles a new
  launcher, and checks the result against torch.

Co-authored-by: Sami Aario <[email protected]>
Co-authored-by: Cursor <[email protected]>
…and skew-fallback paths, and read the runtime arch.

Co-authored-by: Cursor <[email protected]>
… index math, the XCD remap's Int32 range, the 32-bit buffer bounds, or N = 0, before launch.

Co-authored-by: Cursor <[email protected]>
… so other shapes still dispatch.

Co-authored-by: Cursor <[email protected]>
…han the 4 GiB a 32-bit buffer offset reaches, and accept B groups up to 4 GiB.

Co-authored-by: Cursor <[email protected]>
…nts to state only what the code cannot show.

Co-authored-by: Cursor <[email protected]>
… of A or C spans more than 4 GiB.

Co-authored-by: Cursor <[email protected]>
… rows below L, so no store lands past C or wraps a 32-bit offset, and drop the group-size host checks this makes moot.

Co-authored-by: Cursor <[email protected]>
…p the checks only they could fail.

jagged_dense_bmm no longer takes block_m, block_n, or threads. The one caller never varied them, so check_config held branches that could not fire, and the tuned-row key in tiles_log2 could drift from the launched tile. Also drop the unreachable xcd_c = 1 branch in _row_config: the skew path always sets xcd_c.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Anh Minh Nguyen Hoang <[email protected]>
n_groups: int,
max_seq_len: int,
stream=None,
uniform_seqlen: bool = True,

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.

uniform_seqlen defaults to True, so a caller that omits it gets the dense grid even when group lengths vary, which is the normal input for this op. On MI355X, for variable-length batches the dense grid is 1.21–1.83x slower than the compact grid on the PR's skew rows, and on 5 of 15 skew shapes I measured it is slower than the Triton baseline (worst 0.61x: B=120, D=512, N=512, 235 vs 144 µs). On uniform-length data the compact grid is within 0.97–1.10x of the dense grid.

Comment on lines +906 to +909
(D, "block_k", 0),
(D, "block_k", 24),
(D, "block_k", 3 * D // 8),
(192, "block_k", 96),

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.

On gfx950 none of the invalid block_k cases reaches the K % block_k guard (jagged_dense_bmm_gen.py L728): 0 and 24 are rejected as not a multiple of 32, and 96 as not a power of two (L720). With that guard removed, the whole op test still passes on MI355X, while K=192 with block_k=128 then returns 259,490 of 262,144 wrong elements.

@Bernard-Liu

Copy link
Copy Markdown
Contributor

The gfx950 speedup in the description (geomean 1.32x) is measured against Triton 3.6.0, but aiter CI installs Triton 3.9.0 (triton-3.9.0+amd.rocm7.2.0.git24d5394c). On MI355X, over the same 10 rows (5 rounds each), I get geomean 1.29x vs Triton 3.6.0 but 1.15x vs Triton 3.9.0, with the uniform rows at 1.03–1.14x. Some shapes outside the table are not faster: B=16, D=1024, N=1024, Mi=4096 (uniform) is 0.96x vs Triton 3.9.0.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants