Repository navigation
[Triton/Gluon] [gfx1250] DSv4.1 router GEMM (N=384, K=5120): Gluon buckets and bf16 rows for M 576/672/768 - #7663
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
READY FOR HUMAN REVIEWPR Self-ReviewRevision Author self-review accepted. Readiness report: Author answers
Show the author's self-review answersBehavior and intentValidation and unverified scopePR-specific questionChanged op testsPR state
Copilot findings
Code and op-test hygiene
Required CI
Shadow mode reports what would block but keeps the status successful. Set |
There was a problem hiding this comment.
🟡 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
|
Pushed 666bf41 for the Copilot review (replies inline): Gluon buckets aligned to the padded-M ranges the tuned table routes here, The previous Standard Tests (1 GPU) shard 2 failure was |
k50112113
left a comment
There was a problem hiding this comment.
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.
|
@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. |
valarLip
left a comment
There was a problem hiding this comment.
⚠️ Action required before merge (2)
- Run the new N=384, K=5120 Gluon configs on gfx1250 before merge. CI ran only MI35X. There,
test_gemm_a16_w16skips the gluon backend (_is_gluon_available()is False). The 6 new_DSV41_ROUTER_X_VALScases 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-bufferM_LEQ_768revision has not run on gfx1250 at all. Add theci:gfx1250-ffm-tritonlabel, or post a gfx1250pytest op_tests/triton_tests/gemm/basic/test_gemm_a16w16.py -k "384 and 5120"log at bd4e7c3. The CSVusfor M 768 (7.03) was also measured on the 3-buffer config, so refresh it from the same run. - 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.
|
@valarLip thanks, both items are addressed at
|
valarLip
left a comment
There was a problem hiding this comment.
⚠️ Action required before merge (2)
- 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. Theci:gfx1250-ffm-tritonlabel cannot stand in for it.ffm-bringup.yaml:47/57skips PRs from forks, and run 43550828095 shows as skipped. A log atbd4e7c3c1is enough: only three CSV cells changed after it. - 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 revisionmust hold only the SHA (`bc2909652b`). Today it is followed by a sentence, so it failshead_sha.startswith(revision). Move "The only change since bd4e7c3…" into another section.Validation and unverified scopematches 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_CIdoes not exist, so a labeled run would fail at thegit fetchstep (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.
|
Thanks. The PR Self-Review is fixed:
I ran 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. |
|
@k50112113 here is the before/after runtime you asked for. Measured at Config: DeepSeek-V4.1 router GEMM, bf16, N=384, K=5120, TN. Calls go through the production entry
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. |
|
@valarLip here is the gfx1250 log for 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
Full log (gfx1250, head bc29096) |
|
ok the performance is the proof, that's great to know, thanks, approved, please resolve conflicts. |
…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]>
bc29096 to
7818b63
Compare
|
@k50112113 thanks for the approval. Conflicts are resolved and the nit is addressed; head is now
Your latest review is still CHANGES_REQUESTED, which blocks the merge. Could you re-approve when you have a moment? Thanks! |
…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]>
…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]>
… 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]>
…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]>
…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]>
… 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.


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): addM_BOUNDSwith the bucketsM_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_768carry the tuned configs.M_LEQ_768uses two buffers so that every layout fits in LDS.M_LEQ_544,M_LEQ_640,M_LEQ_736repeat the previousM_LEQ_1024config, so the Gluon config only changes for M 545-576, 641-672 and 737-768.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, alltriton/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 768us(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 totest_gemm_a16_w16, which runs the TN layout. The router GEMM only uses TN.PR Self-Review
Reviewed revision
7818b63fb0Behavior and intent
M_LEQ_1024config (BLOCK_K 128), which is not tuned for this N/K.M_LEQ_544/640/736buckets only hold the previousM_LEQ_1024config, so Gluon callers at any other M get the same config as before.Validation and unverified scope
bd4e7c3c1: the M 768us/ 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 replacedget_x_vals()with the sharedget_shapes().test_gemm_a16_w16now runsget_shapes()plus the same six N=384, K=5120 shapes, so the cases of this PR are the same as atbd4e7c3c1.pytest --collect-onlyon the test file (stub Triton target, no GPU) collects exactly 24 more cases than main, alltest_gemm_a16_w16[...-384-5120](six M, gluon/triton, two kernel types); black and ruff pass on the changed test file.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.M_LEQ_768. A 3-bufferM_LEQ_768fails TT and NT with an LDS out-of-resources error, which is why it stays at two buffers.aiter.tuned_gemm.tgemm.mm(which merges the model tuned table), main vs this branch: M 545-576, 641-672 and 737-768 selecttriton; 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 768uscomes from this run.M_BOUNDSwalk 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_BOUNDSmatches theM_LEQ_*keys, CSV column count unchanged, and no other config file has a row with the same key.M_LEQ_768went from three to two buffers (tiles and K-loop accumulation order unchanged). No CI job runs these cases on gfx1250:ci:gfx1250-ffm-tritonis skipped for PRs from forks (head.repomust 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 thegit fetchof the missingshared/reduced_tests_for_FFM_CIref, and after [CI] FFM Triton: fall back to main when the suite source ref is gone #7930 it falls back to main'sop_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?
(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.GEMM-A16W16-N=384-K=5120.jsonon gfx1250, bucketsM_LEQ_576,M_LEQ_672,M_LEQ_768. Any other N/K uses a different JSON, so it is untouched.tgemm.mmrun above (M outside the ranges keep the same FlyDSL rows), and the filler bucketsM_LEQ_544/640/736being byte-identical copies of the previousM_LEQ_1024config.Changed op tests
op_tests/triton_tests/gemm/basic/test_gemm_a16w16.py: the TN-onlytest_gemm_a16_w16parametrizes overget_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 sharedgemm_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