Skip to content

[HIP] [gfx1250] topk_gating: E=384 single-wave kernel at every token count - #8056

Merged
valarLip merged 2 commits into
ROCm:mainfrom
yhl-amd:hyi/topk-gating-384-vwave-2048
Nov 23, 2026
Merged

valarLip merged 2 commits into
ROCm:mainfrom
yhl-amd:hyi/topk-gating-384-vwave-2048

Conversation

@yhl-amd

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

Copy link
Copy Markdown
Contributor

Motivation

On gfx1250 the E=384 topk_gating single-wave kernel from #7922 (WPT=2) was dispatched only up to 1024 tokens; above that, E=384 fell to prefill_n (TPW=1), which is slower there. The 1025+ range is the DSv4.1 decode width once speculative-decoding verify rows are counted at high concurrency (several hundred requests times the verify width), plus prefill chunks.

#7922 (the single-wave kernel) is merged; this branch is current main plus the commits of this PR.

Technical Details

  • topk_gating_launch: on gfx1250 (topk_gating_vwave_arch()), the E=384, topk <= 8 single-wave dispatch (_DISPATCH_WAVE32_VWAVE_KERNEL(384, 2)) no longer has a token bound. The kernel runs one wave per token with no cross-token work, so nothing in it depends on T. This also gives E=384 one tie order at every T on gfx1250, as E=64/128/256 already have.
  • Other wave32 targets keep the multiwave kernel up to 1024 tokens and prefill_n above it; wave64 arches keep their kernels. Nothing changes off gfx1250.
  • Results versus the previous prefill_n path, as for T <= 1024 under [HIP] topk_gating: single-wave register kernel for wave32 (gfx1250) #7922: rows without an exact score tie at the top-k cutoff get the same expert set and the same weights. Where equal (logit, bias) scores sit at the cutoff, the single-wave lane order picks the expert instead of prefill_n's order, so the set can differ; where the bias creates that tie, the stored weight of the picked expert can differ too.
  • op_tests/test_moe_topk_gating.py: the default token list gains T = 2048, and the unaligned section runs the whole --num-tokens list instead of T <= 1024.

No new environment variables.

Test Plan

  • gfx1250: full op_tests/test_moe_topk_gating.py (all sections).
  • gfx1250: E=384 sqrtsoftplus (renorm, bias, top-6) above 1024 tokens compared with main: per-row expert sets and weights.
  • gfx950: full op_tests/test_moe_topk_gating.py.
  • Device code of the instantiated kernels, gfx950 and gfx1250, against the previous head.

Test Result

  • Previous head 96c174f39 (bound at 2048), gfx1250: all sections pass. Versus main on 33,800 random E=384 rows at T = 1025..2048: the expert sets are identical on every row and the weights are bit-identical. gfx950: the full test passes on main and on that head.
  • This head: the kernel source is unchanged, only the host-side bound is dropped; the gfx950 and gfx1250 device assembly of all instantiated kernels is identical to the previous head's apart from the per-file __hip_cuid symbol. A reviewer measured the single-wave kernel against main and against prefill_n on gfx1250 with the bound raised well past 2048 (see the review thread). gfx1250 validation of the widened bound is pending on our side.
  • gfx950 at this head: the unaligned section (now over the whole default token list) passes over all 1260 configurations (4 expert counts x 7 token counts x 5 topk x 3 score functions x 3 dtypes).

PR Self-Review

Reviewed revision

e88dee0

Behavior and intent

  • Before: on gfx1250, E=384 topk_gating calls with topk <= 8 ran the single-wave kernel of [HIP] topk_gating: single-wave register kernel for wave32 (gfx1250) #7922 up to 1024 tokens (2048 at the previous head of this PR) and prefill_n (TPW=1) above that.
  • After: they run the single-wave kernel (topk_gating_kernel_opt_vwave<.., 384, 2, ..>) at every token count. Other arches, other wave32 targets, other expert counts and topk > 8 are unchanged.
  • Results: rows without an exact score tie at the top-k cutoff get the same expert set and weights as before. At an exact tie at the cutoff, the single-wave lane order picks the expert (as it already does up to 1024 tokens), so the set can differ from prefill_n's; if the bias creates that tie, the stored weight can differ too, as in [HIP] topk_gating: single-wave register kernel for wave32 (gfx1250) #7922.
  • Launch bounds at large T are unchanged from prefill_n (TPW=1): both launch num_tokens blocks of one wave, and both index the logits with the same int product token_idx * gating_stride, so dropping the bound adds no new limit.

Validation and unverified scope

  • Previous head 96c174f39, gfx1250: python op_tests/test_moe_topk_gating.py (all default sections, with T = 2048) passed; E=384 sqrtsoftplus (renorm, bias, top-6) at T = 1025..2048 against main: identical expert sets and bit-identical weights on all compared rows (random logits).
  • This head: hipcc --cuda-device-only for gfx950 and gfx1250 of the three csrc/kernels/topk_gating/*.cu units (-S) gives assembly identical to the previous head's apart from the per-file __hip_cuid symbol (the change is host-side dispatch only).
  • This head, gfx950: python op_tests/test_moe_topk_gating.py --section unaligned passed over the full default token list; black and ruff clean on the changed Python file.
  • Unverified: gfx1250 at this head on our side, i.e. correctness and timing above 2048 tokens (we rely on the reviewer's gfx1250 measurement with the bound raised); sigmoid takes the same single-wave path (only softmax is excluded) and was not measured on gfx1250 above 1024 tokens; gfx1250-strict (keeps the old dispatch); end-to-end serving at this revision.

PR-specific question

Which architecture, dtype and shape boundaries select the changed kernel path, and what invariant prevents unsupported inputs from reaching it?

  • Architecture: topk_gating_vwave_arch(), i.e. get_gpu_arch() == "gfx1250" for the current device; gfx1250-strict and every other arch keep their previous path.
  • Shape: num_experts == 384 and topk <= 8 on that arch, any token count (the changed range is above 1024). Other wave32 targets keep the multiwave kernel up to 1024 and prefill_n above.
  • Score function: sqrtsoftplus and sigmoid (softmax never reaches the single-wave kernel).
  • Dtype: the same gating / bias dtypes the single-wave kernel already takes up to 1024 tokens; the change only drops the token bound, the macro and its operand checks (including the vector-load alignment test) are the ones [HIP] topk_gating: single-wave register kernel for wave32 (gfx1250) #7922 uses.

Changed op tests

  • op_tests/test_moe_topk_gating.py: the default --num-tokens list gains 2048, so a default run checks the newly routed range against the torch reference between 1024 and 4096, where the list had no point before.
  • Same file, unaligned section: it used to keep only T <= 1024, the last T that reached the E=384 single-wave kernel. That kernel now takes every T on gfx1250, so the section runs the whole --num-tokens list (default up to 16384) and keeps checking that the scalar-load path routes bit for bit as the vector-load path at every T that reaches the kernel. Not redundant: no other section feeds unaligned logits or bias.

🤖 Generated with Claude Code

@yhl-amd
yhl-amd requested a review from a team November 16, 2026 18:18
@github-actions

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 8056 --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 16, 2026 •

Copy link
Copy Markdown

NOT READY FOR HUMAN REVIEW

PR Self-Review

Revision e88dee039d5a · 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, E=384 `topk_gating` calls with `topk <= 8` ran the single-wave kernel of #7922 up to 1024 tokens (2048 at the previous head of this PR) and `prefill_n` (TPW=1) above that.
- After: they run the single-wave kernel (`topk_gating_kernel_opt_vwave<.., 384, 2, ..>`) at every token count. Other arches, other wave32 targets, other expert counts and `topk > 8` are unchanged.
- Results: rows without an exact score tie at the top-k cutoff get the same expert set and weights as before. At an exact tie at the cutoff, the single-wave lane order picks the expert (as it already does up to 1024 tokens), so the set can differ from `prefill_n`'s; if the bias creates that tie, the stored weight can differ too, as in #7922.
- Launch bounds at large T are unchanged from `prefill_n` (TPW=1): both launch `num_tokens` blocks of one wave, and both index the logits with the same `int` product `token_idx * gating_stride`, so dropping the bound adds no new limit.

Validation and unverified scope

- Previous head `96c174f39`, gfx1250: `python op_tests/test_moe_topk_gating.py` (all default sections, with T = 2048) passed; E=384 sqrtsoftplus (renorm, bias, top-6) at T = 1025..2048 against main: identical expert sets and bit-identical weights on all compared rows (random logits).
- This head: `hipcc --cuda-device-only` for gfx950 and gfx1250 of the three `csrc/kernels/topk_gating/*.cu` units (`-S`) gives assembly identical to the previous head's apart from the per-file `__hip_cuid` symbol (the change is host-side dispatch only).
- This head, gfx950: `python op_tests/test_moe_topk_gating.py --section unaligned` passed over the full default token list; black and ruff clean on the changed Python file.
- Unverified: gfx1250 at this head on our side, i.e. correctness and timing above 2048 tokens (we rely on the reviewer's gfx1250 measurement with the bound raised); sigmoid takes the same single-wave path (only softmax is excluded) and was not measured on gfx1250 above 1024 tokens; gfx1250-strict (keeps the old dispatch); end-to-end serving at this revision.

PR-specific question

Which architecture, dtype and shape boundaries select the changed kernel path, and what invariant prevents unsupported inputs from reaching it?

- Architecture: `topk_gating_vwave_arch()`, i.e. `get_gpu_arch() == "gfx1250"` for the current device; gfx1250-strict and every other arch keep their previous path.
- Shape: `num_experts == 384` and `topk <= 8` on that arch, any token count (the changed range is above 1024). Other wave32 targets keep the multiwave kernel up to 1024 and `prefill_n` above.
- Score function: sqrtsoftplus and sigmoid (softmax never reaches the single-wave kernel).
- Dtype: the same gating / bias dtypes the single-wave kernel already takes up to 1024 tokens; the change only drops the token bound, the macro and its operand checks (including the vector-load alignment test) are the ones #7922 uses.

Changed op tests

- `op_tests/test_moe_topk_gating.py`: the default `--num-tokens` list gains 2048, so a default run checks the newly routed range against the torch reference between 1024 and 4096, where the list had no point before.
- Same file, `unaligned` section: it used to keep only `T <= 1024`, the last T that reached the E=384 single-wave kernel. That kernel now takes every T on gfx1250, so the section runs the whole `--num-tokens` list (default up to 16384) and keeps checking that the scalar-load path routes bit for bit as the vector-load path at every T that reaches the kernel. Not redundant: no other section feeds unaligned logits or bias.

🤖 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

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.

On gfx1250 the E=384 single-wave kernel (WPT=2) stopped at 1024 tokens and
1025..2048 rows fell to prefill_n (TPW=1), which is slower there. That range
is the DSv4.1 decode width with speculative tokens at high concurrency
(several hundred requests times the verify width) and the small prefill
chunks. Extend the single-wave dispatch to T <= 2048; other wave32 targets
keep the multiwave kernel up to 1024 as before, and T > 2048 keeps
prefill_n.

Results are the same set of experts and weights; as with T <= 1024, only
the expert picked among exactly equal (logit, bias) scores follows the
single-wave lane order instead of prefill_n's.

The op test sweeps T = 2048 by default.

Depends on ROCm#7922 (the single-wave kernel); this branch carries its two
commits until it merges.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@yhl-amd
yhl-amd force-pushed the hyi/topk-gating-384-vwave-2048 branch from b8c0e78 to 96c174f Compare November 17, 2026 16:11
@yhl-amd yhl-amd changed the title [HIP] [gfx1250] topk_gating: E=384 single-wave kernel up to 2048 tokens (on #7922) [HIP] [gfx1250] topk_gating: E=384 single-wave kernel up to 2048 tokens Nov 17, 2026
@yhl-amd

yhl-amd commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

#7922 is merged, so this branch is now current main bfe5e048a plus the one commit of this PR; its patch is unchanged. New head 96c174f39; the previous head is kept on the fork as bak/8056-pre1117u. The title drops "(on #7922)".

gfx1250 run at 96c174f39: python op_tests/test_moe_topk_gating.py (all default sections; the default token list now includes 2048) rc = 0, "All topk_gating benchmarks passed!". The per-row comparison with main at T = 1025..2048 from the previous revision applies unchanged, because the patch is the same and main's E=384 dispatch below 1024 tokens is the #7922 code it was compared on.

Description is updated with the PR Self-Review section (Reviewed revision 96c174f39).

@junhaha666 junhaha666 closed this Nov 18, 2026
@junhaha666 junhaha666 reopened this Nov 19, 2026
@github-actions

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

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

Reviewed 96c174f. Dispatch logic is correct: on gfx1250 E=384 topk<=8 now takes the single-wave kernel to T=2048, other wave32 targets keep multiwave to 1024 and then prefill_n, other arches are untouched. Measured on gfx1250 it is 24-42% faster than main over T=1025..2048; inline notes suggest dropping the bound.

Two description points:

  • "the expert sets are identical on every row" holds on rows without an exact tie at the top-k cutoff; where the tie sits at the cutoff the set can change, and where the bias creates the tie the stored weight can too (as in #7922).
  • sigmoid takes the same path (only softmax is excluded) and isn't measured; worth a line under unverified scope.

Comment thread csrc/include/topk_gating_kernels.cuh Outdated
// and WPT=1 are 5-15% slower), and the single-wave kernel still beats
// prefill_n (TPW=1) up to T=2048 on gfx1250; above that prefill_n
// takes over. Other wave32 targets keep the multiwave kernel to 1024.
if(num_tokens <= 2048)

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.

The change is right, but the 2048 bound looks arbitrary: the single-wave kernel keeps beating prefill_n (TPW=1) well past it. One wave per token and no cross-token work, so nothing in it degrades with T; the old T <= 1024 gate came from the multiwave kernel, which only pays off while it fills the CUs.

gfx1250, E=384, bf16 logits, fp32 bias, sqrtsoftplus + renorm, CUDA graph (run_perftest(testGraph=True)), us, min of 2 rounds. "cap raised" is this PR with the bound set to 16384:

T topk main this PR cap raised Triton #7846
1025 8 4.67 2.78 3.49
1536 8 5.22 3.49 3.67
2048 8 5.44 3.48 2.96 4.54
2304 8 5.77 5.75 3.27 4.63
4096 8 6.28 6.23 3.81 5.78
8192 8 9.40 5.58 9.67
16384 8 14.80 9.69 17.44

topk=6 is the same shape (-31% to -43% against main at every T above 1024). With the bound at 2048 there is a step from ~3.5 us at T=2048 to ~5.2 us at T=2049, and the tie order flips there too. Could the E=384 single-wave dispatch drop the token bound on gfx1250 (keeping T <= 1024 for the multiwave kernel on other wave32 targets)? That also gives E=384 one tie order at every T on gfx1250, as E=64/128/256 already have.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed, the bound is dropped in e88dee039. On gfx1250 the E=384, topk <= 8 single-wave dispatch (_DISPATCH_WAVE32_VWAVE_KERNEL(384, 2)) now runs at every T; other wave32 targets keep the multiwave kernel to T <= 1024 and prefill_n above, and other arches are untouched. The comment above the dispatch now gives your reason (one wave per token, no cross-token work) instead of a token limit.

Your measurement is what this relies on (gfx1250, E=384, bf16 logits, fp32 bias, sqrtsoftplus + renorm, CUDA graph, top-8, us): with the bound raised, T = 2048 / 2304 / 4096 / 8192 / 16384 go from 5.44 / 5.77 / 6.28 / 9.40 / 14.80 on main to 2.96 / 3.27 / 3.81 / 5.58 / 9.69, ahead of the Triton #7846 path at every T, and topk = 6 is 31-43% below main at every T above 1024. Dropping the bound also removes the step at T = 2049 and the tie-order flip there, so E=384 now has one tie order at every T on gfx1250, as E=64/128/256 do. gfx1250 validation of the widened bound pending on our side; relying on your measurement.

Large-T limits, from reading the code at this head:

  • Grid: grid(num_tokens) blocks of one 32-lane wave. prefill_n with TPW=1, which these calls ran before, launches the same num_tokens blocks of one wave, so the launch size limit is unchanged. num_tokens is an int taken from size(0) on the host side, same as before.
  • Integer overflow: the input row is gating_output + token_idx * gating_stride with two ints. That product overflows once T times the row stride reaches 2^31 (about 5.6M tokens at stride 384, a 4 GiB bf16 logits tensor). prefill_n ((valid ? token_idx : 0) * gating_stride) and the other kernels in this file use the same expression, so dropping the bound adds no new limit; it is an existing limit of the op on every path. The output offsets use size_t stride_tk, and expert ids stay below 384.
  • No shared memory or per-T workspace in the kernel, and T = 0 already took this kernel before (it was inside the old bound).
  • Device code is unchanged: hipcc --cuda-device-only -S of the three topk_gating/*.cu units for gfx950 and gfx1250 gives the same assembly as the previous head, except for the per-file __hip_cuid symbol. Only the host-side dispatch changed.

The 64-bit row offset is a small separate change across all the kernels in this file; I can send it as its own PR if you want it.

type=str2tuple,
default=[16384, 4096, 1024, 256, 64, 1],
help="Comma-separated list of number of tokens (default: 16384,4096,1024,256,64,1)",
default=[16384, 4096, 2048, 1024, 256, 64, 1],

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.

With the bound widened, the unaligned section (line 1336, t <= 1024) no longer reaches every T that takes the single-wave kernel. The kernel doesn't depend on T, so the risk is low, but raising that filter to the new bound (or 2048 if the bound stays) keeps its "every T that reaches the kernel" coverage.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in e88dee039: the unaligned section no longer filters T <= 1024 and runs the whole --num-tokens list (default 1 to 16384). The single-wave kernel now takes every T on gfx1250, so this keeps the "every T that reaches the kernel" coverage. The SKIP branch for an empty filtered list is gone with the filter.

gfx950 at this head: python op_tests/test_moe_topk_gating.py --section unaligned passes on all 1260 configurations (4 expert counts x 7 token counts x 5 topk x 3 score functions x 3 dtypes). gfx950 does not reach the single-wave kernel, so this only checks the widened section itself. gfx1250 validation pending on our side.

Drop the T <= 2048 bound on the gfx1250 E=384 single-wave dispatch. The
kernel runs one wave per token with no cross-token work, so nothing in it
degrades with T, and it stays ahead of prefill_n (TPW=1) at large T as
well. This also gives E=384 one tie order at every T on gfx1250, as
E=64/128/256 already have. Other wave32 targets keep the multiwave kernel
up to 1024 tokens and prefill_n above it; other arches are unchanged.

The op test's unaligned section now runs the whole --num-tokens list
instead of T <= 1024, so it reaches every T the single-wave kernel takes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@yhl-amd yhl-amd changed the title [HIP] [gfx1250] topk_gating: E=384 single-wave kernel up to 2048 tokens [HIP] [gfx1250] topk_gating: E=384 single-wave kernel at every token count Nov 19, 2026
@yhl-amd

yhl-amd commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

@yzhou103 thanks for the review. New head e88dee039, one commit on top of 96c174f39; the previous head is kept on the fork as bak/8056-pre1119a.

  • Inline 1: the E=384 single-wave dispatch on gfx1250 no longer has a token bound. The limits at large T are covered in the thread.
  • Inline 2: the unaligned section runs every --num-tokens value.
  • Description, tie wording: the result now says that rows without an exact tie at the top-k cutoff keep the same expert set and weights. Where the tie sits at the cutoff the set can change, and where the bias creates the tie the stored weight can change too, as in [HIP] topk_gating: single-wave register kernel for wave32 (gfx1250) #7922. The earlier 33,800-row comparison is now worded as what it was: random logits.
  • Description, sigmoid: listed as taking the same path (only softmax is excluded) and as not measured above 1024 tokens, under unverified scope.
  • Title changed to "at every token count". The PR Self-Review is updated to e88dee039.

gfx1250 validation of the widened bound pending on our side; relying on your measurement.

@valarLip
valarLip merged commit 9169eb8 into ROCm:main Nov 23, 2026
1 check passed
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