Skip to content

[Triton/Gluon] [gfx1250] DSv4.1 router GEMM (N=384, K=5120): Gluon buckets and bf16 rows for M 576/672/768 - #7663

Merged
valarLip merged 5 commits into
ROCm:mainfrom
yhl-amd:hyi/dsv41-router-gemm-configs
Nov 23, 2026
Merged

valarLip merged 5 commits into
ROCm:mainfrom
yhl-amd:hyi/dsv41-router-gemm-configs

Conversation

@yhl-amd

@yhl-amd yhl-amd commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Router GEMM of DeepSeek-V4.1 (N=384, K=5120, bf16) on gfx1250: tuned Gluon buckets for M 576 / 672 / 768, and the DSv4.1 bf16 tuned table sends those buckets to the Gluon kernel.

Changes

  • GEMM-A16W16-N=384-K=5120.json (gfx1250 Gluon): add M_BOUNDS with the buckets M_LEQ_544, M_LEQ_576, M_LEQ_640, M_LEQ_672, M_LEQ_736, M_LEQ_768.
    • M_LEQ_576, M_LEQ_672, M_LEQ_768 carry the tuned configs. M_LEQ_768 uses two buffers so that every layout fits in LDS.
    • M_LEQ_544, M_LEQ_640, M_LEQ_736 repeat the previous M_LEQ_1024 config, so the Gluon config only changes for M 545-576, 641-672 and 737-768.
    • Every existing bucket (M_LEQ_1 ... M_LEQ_8192, any) is kept as is.
  • dsv41_bf16_tuned_gemm.csv: rows for M 576 and 672 added and the M 768 row replaced in place, all triton / auto. The table looks rows up by padded M (32-row steps in this range), so these rows serve M 545-576, 641-672 and 737-768, the same three ranges as above. Every other M keeps its current backend and kernel. The M 768 us (and the derived tflops / bw) is the gfx1250 measurement of the 2-buffer config.
  • op_tests/triton_tests/gemm/basic/test_gemm_a16w16.py: the lowest and the highest M of each tuned bucket (N=384, K=5120) are added to test_gemm_a16_w16, which runs the TN layout. The router GEMM only uses TN.

PR Self-Review

Reviewed revision

7818b63fb0

Behavior and intent

  • Before: on gfx1250 the DSv4.1 router GEMM (N=384, K=5120, bf16) at the decode widths M 545-576, 641-672 and 737-768 runs the FlyDSL hgemm row (the M 1024 row, or the M 768 row for 737-768). If the table is switched to Triton without new buckets, these M fall into the shared Gluon M_LEQ_1024 config (BLOCK_K 128), which is not tuned for this N/K.
  • After: those three padded-M ranges go to Gluon with dedicated BLOCK_K 512 configs (BLOCK_N 32 for the 576 and 672 buckets, BLOCK_N 64 for the 768 bucket). The three need different BLOCK_N, so they cannot share one power-of-two bucket. The M_LEQ_544/640/736 buckets only hold the previous M_LEQ_1024 config, so Gluon callers at any other M get the same config as before.
  • No new environment variable and no code change; the change is limited to one Gluon JSON, one model tuned table and one test list.

Validation and unverified scope

  • Since bd4e7c3c1: the M 768 us / tflops / bw cells of the tuned table, a rebase onto main, and the test shape list. The rebase did not touch the Gluon JSON or the tuned-table rows of this PR (main changed neither the JSON nor any gfx1250 row of the table); the only conflict was the test file, where [Triton/Gluon] Unify get_shapes for GEMMs #8214 replaced get_x_vals() with the shared get_shapes(). test_gemm_a16_w16 now runs get_shapes() plus the same six N=384, K=5120 shapes, so the cases of this PR are the same as at bd4e7c3c1.
  • CPU at this head: pytest --collect-only on the test file (stub Triton target, no GPU) collects exactly 24 more cases than main, all test_gemm_a16_w16[...-384-5120] (six M, gluon/triton, two kernel types); black and ruff pass on the changed test file.
  • On gfx1250 at bd4e7c3c1 (same JSON, same table keys and the same N=384, K=5120 test cases as this head):
    • pytest op_tests/triton_tests/gemm/basic/test_gemm_a16w16.py -k "384 and 5120": all Gluon cases pass. The plain-Triton backend cases skip on gfx1250 by design, as on main.
    • Layout check: M 576 / 672 / 768 compile and run in TN, TT, NN and NT with the 2-buffer M_LEQ_768. A 3-buffer M_LEQ_768 fails TT and NT with an LDS out-of-resources error, which is why it stays at two buffers.
    • Through the production entry aiter.tuned_gemm.tgemm.mm (which merges the model tuned table), main vs this branch: M 545-576, 641-672 and 737-768 select triton; M 512, 577, 700, 769 and 1024 keep their FlyDSL rows. Error against an fp32 reference is the same as main at every tested M. The new M 768 us comes from this run.
  • Earlier revision of the buckets on gfx1250: router outputs within bf16 rounding of the previous kernel, the same experts selected downstream on real gate weights, and DeepSeek-V4.1-Flash served end to end with GSM8K in line with the baseline.
  • CPU, main vs this head: tuned-table lookup with padded M plus M_BOUNDS walk for every M from 1 to 8192 of this shape; backend, kernel and Gluon config change for exactly M 545-576, 641-672 and 737-768. JSON parses, M_BOUNDS matches the M_LEQ_* keys, CSV column count unchanged, and no other config file has a row with the same key.
  • Unverified: the end-to-end serving run was not repeated after M_LEQ_768 went from three to two buffers (tiles and K-loop accumulation order unchanged). No CI job runs these cases on gfx1250: ci:gfx1250-ffm-triton is skipped for PRs from forks (head.repo must be ROCm/aiter). Even for a same-repo branch it would not run this PR's tests: on this branch's base the workflow fails at the git fetch of the missing shared/reduced_tests_for_FFM_CI ref, and after [CI] FFM Triton: fall back to main when the suite source ref is gone #7930 it falls back to main's op_tests/triton_tests, which lacks the new shapes. The gfx1250 evidence is the manual run above, whose pytest log is posted on the PR; it was not repeated after the rebase, which changed only the test parametrization source and no config.

PR-specific question

Which exact workload keys consume these configuration changes, and what evidence shows that unrelated shapes keep their previous selection?

  • Tuned table: key (gfx1250, cu_num 256, M, N 384, K 5120, bias False, bf16 -> bf16, scaleAB False, bpreshuffle False) with padded M 576, 672 and 768, i.e. real M 545-576, 641-672 and 737-768. In DeepSeek-V4.1 this is the MoE router GEMM at decode batch sizes whose speculative-decode row count lands in these ranges.
  • Gluon JSON: GEMM-A16W16-N=384-K=5120.json on gfx1250, buckets M_LEQ_576, M_LEQ_672, M_LEQ_768. Any other N/K uses a different JSON, so it is untouched.
  • Evidence that other shapes keep their selection: the CPU walk over M 1..8192 above (only those three ranges differ from main), the gfx1250 tgemm.mm run above (M outside the ranges keep the same FlyDSL rows), and the filler buckets M_LEQ_544/640/736 being byte-identical copies of the previous M_LEQ_1024 config.

Changed op tests

  • op_tests/triton_tests/gemm/basic/test_gemm_a16w16.py: the TN-only test_gemm_a16_w16 parametrizes over get_shapes() plus N=384, K=5120 at M 545 / 576 / 641 / 672 / 737 / 768 (the lowest and highest M of each new bucket), listed inline with no separate constant. It covers the new Gluon buckets end to end (compile, LDS fit and output against the reference) at both edges of each padded-M range. No existing case uses N=384, K=5120 or any M in these ranges, so without it CI never builds the new configs. The shapes are kept in this file rather than in the shared gemm_shapes.py, which every GEMM test uses and whose docstring keeps config-specific shapes in the kernel's own test file.

🤖 Generated with Claude Code

@yhl-amd
yhl-amd requested a review from a team November 9, 2026 15:07
@github-actions

github-actions Bot commented Nov 9, 2026

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 7663 --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.

@aiter-bot

aiter-bot commented Nov 9, 2026 •

Copy link
Copy Markdown

READY FOR HUMAN REVIEW

PR Self-Review

Revision 7818b63fb01a · 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

- Before: on gfx1250 the DSv4.1 router GEMM (N=384, K=5120, bf16) at the decode widths M 545-576, 641-672 and 737-768 runs the FlyDSL hgemm row (the M 1024 row, or the M 768 row for 737-768). If the table is switched to Triton without new buckets, these M fall into the shared Gluon `M_LEQ_1024` config (BLOCK_K 128), which is not tuned for this N/K.
- After: those three padded-M ranges go to Gluon with dedicated BLOCK_K 512 configs (BLOCK_N 32 for the 576 and 672 buckets, BLOCK_N 64 for the 768 bucket). The three need different BLOCK_N, so they cannot share one power-of-two bucket. The `M_LEQ_544/640/736` buckets only hold the previous `M_LEQ_1024` config, so Gluon callers at any other M get the same config as before.
- No new environment variable and no code change; the change is limited to one Gluon JSON, one model tuned table and one test list.

Validation and unverified scope

- Since `bd4e7c3c1`: the M 768 `us` / tflops / bw cells of the tuned table, a rebase onto main, and the test shape list. The rebase did not touch the Gluon JSON or the tuned-table rows of this PR (main changed neither the JSON nor any gfx1250 row of the table); the only conflict was the test file, where #8214 replaced `get_x_vals()` with the shared `get_shapes()`. `test_gemm_a16_w16` now runs `get_shapes()` plus the same six N=384, K=5120 shapes, so the cases of this PR are the same as at `bd4e7c3c1`.
- CPU at this head: `pytest --collect-only` on the test file (stub Triton target, no GPU) collects exactly 24 more cases than main, all `test_gemm_a16_w16[...-384-5120]` (six M, gluon/triton, two kernel types); black and ruff pass on the changed test file.
- On gfx1250 at `bd4e7c3c1` (same JSON, same table keys and the same N=384, K=5120 test cases as this head):
  - `pytest op_tests/triton_tests/gemm/basic/test_gemm_a16w16.py -k "384 and 5120"`: all Gluon cases pass. The plain-Triton backend cases skip on gfx1250 by design, as on main.
  - Layout check: M 576 / 672 / 768 compile and run in TN, TT, NN and NT with the 2-buffer `M_LEQ_768`. A 3-buffer `M_LEQ_768` fails TT and NT with an LDS out-of-resources error, which is why it stays at two buffers.
  - Through the production entry `aiter.tuned_gemm.tgemm.mm` (which merges the model tuned table), main vs this branch: M 545-576, 641-672 and 737-768 select `triton`; M 512, 577, 700, 769 and 1024 keep their FlyDSL rows. Error against an fp32 reference is the same as main at every tested M. The new M 768 `us` comes from this run.
- Earlier revision of the buckets on gfx1250: router outputs within bf16 rounding of the previous kernel, the same experts selected downstream on real gate weights, and DeepSeek-V4.1-Flash served end to end with GSM8K in line with the baseline.
- CPU, main vs this head: tuned-table lookup with padded M plus `M_BOUNDS` walk for every M from 1 to 8192 of this shape; backend, kernel and Gluon config change for exactly M 545-576, 641-672 and 737-768. JSON parses, `M_BOUNDS` matches the `M_LEQ_*` keys, CSV column count unchanged, and no other config file has a row with the same key.
- Unverified: the end-to-end serving run was not repeated after `M_LEQ_768` went from three to two buffers (tiles and K-loop accumulation order unchanged). No CI job runs these cases on gfx1250: `ci:gfx1250-ffm-triton` is skipped for PRs from forks (`head.repo` must be ROCm/aiter). Even for a same-repo branch it would not run this PR's tests: on this branch's base the workflow fails at the `git fetch` of the missing `shared/reduced_tests_for_FFM_CI` ref, and after #7930 it falls back to main's `op_tests/triton_tests`, which lacks the new shapes. The gfx1250 evidence is the manual run above, whose pytest log is posted on the PR; it was not repeated after the rebase, which changed only the test parametrization source and no config.

PR-specific question

Which exact workload keys consume these configuration changes, and what evidence shows that unrelated shapes keep their previous selection?

- Tuned table: key `(gfx1250, cu_num 256, M, N 384, K 5120, bias False, bf16 -> bf16, scaleAB False, bpreshuffle False)` with padded M 576, 672 and 768, i.e. real M 545-576, 641-672 and 737-768. In DeepSeek-V4.1 this is the MoE router GEMM at decode batch sizes whose speculative-decode row count lands in these ranges.
- Gluon JSON: `GEMM-A16W16-N=384-K=5120.json` on gfx1250, buckets `M_LEQ_576`, `M_LEQ_672`, `M_LEQ_768`. Any other N/K uses a different JSON, so it is untouched.
- Evidence that other shapes keep their selection: the CPU walk over M 1..8192 above (only those three ranges differ from main), the gfx1250 `tgemm.mm` run above (M outside the ranges keep the same FlyDSL rows), and the filler buckets `M_LEQ_544/640/736` being byte-identical copies of the previous `M_LEQ_1024` config.

Changed op tests

- `op_tests/triton_tests/gemm/basic/test_gemm_a16w16.py`: the TN-only `test_gemm_a16_w16` parametrizes over `get_shapes()` plus N=384, K=5120 at M 545 / 576 / 641 / 672 / 737 / 768 (the lowest and highest M of each new bucket), listed inline with no separate constant. It covers the new Gluon buckets end to end (compile, LDS fit and output against the reference) at both edges of each padded-M range. No existing case uses N=384, K=5120 or any M in these ranges, so without it CI never builds the new configs. The shapes are kept in this file rather than in the shared `gemm_shapes.py`, which every GEMM test uses and whose docstring keeps config-specific shapes in the kernel's own test file.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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
  • ADVISORY — an author-replied Copilot finding is still unresolved; confirm the disposition during human review

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
  • PASS — Aiter Test Gate: passed

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

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.

🟡 Changes recommended

The tuned configuration exceeds gfx1250’s LDS limit for a supported layout, and overly broad matching changes routing and configurations for unintended neighboring shapes.

3 open issues
What changed in this PR

This PR tunes the DeepSeek-V4.1 bf16 router GEMM (N=384, K=5120) on gfx1250 and updates model-specific dispatch for M=576, 672, and 768.

Changes:

  • Add three Gluon tuning buckets and explicit M_BOUNDS.
  • Add dispatch rows for M=576 and 672, and switch M=768 from FlyDSL to triton / auto.
File Description
aiter/​ops/​triton/​configs/​gfx1250/​gluon/​gemm/​gemm_a16w16/​GEMM-A16W16-N=384-K=5120.json Adds router GEMM tuning buckets and bounds.
aiter/​configs/​model_configs/​dsv41_bf16_tuned_gemm.csv Updates backend selection and timing data for the three target sizes.

Review effort: Balanced

@zufayu
zufayu requested review from a team and k50112113 November 10, 2026 01:22
@github-actions github-actions Bot changed the title [Triton/Gluon] [Config] [gfx1250] DSv4.1 router GEMM (N=384, K=5120): Gluon buckets and bf16 rows for M 576/672/768 [Triton/Gluon] [gfx1250] DSv4.1 router GEMM (N=384, K=5120): Gluon buckets and bf16 rows for M 576/672/768 Nov 10, 2026
@github-actions github-actions Bot removed the Config label Nov 10, 2026
@yhl-amd

yhl-amd commented Nov 10, 2026

Copy link
Copy Markdown
Contributor Author

Pushed 666bf41 for the Copilot review (replies inline): Gluon buckets aligned to the padded-M ranges the tuned table routes here, M_LEQ_768 fits LDS in all four layouts, and a gfx1250 layout test. Description updated.

The previous Standard Tests (1 GPU) shard 2 failure was op_tests/test_flydsl_hgemm.py ("graph replay mismatch" on a split-K case, gfx950). It is not related to this PR (gfx1250 config files only): the same shard passed on main at the same base (main run), and #7664, which touches only gfx1250 MegaMoE files, hit the same test at a different case in the same window (#7664 run). The new push re-runs CI.

@k50112113 k50112113 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.

Can you provide before/after runtime (us) comparison? Non-power-of-2 bucket can be added but only with a strong reason to do so, e.g. huge performance gap.

@k50112113

Copy link
Copy Markdown
Contributor

@yhl-amd Can you provide before/after runtime (us) comparison? Non-power-of-2 bucket can be added but only with a strong reason to do so, e.g. huge performance gap.

@zufayu
zufayu requested review from a team and removed request for a team November 13, 2026 01:49
@valarLip valarLip added the ci:gfx1250-ffm-triton Run gfx1250 FFM tests label Nov 14, 2026

@valarLip valarLip left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

⚠️ Action required before merge (2)

  1. Run the new N=384, K=5120 Gluon configs on gfx1250 before merge. CI ran only MI35X. There, test_gemm_a16_w16 skips the gluon backend (_is_gluon_available() is False). The 6 new _DSV41_ROUTER_X_VALS cases run only through the gfx950 triton path, so none of the JSON buckets added here has run in CI. The description also says the 2-buffer M_LEQ_768 revision has not run on gfx1250 at all. Add the ci:gfx1250-ffm-triton label, or post a gfx1250 pytest op_tests/triton_tests/gemm/basic/test_gemm_a16w16.py -k "384 and 5120" log at bd4e7c3. The CSV us for M 768 (7.03) was also measured on the 3-buffer config, so refresh it from the same run.
  2. Fill in the PR Self-Review sections. aiter-bot reports all five sections missing (Reviewed revision, Behavior and intent, Validation and unverified scope, PR-specific question, Changed op tests). Most of the content is already in the description; move it under those headings and name the head SHA.

Checked on CPU (getPaddedM port + M_BOUNDS walk, M 1..8192, base vs head): the backend and the Gluon config change for exactly M 545-576, 641-672 and 737-768. Inside each range cdiv(M, 32) is constant (18 / 21 / 24). The padded-LDS estimate for the new M_LEQ_768 is ≤ 245,760 B in TN/TT/NN/NT. The old 3-buffer config needed 345,600 B in TT, over the 327,680 B limit, which matches Copilot's finding. Copilot's 3 threads and k50112113's test-placement comment are addressed at head.


Reviewed at bd4e7c3. Already fixed: Copilot LDS overflow for M_LEQ_768 (now 2 buffers), Gluon config limited to the padded-M ranges via M_LEQ_544/640/736, separate DSv4.1 layout test folded into the TN-only test_gemm_a16_w16.

@yhl-amd

yhl-amd commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor Author

@valarLip thanks, both items are addressed at bc2909652b.

  1. gfx1250 run / M 768 timing. The ci:gfx1250-ffm-triton label is on, but it will not exercise these cases: in ffm-bringup.yaml the job only runs when the PR head branch lives in ROCm/aiter (this one is from a fork, so the labeled run was skipped), and it replaces op_tests/triton_tests with the reduced suite ref (currently missing, so main's tree), which does not have the new _DSV41_ROUTER_X_VALS. So here is the gfx1250 run instead: I ran pytest op_tests/triton_tests/gemm/basic/test_gemm_a16w16.py -k "384 and 5120" on gfx1250 at bd4e7c3c1: all Gluon cases pass (the plain-Triton backend cases skip on gfx1250 by design). In the same session the 2-buffer M_LEQ_768 compiled and ran in all four layouts, and tgemm.mm picked triton for exactly M 545-576 / 641-672 / 737-768 while M 512 / 577 / 700 / 769 / 1024 kept their FlyDSL rows. New commit bc2909652b replaces the M 768 us (and the derived tflops / bw) with the value measured in that run on the 2-buffer config. Only those three cells change; the row key, backend and kernel stay the same, and no other config file has this key, so the merge-time dedup is not affected. If you want the full pytest log rather than this summary, I can post one from a gfx1250 run at this head.
  2. Self-Review. The description now has ## PR Self-Review with Reviewed revision (bc2909652b), Behavior and intent, Validation and unverified scope, PR-specific question (the exact tuned-table / Gluon-bucket keys and the evidence that other M keep their selection) and Changed op tests.

@valarLip valarLip left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

⚠️ Action required before merge (2)

  1. Post the gfx1250 pytest op_tests/triton_tests/gemm/basic/test_gemm_a16w16.py -k "384 and 5120" log you offered. The reply gives a summary, but no log is posted. The ci:gfx1250-ffm-triton label cannot stand in for it. ffm-bringup.yaml:47/57 skips PRs from forks, and run 43550828095 shows as skipped. A log at bd4e7c3c1 is enough: only three CSV cells changed after it.
  2. Fix the Self-Review so aiter-bot passes. Both FAILs in the bot comment are real; I re-applied its checks to this description on CPU.
    • ### Reviewed revision must hold only the SHA (`bc2909652b`). Today it is followed by a sentence, so it fails head_sha.startswith(revision). Move "The only change since bd4e7c3…" into another section.
    • Validation and unverified scope matches none of the bot's keywords (unverified, not tested, not run, …). "Not verified:" does not count; change it to "Unverified:".
    • While editing, fix the FFM sentence. shared/reduced_tests_for_FFM_CI does not exist, so a labeled run would fail at the git fetch step (set -euo pipefail). It would not fall back to main's tree.

Checked at head: the M 768 row is now 6.59 us. Its tflops and bw cells match the formula: 2·M·N·K/t = 458.25 TFLOPS and (MK+NK+MN)·2/t = 1879.56 GB/s. The row was 9.06 us on flydsl. On current main the PR merges cleanly and has no duplicate CSV key. The gfx1250 Gluon gemm_a16w16 change on main (#7289) only touches the compute_bound epilogue. These buckets are all bandwidth_bound, so the LDS fit checked last round still holds. k50112113's CHANGES_REQUESTED review (before/after us, reason for the non-power-of-2 buckets) is still unanswered and blocks merge on its own.


Re-reviewed at bc29096. Already fixed: M 768 us/tflops/bw refreshed for the 2-buffer config; Self-Review sections added; earlier: Copilot LDS overflow (2 buffers), Gluon config limited to the padded-M ranges, DSv4.1 test folded into the TN-only test_gemm_a16_w16.

@yhl-amd

yhl-amd commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

Thanks. The PR Self-Review is fixed:

  • ### Reviewed revision now holds only `bc2909652b`. The "only change since bd4e7c3c1" sentence moved to the validation section.
  • The limitation line now starts with "Unverified:".
  • The FFM sentence is corrected. The job is skipped for fork PRs. At this branch's base it would fail at the git fetch of the missing shared/reduced_tests_for_FFM_CI ref. Since [CI] FFM Triton: fall back to main when the suite source ref is gone #7930 on main it falls back to main's op_tests/triton_tests, which does not have these shapes either.

I ran .github/scripts/pr_self_review.py's validate_author_answers locally against the new description and head: no findings. The bot comment will refresh on its next run.

The gfx1250 pytest log is still open. I don't have a gfx1250 machine right now, so I will post it here once I do. k50112113's questions are also still open.

@yhl-amd

yhl-amd commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

@k50112113 here is the before/after runtime you asked for.

Measured at bd4e7c3c1, on gfx1250. The only change since then is bc2909652, which updates the recorded timing cells of the M 768 row in dsv41_bf16_tuned_gemm.csv. That row keeps the same backend and config, so the kernel that runs is the same.

Config: DeepSeek-V4.1 router GEMM, bf16, N=384, K=5120, TN. Calls go through the production entry tgemm.mm, so the model_configs CSV merge and dispatch are included. Timed with hipGraph replay, before and after interleaved, median of 5 rounds.

M backend before -> after after vs before
576 FlyDSL -> Gluon -17%
672 FlyDSL -> Gluon -14%
768 FlyDSL -> Gluon -28%
512, 577, 700, 769, 1024 (outside the buckets) FlyDSL, unchanged within +/-0.5% (noise)

Why the non-power-of-2 buckets. If these rows switch to Gluon but keep the default power-of-2 Gluon buckets, we get only part of the gain. With the new buckets, the kernels are another 14% (576), 9% (672) and 14% (768) faster than with the CSV change alone. That gap is what the buckets buy.

Neighbouring M. The padded-row lookup also sends M 545-575, 641-671 and 737-767 to these rows. I measured the edges of those ranges (545, 641, 737, 767). All of them are faster than before (-14% to -27%), and none regresses.

768 bucket: 3 buffers vs 2. With 3 buffers, TN gets only about 1-3% faster, and the TT and NT layouts fail to compile because they need more LDS than gfx1250 has. With 2 buffers, all four layouts compile and pass, so the bucket keeps 2 buffers.

Tests on gfx1250. op_tests/triton_tests/gemm/basic/test_gemm_a16w16.py -k "384 and 5120" (the new M 545/576/641/672/737/768 in the TN-only test) passes before and after: 12 passed. The 12 skips are the Triton backend, which has no gfx1250 config. The Gluon kernel also passes the TN/TT/NN/NT layouts at M = 576/672/768. Relative to an fp32 reference, tgemm.mm has the same error per M before and after.

@yhl-amd

yhl-amd commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

@valarLip here is the gfx1250 log for pytest op_tests/triton_tests/gemm/basic/test_gemm_a16w16.py -k "384 and 5120" -v. It ran at the current head bc2909652b (since bd4e7c3c1, only the three cells of the M 768 CSV row changed), on one gfx1250 GPU, with the tree checked out at that SHA.

12 passed, 12 skipped. All 12 Gluon cases pass: M = 545, 576, 641, 672, 737 and 768 (the three new padded-M buckets and their edges, including the 2-buffer M_LEQ_768), each for bandwidth_bound and compute_bound. The 12 skips are the test's own gfx1250 rules (-rs):

  • 6 × "triton backend has no gfx1250 a16w16 config (gluon-only arch)"
  • 6 × "kernel_type only applies to the gluon backend"
Full log (gfx1250, head bc29096)
### tree h7663 sha bc2909652  gpu-arch gfx1250  date 2026-11-17T05:47:58Z
### cmd: python3 -m pytest -p no:cacheprovider op_tests/triton_tests/gemm/basic/test_gemm_a16w16.py -k 384 and 5120 -v
============================= test session starts ==============================
platform linux -- Python 3.12.3, pytest-9.0.3, pluggy-1.6.0 -- /usr/local/bin/python3
rootdir: /w/t/h7663
configfile: pyproject.toml
plugins: anyio-4.14.2, dash-3.1.1, timeout-2.4.0
collecting ... collected 1045 items / 1021 deselected / 24 selected

op_tests/triton_tests/gemm/basic/test_gemm_a16w16.py::test_gemm_a16_w16[bandwidth_bound-triton-545-384-5120] SKIPPED [  4%]
op_tests/triton_tests/gemm/basic/test_gemm_a16w16.py::test_gemm_a16_w16[bandwidth_bound-triton-576-384-5120] SKIPPED [  8%]
op_tests/triton_tests/gemm/basic/test_gemm_a16w16.py::test_gemm_a16_w16[bandwidth_bound-triton-641-384-5120] SKIPPED [ 12%]
op_tests/triton_tests/gemm/basic/test_gemm_a16w16.py::test_gemm_a16_w16[bandwidth_bound-triton-672-384-5120] SKIPPED [ 16%]
op_tests/triton_tests/gemm/basic/test_gemm_a16w16.py::test_gemm_a16_w16[bandwidth_bound-triton-737-384-5120] SKIPPED [ 20%]
op_tests/triton_tests/gemm/basic/test_gemm_a16w16.py::test_gemm_a16_w16[bandwidth_bound-triton-768-384-5120] SKIPPED [ 25%]
op_tests/triton_tests/gemm/basic/test_gemm_a16w16.py::test_gemm_a16_w16[bandwidth_bound-gluon-545-384-5120] PASSED [ 29%]
op_tests/triton_tests/gemm/basic/test_gemm_a16w16.py::test_gemm_a16_w16[bandwidth_bound-gluon-576-384-5120] PASSED [ 33%]
op_tests/triton_tests/gemm/basic/test_gemm_a16w16.py::test_gemm_a16_w16[bandwidth_bound-gluon-641-384-5120] PASSED [ 37%]
op_tests/triton_tests/gemm/basic/test_gemm_a16w16.py::test_gemm_a16_w16[bandwidth_bound-gluon-672-384-5120] PASSED [ 41%]
op_tests/triton_tests/gemm/basic/test_gemm_a16w16.py::test_gemm_a16_w16[bandwidth_bound-gluon-737-384-5120] PASSED [ 45%]
op_tests/triton_tests/gemm/basic/test_gemm_a16w16.py::test_gemm_a16_w16[bandwidth_bound-gluon-768-384-5120] PASSED [ 50%]
op_tests/triton_tests/gemm/basic/test_gemm_a16w16.py::test_gemm_a16_w16[compute_bound-triton-545-384-5120] SKIPPED [ 54%]
op_tests/triton_tests/gemm/basic/test_gemm_a16w16.py::test_gemm_a16_w16[compute_bound-triton-576-384-5120] SKIPPED [ 58%]
op_tests/triton_tests/gemm/basic/test_gemm_a16w16.py::test_gemm_a16_w16[compute_bound-triton-641-384-5120] SKIPPED [ 62%]
op_tests/triton_tests/gemm/basic/test_gemm_a16w16.py::test_gemm_a16_w16[compute_bound-triton-672-384-5120] SKIPPED [ 66%]
op_tests/triton_tests/gemm/basic/test_gemm_a16w16.py::test_gemm_a16_w16[compute_bound-triton-737-384-5120] SKIPPED [ 70%]
op_tests/triton_tests/gemm/basic/test_gemm_a16w16.py::test_gemm_a16_w16[compute_bound-triton-768-384-5120] SKIPPED [ 75%]
op_tests/triton_tests/gemm/basic/test_gemm_a16w16.py::test_gemm_a16_w16[compute_bound-gluon-545-384-5120] PASSED [ 79%]
op_tests/triton_tests/gemm/basic/test_gemm_a16w16.py::test_gemm_a16_w16[compute_bound-gluon-576-384-5120] PASSED [ 83%]
op_tests/triton_tests/gemm/basic/test_gemm_a16w16.py::test_gemm_a16_w16[compute_bound-gluon-641-384-5120] PASSED [ 87%]
op_tests/triton_tests/gemm/basic/test_gemm_a16w16.py::test_gemm_a16_w16[compute_bound-gluon-672-384-5120] PASSED [ 91%]
op_tests/triton_tests/gemm/basic/test_gemm_a16w16.py::test_gemm_a16_w16[compute_bound-gluon-737-384-5120] PASSED [ 95%]
op_tests/triton_tests/gemm/basic/test_gemm_a16w16.py::test_gemm_a16_w16[compute_bound-gluon-768-384-5120] PASSED [100%]

=============== 12 passed, 12 skipped, 1021 deselected in 5.18s ================
### rc=0 end 2026-11-17T05:48:05Z

@k50112113

Copy link
Copy Markdown
Contributor

ok the performance is the proof, that's great to know, thanks, approved, please resolve conflicts.

yhl-amd and others added 5 commits November 21, 2026 09:45
…576/672/768

Add M_LEQ_576/672/768 buckets (and the matching M_BOUNDS) to the gfx1250
Gluon a16w16 config for N=384, K=5120, keeping every existing bucket, and
route M 576 and 672 (new rows) and 768 (row replaced in place) of the DSv4.1
bf16 tuned table to triton for this shape. Other M keep their current
backend.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t LDS for all layouts

The DSv4.1 bf16 tuned table looks rows up by padded M, so the M 576 / 672 /
768 rows serve M 545-576, 641-672 and 737-768. Add M_LEQ_544 / 640 / 736
buckets that keep the previous config, so the Gluon config changes for
exactly those three ranges and every other M of this shape resolves as
before.

The M_LEQ_768 bucket used three buffers, which only fits in LDS for the TN
and NN layouts; use two buffers (same tiles, same K loop) so TT and NT fit
as well. Add a gfx1250 layout test that covers the lowest and highest M of
each tuned bucket in all four layouts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The router GEMM only uses the TN layout. Remove the separate
layout test and add the tuned bucket edges of N=384, K=5120 to
test_gemm_a16_w16, which runs the default TN layout.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The M_LEQ_768 Gluon bucket was changed to 2 buffers so it fits LDS in
every layout, but the tuned-GEMM row still carried the timing measured on
the earlier 3-buffer config. Replace it (and the derived tflops/bw) with
the value measured on gfx1250 at the current 2-buffer config.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Drop the separate shape constant. test_gemm_a16_w16 (TN only) now
parametrizes over get_shapes() plus the N=384, K=5120 shapes, the lowest
and the highest M of each tuned gfx1250 Gluon bucket.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@yhl-amd
yhl-amd force-pushed the hyi/dsv41-router-gemm-configs branch from bc29096 to 7818b63 Compare November 21, 2026 01:52
@yhl-amd

yhl-amd commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

@k50112113 thanks for the approval. Conflicts are resolved and the nit is addressed; head is now 7818b63fb.

  • Rebase onto main (df3e0b2f6): the only conflict was op_tests/triton_tests/gemm/basic/test_gemm_a16w16.py, where [Triton/Gluon] Unify get_shapes for GEMMs #8214 replaced get_x_vals() with the shared get_shapes(); I kept main's version and re-applied this PR's shapes on top of it. The Gluon JSON GEMM-A16W16-N=384-K=5120.json and the gfx1250 rows of dsv41_bf16_tuned_gemm.csv merged without conflict and are byte-identical to the previous head (main changed neither the JSON nor any gfx1250 row; its only change in that CSV is a gfx950 row). No other config file has a row with the same keys.
  • Nit (commit 7818b63fb): dropped _DSV41_ROUTER_X_VALS; test_gemm_a16_w16 (TN only) now uses get_shapes() plus the six N=384, K=5120 shapes inline. Details in the inline thread.
  • Checks on CPU: black 26.10.1 and ruff 0.16.0 pass on the test file; pytest --collect-only collects exactly the same 24 N=384, K=5120 cases of test_gemm_a16_w16 as before, on top of main's cases.
  • gfx1250: the rebase changed only the config merge and the test parametrization, not any config or test case, so the gfx1250 results already posted (issuecomment-6940262206 at bc2909652) still apply; I did not rerun on gfx1250.

Your latest review is still CHANGES_REQUESTED, which blocks the merge. Could you re-approve when you have a moment? Thanks!

yhl-amd added a commit to yhl-amd/aiter that referenced this pull request Nov 21, 2026
…1344 / 1536

The DSv4.1 router GEMM at the high-concurrency decode widths (M 1344 and
1536 rows with speculative tokens) had no exact bf16 row and ran the
default selection. Add Gluon a16w16 buckets M_LEQ_1344 (32x64x256, 4
buffers) and M_LEQ_1536 (64x64x256, 4 buffers) to the N=384, K=5120 config,
and the two bf16 rows that select Gluon at those M. The logits are bit
identical to the previous kernel; the other buckets are unchanged.

The a16w16 test covers the edges of the two new buckets.

Depends on ROCm#7663 (M_BOUNDS and the M 576 / 672 / 768 buckets of the same
file); this branch carries its commits until it merges.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@valarLip
valarLip merged commit a91a5ba into ROCm:main Nov 23, 2026
96 of 98 checks passed
yhl-amd added a commit to yhl-amd/aiter that referenced this pull request Nov 23, 2026
…1344 / 1536

The DSv4.1 router GEMM at the high-concurrency decode widths (M 1344 and
1536 rows with speculative tokens) had no exact bf16 row and ran the
default selection. Add Gluon a16w16 buckets M_LEQ_1344 (32x64x256, 4
buffers) and M_LEQ_1536 (64x64x256, 4 buffers) to the N=384, K=5120 config,
and the two bf16 rows that select Gluon at those M. The logits are bit
identical to the previous kernel; the other buckets are unchanged.

The a16w16 test covers the edges of the two new buckets.

Depends on ROCm#7663 (M_BOUNDS and the M 576 / 672 / 768 buckets of the same
file); this branch carries its commits until it merges.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
XiaobingSuper added a commit to xytpai/aiter that referenced this pull request Nov 24, 2026
… K=5120 router shapes

main (ROCm#7663) moved M=576/672/768, N=384, K=5120 to Triton rows. The M=768 row
this PR had retuned is superseded by main's row; the other retuned rows are
unchanged.

Co-Authored-By: Claude Code <[email protected]>
yhl-amd added a commit to yhl-amd/aiter that referenced this pull request Nov 26, 2026
…1344 / 1536

The DSv4.1 router GEMM at the high-concurrency decode widths (M 1344 and
1536 rows with speculative tokens) had no exact bf16 row and ran the
default selection. Add Gluon a16w16 buckets M_LEQ_1344 (32x64x256, 4
buffers) and M_LEQ_1536 (64x64x256, 4 buffers) to the N=384, K=5120 config,
and the two bf16 rows that select Gluon at those M. The logits are bit
identical to the previous kernel; the other buckets are unchanged.

Builds on ROCm#7663 (M_BOUNDS and the M 576 / 672 / 768 buckets of the same
file), which is in main. No op test is added: ROCm#8036 trimmed the router
shapes from the a16w16 test to keep the shard within its time limit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
yhl-amd added a commit to yhl-amd/aiter that referenced this pull request Nov 27, 2026
…1344 / 1536

The DSv4.1 router GEMM at the high-concurrency decode widths (M 1344 and
1536 rows with speculative tokens) had no exact bf16 row and ran the
default selection. Add Gluon a16w16 buckets M_LEQ_1344 (32x64x256, 4
buffers) and M_LEQ_1536 (64x64x256, 4 buffers) to the N=384, K=5120 config,
and the two bf16 rows that select Gluon at those M. The logits are bit
identical to the previous kernel; the other buckets are unchanged.

Builds on ROCm#7663 (M_BOUNDS and the M 576 / 672 / 768 buckets of the same
file), which is in main. No op test is added: ROCm#8036 trimmed the router
shapes from the a16w16 test to keep the shard within its time limit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
azaidy pushed a commit that referenced this pull request Nov 30, 2026
… Gluon buckets and bf16 rows for M 1344 / 1536 (on #7663) (#8049)

* dsv41 router GEMM (N=384, K=5120): Gluon buckets and bf16 rows for M 1344 / 1536

The DSv4.1 router GEMM at the high-concurrency decode widths (M 1344 and
1536 rows with speculative tokens) had no exact bf16 row and ran the
default selection. Add Gluon a16w16 buckets M_LEQ_1344 (32x64x256, 4
buffers) and M_LEQ_1536 (64x64x256, 4 buffers) to the N=384, K=5120 config,
and the two bf16 rows that select Gluon at those M. The logits are bit
identical to the previous kernel; the other buckets are unchanged.

Builds on #7663 (M_BOUNDS and the M 576 / 672 / 768 buckets of the same
file), which is in main. No op test is added: #8036 trimmed the router
shapes from the a16w16 test to keep the shard within its time limit.

* dsv41 router GEMM: record the bw column of the M 1344 / 1536 rows in GB/s

The two bf16 rows added for M 1344 and 1536 stored the bandwidth column in
TB/s, while the rest of the table (and BaseTuner.calculate) use GB/s.
Convert the two cells from the recorded time with the same formula; the
kernel selection and the other columns are unchanged.
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