Skip to content

[FlyDSL] FP8 MQA logits improvements for gfx950 - #7412

Open
vpietila-amd wants to merge 14 commits into
mainfrom
users/vpietila/fp8-mqa-logits-gfx950-improvements
Open

vpietila-amd wants to merge 14 commits into
mainfrom
users/vpietila/fp8-mqa-logits-gfx950-improvements

Conversation

@vpietila-amd

@vpietila-amd vpietila-amd commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR improves the FlyDSL FP8 MQA logits kernel on gfx950:

  • A tuned route table replaces the hand-written variant pick.
  • The grid.y KV split uses the occupancy-aware wave-cost model, with tuned fixed splits for long uneven windows.
  • The LDS-pipelined builder gains new head-reduce, head-accumulation and software-pipelining options and a bank-conflict-free swizzle, and moves to async copy atoms.
  • Empty and past-the-end KV windows no longer make a block scan the whole KV.
  • aiter.mqa_logits() ([HIP] [CI] [JIT] Add aiter.mqa_logits with a tuned Triton/FlyDSL table #6185) accepts the new variants, and its GLM-5 table is re-tuned with them.

Motivation

  • Variant pick: main's gfx950 heuristic picked from a few fixed variants. At clean_logits=False it is 0.79–0.95× Gluon (geomean) for every (num_heads, head_dim) except H128 D128.
  • Split policy: main's gfx950 split used a fixed cu_oversub target that ignores how many blocks of a kernel fit on a CU, so small-M / long-KV shapes were badly split.
  • Empty windows: an empty or past-the-end row stretched the block's union KV window to seq_len_kv. Past_end at 2048×131072 takes 1.6–6.0 ms on main.
  • Raw addressing: the LDS builder used raw buffer_ops / create_llvm_ptr addressing and a hand-coded swizzle.

Changes

  • Dispatch (aiter/ops/flydsl/fp8_mqa_logits_kernels.py):
    • Tag grammar: gfx950 variants are a tag grammar built on demand, mfma<MxNxK>_bkv<B>_r<R>_w<W>[_lds<NB>[_pd<PD>][_swp][_rs][_ls][_ts][_dg][_ig]][_h<fma|fma2>][_wpe<N>][_ns<N>].
    • Route table: _GFX950_ROUTES, keyed by (num_heads class, head_size class) with seq_len / seq_len_kv bounds, picks the variant. Head sizes above 128 take _GFX950_LARGE_HEAD_FALLBACK.
    • Split policy: gfx950 uses the occupancy-aware wave-cost model, as gfx942 does. Seven routes carry tuned fixed splits at seq_len_kv > 4096 (_GFX950_ROUTE_SPLITS).
    • New public variant_supported(tag, num_heads, head_size): the tag builds, its atom tiles the problem, its LDS slots fit and its vmcnt fits the encoding (≤ 63).
    • Compiler options: LLVM's SLP vectorizer is off except on 4 routes; _wpe<N> sets waves_per_eu.
  • aiter.mqa_logits (aiter/mqa_logits.py, glm5_tuned_mqa_logits.csv):
    • flydsl_supports uses variant_supported instead of membership in KERNEL_VARIANTS.
    • A row may name the variant auto to use the route table.
    • The GLM-5 table is re-tuned with routed tags.
  • Kernel (aiter/ops/flydsl/kernels/mqa_logits/fp8_mqa_logits.py):
    • New options:
      • head_acc (add / fma / fma2 head-sum chains);
      • rs_head (permlane reduce-scatter over a group of n-tiles, one contiguous 64-lane store);
      • sw_pipe (MFMAs of item k+1 before the epilogue of item k; _ig forces iglp_opt at any WPB);
      • lds_scales, tile_skip, dma_guard, prefetch_depth.
    • KV staging: async-copy atoms (BufferLoadAsyncLDS{128b,32b}), and the bank-conflict swizzle as a SwizzleType layout. For the 32x32x64 atom at head_size ≤ 128 the swizzle is 16-byte granular, which removes a 2-way ds_read_b128 conflict.
    • Empty-window fix: a non-live row takes the window [seq_len_kv, 0).
  • Shared helpers (aiter/ops/flydsl/kernels/kernels_common.py): warp_reduce_strided and warp_reduce_scatter_strided. FlyDSL 0.5.3's fx.coop only folds contiguous lane groups, while the head reduce folds lane bits at and above MFMA_N.

Performance

MI350X (gfx950, 256 CUs), ROCm 7.2.2, torch 2.10.0, Triton 3.8.0, FlyDSL 0.5.3. PR 02598fa593, main 3486e43ba. Geomean speedup, > 1 means this PR is faster.

Hardware Workload/configuration Before After Speedup
MI350X 960-case sweep, clean_logits=True main FlyDSL this PR 1.35× (1.57× vs Gluon)
MI350X 960-case sweep, clean_logits=False main FlyDSL this PR 1.42× (1.42× vs Gluon)
MI350X sweep cases with s_kv ≥ 32k (90 per clean_logits) main FlyDSL this PR 2.30× / 3.02×
MI350X aiter.mqa_logits(), 24 GLM-5 shapes (H32 D128) main code + table this PR + re-tuned table 1.36× (1.25–1.65×); 1.70× vs Triton/Gluon

The 960-case sweep is op_tests/test_flydsl_fp8_mqa_logits.py --scenario bench --full over:

  • shapes 1×1, 1×16, 1×113, 17×76, 61×113, 61×1024, 128×1024, 1024×1024, 1024×1560, 64×2048, 64×8192, 256×8192, 257×8192, 128×64, 1024×1000, 512×32768, 1024×65536 and 2048×131072;
  • num_heads {32, 64, 128} × head_dim {64, 128} × 5 windows × clean_logits.

Every case is graded, then timed with HIP-graph replay (LLC flush per replay, median of 20 × mean of 50). All 960 cases pass on both trees. The PR and main shards alternated on one GPU. GLM-5 times are from mqa_logits_tune.py --run_config.

Per (num_heads, head_dim) and per window
H D cl=True vs Gluon cl=True vs main cl=False vs Gluon cl=False vs main
32 64 1.39 1.30 1.26 1.37
32 128 1.38 1.33 1.22 1.39
64 64 1.32 1.37 1.14 1.46
64 128 1.35 1.35 1.16 1.40
128 64 1.57 1.41 1.42 1.49
128 128 2.83 1.36 2.86 1.44
window cl=True vs Gluon cl=True vs main cl=False vs Gluon cl=False vs main
causal 1.71 1.23 1.52 1.23
cp 1.83 1.45 1.70 1.49
empty 1.43 1.08 1.26 1.11
misaligned 1.53 1.27 1.35 1.28
past_end 1.54 1.94 1.48 2.31

Notes:

  • Where the PR loses: it beats main on 922 of 960 cases. All 5 cases below 0.97× vs main are empty windows (worst 0.90×, 1024×65536 H128 D128, dominated by the -inf fill). The weakest cases vs Gluon (0.63–0.83×) are empty / past_end windows at s_kv ≥ 32k: nothing to compute, and the fixed splits add empty blocks.

Testing

  • Unit tests added or updated
  • Performance benchmarks run
  • Tested on MI250X
  • Tested on MI300X

MI350X (gfx950) only; see "Validation and unverified scope".

Documentation

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

The tag grammar, route table and builder options are documented next to the code; this op has no user-guide page.

Dependencies

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

Breaking Changes

None for flydsl_fp8_mqa_logits and mqa_logits. One exported constant changes on gfx950:

  • KERNEL_VARIANTS (exported from aiter.ops.flydsl) now lists the routed tags plus the large-head fallback, not the old fixed registry. The old tags still build. Code that validates a tag by membership in KERNEL_VARIANTS should call variant_supported(tag, num_heads, head_size) instead; aiter.mqa_logits does so in this PR.

PR Self-Review

Reviewed revision

03f8253

Behavior and intent

  • gfx950 dispatch: a tuned route table and an occupancy-aware split replace a heuristic that lost to Gluon on about half the sweep at clean_logits=False.
  • Empty and past-the-end windows: they no longer widen a block's union KV window. The output was already correct; only the time changes, up to about 100× at s_kv = 128k.
  • mqa_logits: FlyDSL rows are validated by variant_supported. Without this, after this PR every GLM-5 FlyDSL row would silently run Triton.
  • gfx942: only the empty-window fix and head_acc (default unchanged) reach its builder; its routes and split policy are unchanged.

Validation and unverified scope

MI350X, ROCm 7.2.2, torch 2.10.0, Triton 3.8.0, FlyDSL 0.5.3:

  • Op test verify: FLYDSL_RUNTIME_ENABLE_CACHE=0 python op_tests/test_flydsl_fp8_mqa_logits.py --scenario verify: 152/152 in 33 s. With --full: 1833/1833.
  • python op_tests/test_mqa_logits.py: passes.
  • Bench: --scenario bench --full on PR and main: 960/960 graded on both.
  • Tuning: mqa_logits_tune.py on GLM-5, then --run_config: 24/24 within 10%. op_tests/tuning_tests/test_config_shape_collision.py passes.
  • Spill scan (compile-only): no spills on any route at its own (num_heads, head_size), and none for the fallback up to head_size 512.
  • Lint: black --check and ruff check pass.

Unverified:

  • gfx942 was not run (CI's gfx942 lane covers it).
  • Head sizes above 128 run the untuned fallback. At head_size 1024 with 64 or more heads it spills, because Q alone needs 512 VGPRs, but it stays correct. mqa_logits() admits only head_dim 64 and 128.
  • Known limitation, as in [FlyDSL] fp8_mqa_logits: derive the split target from kernel occupancy #5921 for gfx942: a launcher whose first call is inside graph capture cannot query occupancy (HIP rejects hipModuleUnload during capture), so it uses the fixed cu_oversub=4 split. Output is unaffected. One eager call before capture gives the tuned split.

PR-specific question

What would each changed op test fail on before this PR, and why is that coverage not already provided?

  • Production-variant pins (test_flydsl_fp8_mqa_logits.py):
    • What: every routed variant is forced onto an odd 67×1500 shape (a clamped tail tile and a partial row block), at its routes' sizes by default and at all sizes with --full.
    • Why: the routed variants did not exist before this PR, and the shape-dependent router reaches a given variant only by chance in the sweeps.
  • Auto-routed head dims: main has no test above head_dim 128. In an earlier revision of this PR (bfe265224), all head_dim 512 cases failed (wrong logits or LDS overflow), and nothing else would have caught it.
  • Long-context shapes (512×32768, 1024×65536, 2048×131072): the only shapes that reach the long-KV routes and splits. On main they expose the empty-window slowdown (past_end 1.6–6.0 ms vs 23–252 µs here).
  • check_shipped_flydsl_rows_supported (test_mqa_logits.py): it fails when a shipped FlyDSL row would fall back to Triton, which was the state of all 24 GLM-5 rows after this PR's registry change. check_dispatches_shipped_row expects Triton whenever flydsl_supports is False, so it cannot catch this.

Changed op tests

  • op_tests/test_flydsl_fp8_mqa_logits.py, still the single FlyDSL fp8_mqa_logits correctness and perf test:
    • production-variant pins, and auto-routed head-dim checks for head_dim above 128;
    • three long-context shapes;
    • a variant column in the bench output;
    • --shapes-csv (bench production shape dumps through the same path);
    • -o (save the tables);
    • a smaller default verify, with the full matrix behind --full.
  • op_tests/test_mqa_logits.py: check_shipped_flydsl_rows_supported, the guard against silent Triton fallback described above.

…computing optimal KV-split values, add new head accumulation method; improve software pipelining; fix empty KV window handling; use async loads for LDS copies.
@github-actions

github-actions Bot commented Nov 3, 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: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 gfx1201 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 7412 --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.

@aiter-bot

aiter-bot commented Nov 3, 2026 •

Copy link
Copy Markdown

NOT READY FOR HUMAN REVIEW

PR Self-Review

Revision 03f825395e9f · mode shadow

Author self-review accepted. Readiness report:

Author answers

  • PASS — current-SHA answers are present and structurally specific
Show the author's self-review answers

Behavior and intent

- **gfx950 dispatch:** a tuned route table and an occupancy-aware split replace a heuristic that lost to Gluon on about half the sweep at clean_logits=False.
- **Empty and past-the-end windows:** they no longer widen a block's union KV window. The output was already correct; only the time changes, up to about 100× at s_kv = 128k.
- **`mqa_logits`:** FlyDSL rows are validated by `variant_supported`. Without this, after this PR every GLM-5 FlyDSL row would silently run Triton.
- **gfx942:** only the empty-window fix and `head_acc` (default unchanged) reach its builder; its routes and split policy are unchanged.

Validation and unverified scope

MI350X, ROCm 7.2.2, torch 2.10.0, Triton 3.8.0, FlyDSL 0.5.3:
- **Op test verify:** `FLYDSL_RUNTIME_ENABLE_CACHE=0 python op_tests/test_flydsl_fp8_mqa_logits.py --scenario verify`: 152/152 in 33 s. With `--full`: 1833/1833.
- **`python op_tests/test_mqa_logits.py`:** passes.
- **Bench:** `--scenario bench --full` on PR and main: 960/960 graded on both.
- **Tuning:** `mqa_logits_tune.py` on GLM-5, then `--run_config`: 24/24 within 10%. `op_tests/tuning_tests/test_config_shape_collision.py` passes.
- **Spill scan (compile-only):** no spills on any route at its own (num_heads, head_size), and none for the fallback up to head_size 512.
- **Lint:** `black --check` and `ruff check` pass.

Unverified:
- **gfx942** was not run (CI's gfx942 lane covers it).
- **Head sizes above 128** run the untuned fallback. At head_size 1024 with 64 or more heads it spills, because Q alone needs 512 VGPRs, but it stays correct. `mqa_logits()` admits only head_dim 64 and 128.
- **Known limitation, as in #5921 for gfx942:** a launcher whose first call is inside graph capture cannot query occupancy (HIP rejects `hipModuleUnload` during capture), so it uses the fixed `cu_oversub=4` split. Output is unaffected. One eager call before capture gives the tuned split.

PR-specific question

What would each changed op test fail on before this PR, and why is that coverage not already provided?

- **Production-variant pins** (`test_flydsl_fp8_mqa_logits.py`):
  - What: every routed variant is forced onto an odd 67×1500 shape (a clamped tail tile and a partial row block), at its routes' sizes by default and at all sizes with `--full`.
  - Why: the routed variants did not exist before this PR, and the shape-dependent router reaches a given variant only by chance in the sweeps.
- **Auto-routed head dims:** main has no test above head_dim 128. In an earlier revision of this PR (`bfe265224`), all head_dim 512 cases failed (wrong logits or LDS overflow), and nothing else would have caught it.
- **Long-context shapes** (512×32768, 1024×65536, 2048×131072): the only shapes that reach the long-KV routes and splits. On main they expose the empty-window slowdown (past_end 1.6–6.0 ms vs 23–252 µs here).
- **`check_shipped_flydsl_rows_supported`** (`test_mqa_logits.py`): it fails when a shipped FlyDSL row would fall back to Triton, which was the state of all 24 GLM-5 rows after this PR's registry change. `check_dispatches_shipped_row` expects Triton whenever `flydsl_supports` is False, so it cannot catch this.

Changed op tests

- **`op_tests/test_flydsl_fp8_mqa_logits.py`**, still the single FlyDSL fp8_mqa_logits correctness and perf test:
  - production-variant pins, and auto-routed head-dim checks for head_dim above 128;
  - three long-context shapes;
  - a `variant` column in the bench output;
  - `--shapes-csv` (bench production shape dumps through the same path);
  - `-o` (save the tables);
  - a smaller default verify, with the full matrix behind `--full`.
- **`op_tests/test_mqa_logits.py`:** `check_shipped_flydsl_rows_supported`, the guard against silent Triton fallback described above.

PR state

  • PASS — pull request is marked ready for review

Copilot findings

  • PASS — no active Copilot finding lacks a substantive author reply
  • ADVISORY — Copilot did not review the current head SHA

Code and op-test hygiene

  • PASS — no committed artifact or conflict marker detected

Required CI

  • PASS — Black: passed
  • PASS — Ruff: passed
  • PASS — Repository dependency: passed
  • FAIL — Aiter Test Gate: failed
  • Required CI failed; fix it before requesting human review.

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

vpietila-amd and others added 4 commits November 3, 2026 16:44
…t guidelines

Kernel (ISA-identical on all 96 checked gfx950 specializations):
- Use the public fx.fma spelling instead of fx.math.fma.
- Pass DSL values straight to rocdl.readfirstlane, which coerces them;
  drop the redundant .ir_value() unwraps.
- Pass tile_skip/dma_guard to the LDS builder directly instead of through
  conditional kwargs dicts.

kernels_common strided warp reductions:
- Document why fx.coop (FlyDSL 0.4.1) cannot replace them: all of its
  warp collectives, including the ROCm DPP override, fold contiguous lane
  groups only, and permlane{16,32}_swap has no typed wrapper.
- Use fx.max for ReductionOp.MAX, matching fx.coop's combine.

op test:
- --shapes-csv rows now sweep the existing --num-heads/--head-dim/--window
  axes when a column is absent, replacing the scalar --csv-num-heads and
  --csv-window flags.
- -o/--output gets help text, writes every scenario's table (bench no
  longer overwrites verify), and reuses the logged speedup line.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…rse variants LDS usage and do not build variants that exceed devices LDS capacity. Fix documentation for gfx950 routes. Add test for auto-routed head dimensions.
…s. Test improvements: every route is checked against reference.
@msaffari-amd

msaffari-amd commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Rebase conflict, and please re-run perf on FlyDSL 0.5.0

The PR conflicts with main in aiter/ops/flydsl/kernels/kernels_common.py. Main added pin_i32 (#7727, used by topk/radix_topk_one_block.py) in the same place where you add _combine, _permlane_swap, warp_reduce_strided and warp_reduce_scatter_strided. Keeping both sides works.

I tried it locally (main merged into this PR, FlyDSL 0.5.0):

  • gfx942 verify: 326/326 pass
  • all 35 gfx950 routes and the fallback compile on gfx950, 0 spills at head size 64 and 128

Main now pins FlyDSL 0.5.0. The perf tables in the description are from FlyDSL 0.4.1 at bfe265224. After that, these commits changed the kernel and the split policy:

  • d5f1ee0 swizzle fix for D>256
  • da0c237 removed the aggressive oversubscription

So the numbers may not match the code anymore. Please re-run the tables on gfx950 with FlyDSL 0.5.0 at the final head.

@msaffari-amd

Copy link
Copy Markdown
Contributor

After rebase, mqa_logits() never runs your gfx950 routes, and GLM-5 rows go to Triton

Main now has aiter/mqa_logits.py (#6185). It does not use _auto_variant. It reads the tag from the tuned table and passes it as variant=.... Shapes not in the table use Triton (DEFAULT_CONFIG). Before running FlyDSL, it checks:

if mod is None or variant not in mod.KERNEL_VARIANTS:
    return False

This PR changes KERNEL_VARIANTS on gfx950 to only the routed tags. The GLM-5 table (aiter/configs/model_configs/glm5_tuned_mqa_logits.csv) uses 6 FlyDSL tags, like mfma32x32x64_bkv128_r2_w4_lds3. None of them are in the new list.

So on gfx950, through mqa_logits():

  • GLM-5 FlyDSL rows (24): were FlyDSL on main, now Triton.
  • shapes not in the table: Triton, same as before.
  • your new routes: never used.

Only direct calls to flydsl_fp8_mqa_logits(variant=None) use your routes. Your tests and benchmarks call it that way, so they don't show this.

I checked with main merged into this PR:

  • main: 6/6 tags in KERNEL_VARIANTS, 0 rows go to Triton
  • this PR: 0/6 tags in KERNEL_VARIANTS, 24 rows go to Triton

The table shows Triton is 1.2x to 3.9x slower for these rows. For example, 256x16384: FlyDSL 37.7 us vs Triton 147.8 us.

CI will not catch this. check_dispatches_shipped_row expects Triton when flydsl_supports is False.

All 6 old tags still build with the new grammar. They pass _variant_supports and compile on gfx950 with 0 spills. Only the list check blocks them.

Possible fixes:

  • keep the old tags in KERNEL_VARIANTS, or
  • make flydsl_supports use _variant_supports, or
  • retune the GLM-5 table with your new tags.

To make mqa_logits() use your routes, add tuned rows for them. Also, the tuner (csrc/mqa_logits/mqa_logits_tune.py) loops over KERNEL_VARIANTS, so it now gets fewer candidates. "Breaking Changes: None" should mention this.

@msaffari-amd

Copy link
Copy Markdown
Contributor

Suggestion: keep the default verify smaller

The PR adds many verify cases (mostly from verify_production_variants). Each case compiles and runs a kernel, so CI gets slower.

--scenario verify:

  • main: 95 cases, 34 s
  • this PR (merged with main): 326 cases, 137 s

gfx950 has about 720 production pins, so it will take longer there. .github/split-test-times/aiter.tsv still lists this test at 36 s.

Maybe keep one or two shapes per route in the default verify, and move the full set behind a flag or a separate scenario.

@msaffari-amd

Copy link
Copy Markdown
Contributor

Overlap with #6164

#6164 (gfx942 LDS-staged variant, open) also edits aiter/ops/flydsl/fp8_mqa_logits_kernels.py and op_tests/test_flydsl_fp8_mqa_logits.py. It changes the gfx942 default variant, and this PR changes variant selection and the test pins. The two will conflict.

Please agree with @akii96 on the merge order, so the second PR rebases on the first one's variant list and tests.

vpietila-amd and others added 5 commits November 30, 2026 08:39
…ments

Resolve the kernels_common.py conflict by keeping main's pin_i32 (#7727)
and this branch's cross-lane reduction helpers.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…improve LDS swizzle to remove remaining bank conflicts.
… integration test to verify that shipped flydsl rows are supported.
@vpietila-amd

Copy link
Copy Markdown
Contributor Author

Rebase conflict, and please re-run perf on FlyDSL 0.5.0

The PR conflicts with main in aiter/ops/flydsl/kernels/kernels_common.py. Main added pin_i32 (#7727, used by topk/radix_topk_one_block.py) in the same place where you add _combine, _permlane_swap, warp_reduce_strided and warp_reduce_scatter_strided. Keeping both sides works.

I tried it locally (main merged into this PR, FlyDSL 0.5.0):

  • gfx942 verify: 326/326 pass
  • all 35 gfx950 routes and the fallback compile on gfx950, 0 spills at head size 64 and 128

Main now pins FlyDSL 0.5.0. The perf tables in the description are from FlyDSL 0.4.1 at bfe265224. After that, these commits changed the kernel and the split policy:

  • d5f1ee0 swizzle fix for D>256
  • da0c237 removed the aggressive oversubscription

So the numbers may not match the code anymore. Please re-run the tables on gfx950 with FlyDSL 0.5.0 at the final head.

Main is merged in (cc54c94117).

Main now pins FlyDSL 0.5.3, so everything was re-run on 0.5.3 at the final head:

  • Full 960-case bench, PR (02598fa593) vs main (3486e43ba), MI350X, ROCm 7.2.2, torch 2.10.0, Triton 3.8.0. All 960 cases pass grading on both trees.
  • PR vs main FlyDSL: 1.35× (clean_logits=True) and 1.42× (False). PR vs Gluon: 1.57× and 1.42×.
  • The description's tables are updated, including the per-(H, D), long-context and per-window tables.

@vpietila-amd

Copy link
Copy Markdown
Contributor Author

After rebase, mqa_logits() never runs your gfx950 routes, and GLM-5 rows go to Triton

Main now has aiter/mqa_logits.py (#6185). It does not use _auto_variant. It reads the tag from the tuned table and passes it as variant=.... Shapes not in the table use Triton (DEFAULT_CONFIG). Before running FlyDSL, it checks:

if mod is None or variant not in mod.KERNEL_VARIANTS:
    return False

This PR changes KERNEL_VARIANTS on gfx950 to only the routed tags. The GLM-5 table (aiter/configs/model_configs/glm5_tuned_mqa_logits.csv) uses 6 FlyDSL tags, like mfma32x32x64_bkv128_r2_w4_lds3. None of them are in the new list.

So on gfx950, through mqa_logits():

  • GLM-5 FlyDSL rows (24): were FlyDSL on main, now Triton.
  • shapes not in the table: Triton, same as before.
  • your new routes: never used.

Only direct calls to flydsl_fp8_mqa_logits(variant=None) use your routes. Your tests and benchmarks call it that way, so they don't show this.

I checked with main merged into this PR:

  • main: 6/6 tags in KERNEL_VARIANTS, 0 rows go to Triton
  • this PR: 0/6 tags in KERNEL_VARIANTS, 24 rows go to Triton

The table shows Triton is 1.2x to 3.9x slower for these rows. For example, 256x16384: FlyDSL 37.7 us vs Triton 147.8 us.

CI will not catch this. check_dispatches_shipped_row expects Triton when flydsl_supports is False.

All 6 old tags still build with the new grammar. They pass _variant_supports and compile on gfx950 with 0 spills. Only the list check blocks them.

Possible fixes:

  • keep the old tags in KERNEL_VARIANTS, or
  • make flydsl_supports use _variant_supports, or
  • retune the GLM-5 table with your new tags.

To make mqa_logits() use your routes, add tuned rows for them. Also, the tuner (csrc/mqa_logits/mqa_logits_tune.py) loops over KERNEL_VARIANTS, so it now gets fewer candidates. "Breaking Changes: None" should mention this.

Thanks for catching this. After the merge, test_mqa_logits.py passed while the rows labeled FlyDSL ran at Triton speed (1024×8192: 111 µs, against 45 µs for FlyDSL called directly). Fixed in 888cf08fae, 02598fa593 and 68f1e9c625, which combine two of your suggestions:

  • flydsl_supports validates by grammar. A new public variant_supported(tag, num_heads, head_size) replaces the KERNEL_VARIANTS membership test. It accepts any tag that builds on the arch, whose atom tiles the problem, and whose LDS slots and vmcnt fit. The old GLM-5 tags (and any user table with older tags) keep running on FlyDSL.
  • Opt-in router. A row may also name the variant auto, which hands the choice to flydsl_fp8_mqa_logits's route table. Shipped rows keep concrete tags.
  • GLM-5 table re-tuned with mqa_logits_tune.py (MI350X, Triton 3.8.0, FlyDSL 0.5.3). All 24 rows pick FlyDSL with routed tags. Through mqa_logits() that is 1.36× faster than main's code and table (1.25×–1.65×, same machine) and 1.70× faster than Triton/Gluon (geomean). --run_config gives 24/24 within 10%, and the collision guard passes. The per-shape table is in the description.
  • CI guard. test_mqa_logits.py gains check_shipped_flydsl_rows_supported, which asserts that every shipped FlyDSL row for the live GPU passes flydsl_supports. It fails on the state you described, which check_dispatches_shipped_row could not catch.
  • Tuner candidates. The tuner still loops over KERNEL_VARIANTS, which now holds the routed tags plus the large-head fallback. "Breaking Changes" now lists the KERNEL_VARIANTS change, with variant_supported as the replacement for membership checks.

@vpietila-amd

Copy link
Copy Markdown
Contributor Author

Suggestion: keep the default verify smaller

The PR adds many verify cases (mostly from verify_production_variants). Each case compiles and runs a kernel, so CI gets slower.

--scenario verify:

  • main: 95 cases, 34 s
  • this PR (merged with main): 326 cases, 137 s

gfx950 has about 720 production pins, so it will take longer there. .github/split-test-times/aiter.tsv still lists this test at 36 s.

Maybe keep one or two shapes per route in the default verify, and move the full set behind a flag or a separate scenario.

Done in 02598fa593. The default --scenario verify pins each routed variant only at the (num_heads, head_dim) of the routes that use it, with the causal window and both clean_logits values. The head-dim auto-routing check runs at head_dim 512 on 2 shapes.

On gfx950 that is 152 cases in 33 s with FLYDSL_RUNTIME_ENABLE_CACHE=0, against 815 cases in 2 min 36 s before.

The full matrix moved behind --full: every variant × num_heads × head_dim (plus 512) × clean_logits × causal/past_end, and auto-routing at head_dim 256/512/1024. All 1833 cases pass.

@msaffari-amd

Copy link
Copy Markdown
Contributor

LGTM.

Small things, not blocking:

msaffari-amd
msaffari-amd previously approved these changes Dec 1, 2026
@vpietila-amd
vpietila-amd marked this pull request as ready for review December 3, 2026 09:26
@vpietila-amd
vpietila-amd requested a review from a team December 3, 2026 09:26
@github-actions github-actions Bot added the FlyDSL label Dec 3, 2026

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants