Skip to content

[HIP] Speed up gfx950 384-expert sqrtsoftplus topk gating - #8258

Merged
junhaha666 merged 1 commit into
ROCm:mainfrom
yzhou103:perf/gfx950-topk-384-main
Nov 23, 2026
Merged

junhaha666 merged 1 commit into
ROCm:mainfrom
yzhou103:perf/gfx950-topk-384-main

Conversation

@yzhou103

@yzhou103 yzhou103 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Speed up HIP topk_gating on gfx950 for sqrtsoftplus routing with 384 experts and top-k 1–8 by reusing the existing vwave kernel with a wave64 layout. The public API and dispatch inputs are unchanged; the new path is selected automatically.

Motivation

The existing gfx950 register kernel uses runtime cursors to select entries from per-lane sorted lists. Reusing the vwave implementation lets the kernel shift these lists after each selection while retaining the existing expert layout, tie order, and normalization order. This improves the measured MI355X workload without depending on the Triton implementation in #7846.

Changes

  • Generalize the vwave lane count from 32 to compile-time WARP_SIZE. On gfx950, one wave handles one row, with six experts per lane and WPT=1.
  • Reuse the vwave bulk input loads, select-based scoring/sorting, and list-shifting top-k merge.
  • Use a 64-bit ballot and ctzll on GFX9 so winning lanes 32–63 remain visible.
  • Preserve the wave64 padded-row early exit and existing invalid-row/shared-expert output behavior.
  • Add a per-device cached gfx950 dispatch gate for sqrtsoftplus, 384 routed experts, and top-k ≤8. Other configurations retain their prior dispatch.

Only csrc/include/topk_gating_kernels.cuh changes. No environment variables, tuning configurations, or dependencies are added. The measurements cover the combined change; individual optimizations were not isolated with ablation experiments.

Performance (if applicable)

Hardware/software: one MI355X (gfx950), PyTorch 2.10.0+rocm7.2.4.git3d3aa833, HIP 7.2.53211, Triton 3.7.0. All three candidates were measured on the same GPU, without clock locking.

Workload: BF16 logits [rows, 384], FP32 correction bias and output weights, INT32 expert IDs, sqrtsoftplus, renorm=True, routed scaling factor 1.5, no shared experts, preallocated outputs, and warm-cache inputs. Results are medians of five rounds with alternating candidate order. Compilation and allocation are excluded; IDs and FP32 weight bits were checked before timing.

Comparison revisions: original HIP at main db3b870ea154f4e5d68b4a38a1759cee1a8bcdcd; this HIP change at 5be669a848b7bc0aa83e76af8201959e7508e938; Triton from #7846 at a935e8354250fd4f6a560ea7ede6638a0805a24e. For the three-way comparison, the same HIP patch was applied to the #7846 tree to access its Triton dispatch, with original and optimized HIP modules loaded separately. The relevant original HIP sources match the main baseline. This PR itself is based on main and has no dependency on #7846.

Eager GPU kernel time: run_perftest(testGraph=False)

These are profiler-derived GPU kernel times (device_time_sum), not host wall-clock times. All latencies below are in microseconds.

Rows Top-k Original HIP This PR Triton #7846 Reduction vs original HIP
128 6 5.302 3.950 4.523 25.5%
128 8 5.639 4.131 5.051 26.7%
256 6 5.347 3.989 4.614 25.4%
256 8 5.712 4.189 5.127 26.7%
512 6 5.532 4.124 4.812 25.4%
512 8 5.797 4.346 5.393 25.0%

For these shapes, latency is approximately 25–27% lower than original HIP and 13–19% lower than Triton.

Graph GPU kernel time: run_perftest(testGraph=True)

This also reports profiler-derived GPU kernel time. At 128–512 rows, this PR and Triton are approximately tied under this measurement method.

Rows Top-k Original HIP This PR Triton #7846
128 6 4.394 4.370 4.403
128 8 4.583 4.328 4.326
256 6 4.429 4.391 4.399
256 8 4.653 4.329 4.366
512 6 4.521 4.362 4.385
512 8 4.832 4.369 4.361
2048 8 5.545 4.388 5.383
4096 6 6.660 5.356 —
4096 8 7.246 5.747 —
16384 6 18.073 14.718 —
16384 8 20.228 16.147 —

The Triton path in the compared revision is enabled only through 2048 rows; larger shapes are not reported as Triton measurements. The HIP performance sweep covered 1–16384 rows.

Graph replay without profiler: GPU events, amortized per call

Each graph contains 256 calls and is replayed 20 times per round after warmup. GPU-event elapsed time is divided by the number of calls. This includes gaps between graph nodes and excludes capture and Python dispatch. It is a separate metric from the profiler kernel times above.

Rows Top-k Original HIP This PR Triton #7846
128 6 4.242 2.834 3.371
128 8 4.577 2.982 3.831
256 6 4.284 2.867 3.409
256 8 4.621 3.028 3.877
512 6 4.438 2.966 3.604
512 8 4.780 3.152 4.084

Under this method, latency is approximately 33–35% lower than original HIP and 16–23% lower than Triton. A separate same-graph profiler-on/off experiment showed that profiling perturbs these short kernels, so the two graph measurements are reported separately. No model or end-to-end throughput claim is made.

Supplemental top-k 1–8 sweep (review follow-up)

To cover the full dispatch range, both main baseline db3b870ea154f4e5d68b4a38a1759cee1a8bcdcd and PR head 5be669a848b7bc0aa83e76af8201959e7508e938 were rebuilt into separate JIT directories in the same container, then measured on another single MI355X/gfx950. This is a separate base/head run; its measurements are not combined with the earlier three-way comparison.

The workload and three timing methods match those defined above: BF16 [rows,384] logits, FP32 bias/weights, INT32 IDs, sqrtsoftplus, renormalization enabled, scaling factor 1.5, no shared experts, preallocated outputs, warm cache, and five alternating-order rounds. The sweep covers rows 1/64/128/256/512/2048/4096/16384 crossed with every top-k from 1 through 8. Software: the same PyTorch 2.10.0+rocm7.2.4.git3d3aa833 and HIP 7.2.53211, with FlyDSL 0.5.0; this container has Triton 3.8.0, but this supplement measures only the HIP candidates. GPU clocks were not locked.

All 64 configurations passed exact expert-ID and FP32-weight-bit comparison against baseline and an independent FP32 reference check. GPU traces confirm that top-k 1–8 selects the new vwave kernel and top-k 9 retains the original kernel.

Across all 64 shapes, the unprofiled graph-event latency reduction is 17.3%–40.8%. Eager profiler medians range from effectively flat (0.5% lower) to 33.1% lower. Profiled graph results do not show a uniform win: 17 of 64 medians are higher, by at most 2.34% (128 rows, top-k 5: 4.294 → 4.395 µs); the largest reduction is 30.6%. Small-row profiled graph results remain close to a tie. The table below includes the specifically requested top-k 1/2/4/7 values rather than inferring their performance from 6/8.

All times are µs, shown as baseline → PR head.

Rows Top-k Eager kernel, base → head Profiled graph kernel, base → head Unprofiled graph events, base → head
128 1 4.259 → 3.082 4.330 → 4.337 3.377 → 2.152
128 2 4.480 → 3.287 4.320 → 4.324 3.581 → 2.330
128 4 4.886 → 3.579 4.314 → 4.395 3.851 → 2.550
128 7 5.375 → 4.024 4.506 → 4.410 4.440 → 2.967
256 1 4.341 → 3.121 4.315 → 4.319 3.436 → 2.175
256 2 4.561 → 3.192 4.382 → 4.430 3.637 → 2.407
256 4 4.924 → 3.650 4.433 → 4.417 3.906 → 2.603
256 7 5.448 → 4.060 4.552 → 4.386 4.484 → 3.000
512 1 4.455 → 3.158 4.317 → 4.374 3.546 → 2.246
512 2 4.685 → 3.363 4.384 → 4.403 3.757 → 2.454
512 4 5.083 → 3.754 4.387 → 4.418 4.044 → 2.680
512 7 5.554 → 4.199 4.728 → 4.419 4.644 → 3.114
Complete 64-configuration base/head table and container provenance

Container: rocm/atom-dev@sha256:f3c2fcd6f2213401d275207dd6a7815ef00a9e6ff7bc610dd5e7e266cd55705e. Both HIP builds use the same compiler and CK revision f93c029e09f67c983696eecac8e0e0350f3dbb54. The unprofiled graph contains 256 calls and is replayed 20 times per round, as in the earlier measurements.

Rows Top-k Eager kernel, base → head Profiled graph kernel, base → head Unprofiled graph events, base → head
1 1 3.702 → 2.477 4.310 → 4.313 3.010 → 1.782
1 2 3.852 → 2.670 4.317 → 4.309 3.214 → 1.962
1 3 4.033 → 2.859 4.310 → 4.300 3.410 → 2.148
1 4 4.239 → 3.003 4.319 → 4.301 3.599 → 2.295
1 5 4.413 → 3.145 4.319 → 4.307 3.784 → 2.434
1 6 4.614 → 3.272 4.312 → 4.301 3.982 → 2.565
1 7 4.795 → 3.398 4.341 → 4.312 4.175 → 2.692
1 8 5.006 → 3.508 4.394 → 4.309 4.363 → 2.803
64 1 4.246 → 3.073 4.339 → 4.343 3.368 → 2.140
64 2 4.427 → 3.268 4.341 → 4.352 3.565 → 2.326
64 3 4.650 → 3.458 4.328 → 4.328 3.738 → 2.481
64 4 4.825 → 3.602 4.327 → 4.324 3.824 → 2.525
64 5 5.039 → 3.744 4.294 → 4.306 4.048 → 2.683
64 6 5.216 → 3.887 4.352 → 4.303 4.204 → 2.788
64 7 5.376 → 3.971 4.450 → 4.377 4.406 → 2.935
64 8 5.446 → 4.062 4.557 → 4.351 4.535 → 2.980
128 1 4.259 → 3.082 4.330 → 4.337 3.377 → 2.152
128 2 4.480 → 3.287 4.320 → 4.324 3.581 → 2.330
128 3 4.681 → 3.483 4.327 → 4.309 3.754 → 2.496
128 4 4.886 → 3.579 4.314 → 4.395 3.851 → 2.550
128 5 5.067 → 3.685 4.294 → 4.395 4.057 → 2.710
128 6 5.264 → 3.822 4.402 → 4.397 4.244 → 2.821
128 7 5.375 → 4.024 4.506 → 4.410 4.440 → 2.967
128 8 5.447 → 4.120 4.621 → 4.376 4.585 → 3.013
256 1 4.341 → 3.121 4.315 → 4.319 3.436 → 2.175
256 2 4.561 → 3.192 4.382 → 4.430 3.637 → 2.407
256 3 4.728 → 3.451 4.419 → 4.428 3.799 → 2.567
256 4 4.924 → 3.650 4.433 → 4.417 3.906 → 2.603
256 5 5.112 → 3.788 4.399 → 4.409 4.127 → 2.774
256 6 5.283 → 3.926 4.451 → 4.388 4.291 → 2.863
256 7 5.448 → 4.060 4.552 → 4.386 4.484 → 3.000
256 8 5.500 → 4.163 4.675 → 4.361 4.618 → 3.039
512 1 4.455 → 3.158 4.317 → 4.374 3.546 → 2.246
512 2 4.685 → 3.363 4.384 → 4.403 3.757 → 2.454
512 3 4.918 → 3.591 4.389 → 4.398 3.940 → 2.626
512 4 5.083 → 3.754 4.387 → 4.418 4.044 → 2.680
512 5 5.288 → 3.910 4.448 → 4.422 4.284 → 2.870
512 6 5.445 → 4.055 4.542 → 4.407 4.433 → 2.968
512 7 5.554 → 4.199 4.728 → 4.419 4.644 → 3.114
512 8 5.559 → 4.287 4.864 → 4.376 4.771 → 3.142
2048 1 4.882 → 3.687 4.407 → 4.391 3.902 → 2.752
2048 2 5.141 → 3.947 4.428 → 4.391 4.187 → 2.967
2048 3 5.448 → 4.249 4.558 → 4.390 4.375 → 3.244
2048 4 5.590 → 4.463 4.664 → 4.399 4.511 → 3.300
2048 5 5.602 → 4.623 4.939 → 4.397 4.740 → 3.554
2048 6 5.601 → 4.834 5.164 → 4.397 4.982 → 3.656
2048 7 5.452 → 4.969 5.399 → 4.429 5.170 → 3.836
2048 8 5.485 → 5.071 5.567 → 4.380 5.347 → 3.850
4096 1 5.483 → 4.487 4.969 → 4.433 4.766 → 3.415
4096 2 5.431 → 4.937 5.332 → 4.462 5.036 → 3.874
4096 3 5.441 → 5.416 5.683 → 4.546 5.417 → 4.221
4096 4 6.109 → 5.793 5.961 → 4.769 5.587 → 4.529
4096 5 7.549 → 6.115 6.316 → 5.118 5.993 → 4.776
4096 6 8.808 → 6.427 6.659 → 5.371 6.232 → 5.081
4096 7 9.045 → 6.645 7.016 → 5.628 6.640 → 5.256
4096 8 9.079 → 6.778 7.279 → 5.726 6.786 → 5.401
16384 1 11.947 → 8.186 11.971 → 8.304 10.993 → 7.500
16384 2 13.256 → 11.750 13.265 → 9.919 11.939 → 9.131
16384 3 14.413 → 11.765 14.383 → 11.733 13.140 → 10.520
16384 4 15.581 → 12.720 15.602 → 12.706 14.040 → 11.607
16384 5 16.915 → 13.773 16.913 → 13.834 15.411 → 12.363
16384 6 18.096 → 14.580 18.112 → 14.710 16.199 → 13.328
16384 7 19.254 → 15.514 19.255 → 15.516 17.439 → 13.852
16384 8 20.310 → 16.249 20.323 → 16.233 18.128 → 14.612

Testing

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

The existing canonical test was run after rebuilding the final main-based worktree:

python3 op_tests/test_moe_topk_gating.py \
  --section softplus,nan,ties,eplb,shared,pad-rows,unaligned \
  --num-experts 384 --num-tokens 1,128,2048 --topk 1,6,8,9

Result: exit 0, All topk_gating benchmarks passed!. The default dtype sweep covers FP16/BF16/FP32, with 443 decorated benchmark invocations plus unaligned-input checks. Top-k 9 exercises the existing fallback.

Additional validation:

  • Review follow-up: 64 further base/head performance configurations passed exact output comparison and an independent FP32 reference check; top-k 1–8 and its top-k 9 fallback were verified with GPU traces. See the supplemental performance section.
  • 432 exact comparisons against original HIP on the final main-based build: expert IDs and FP32 weight bits match. Coverage includes top-k 1–9, all three input dtypes, supported bias types/no bias, random/tied/constant/NaN/Inf inputs, invalid bias values, renormalization on/off, shared experts, offset and padded row strides, valid-row counts of zero/partial/all, and unchanged output padding sentinels.
  • 189 GPU tests passed from op_tests/triton_tests/moe/moe_routing/test_topk_gating_sqrtsoftplus_384.py in the [Triton/Gluon] [gfx950] topk_gating: light Triton kernel for 384-expert sqrtsoftplus routing at decode widths #7846 comparison tree with this HIP patch. These cover exact HIP/Triton agreement, dynamic valid-row counts, and first graph capture. This is supplementary evidence from that comparison tree; the test file is not part of this PR or the final main-based tree.
  • Additional dynamic-row performance checks used valid-row counts of zero/half/all at 128/512/2048 rows and top-k 6/8, with exact output agreement.
  • gfx1250 offline compilation/ISA check: both original and modified sqrtsoftplus translation units compiled; normalized disassembly matched for all 50 existing vwave kernels. Ten additional compiled instances are not selected by the gfx1250 runtime gate. This is not a gfx1250 hardware test.
  • git diff --check passed.

Documentation

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

No user-facing API or configuration changes. Inline kernel comments describe the wave-size invariant and dispatch scope; performance and validation are documented here.

Dependencies

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

Breaking Changes

None.

PR Self-Review

Reviewed revision

5be669a848b7bc0aa83e76af8201959e7508e938

Behavior and intent

The gfx950 384-expert sqrtsoftplus path automatically uses the wave64 vwave kernel for top-k 1–8. The intent is to reduce routing latency while preserving the existing output contract, including tie order, normalization, padding, and shared experts. The implementation and measured benefit are described above.

Validation and unverified scope

On MI355X/gfx950, ran python3 op_tests/test_moe_topk_gating.py --section softplus,nan,ties,eplb,shared,pad-rows,unaligned --num-experts 384 --num-tokens 1,128,2048 --topk 1,6,8,9 after rebuilding revision 5be669a848b7bc0aa83e76af8201959e7508e938. It passed with exit 0 and All topk_gating benchmarks passed! (443 decorated invocations plus unaligned checks). Another 432 baseline comparisons passed with identical expert IDs and FP32 weight bits.

The review follow-up rebuilt baseline and head in the same container and passed a further 64-case performance/correctness sweep: rows 1/64/128/256/512/2048/4096/16384, every top-k 1–8, and five alternating-order rounds. All 64 cases match the baseline bit for bit and pass the independent FP32 reference. GPU traces verify the top-k 1–8 optimized dispatch and top-k 9 fallback. The Performance section provides all measurements, including the small profiled-graph slowdowns, and separates the earlier three-way run from the supplemental HIP-only run.

Unverified / deferred: downstream model/end-to-end validation is deferred for this PR; no model accuracy or throughput result is claimed. MI250X/MI300X and gfx1250 hardware tests were not run. gfx1250 evidence is limited to offline compilation and ISA comparison. The #7846 tests and earlier three-way timings were run in that comparison tree with this HIP patch, while canonical tests, the 432-case baseline checks, and the supplemental HIP sweep used the final main-based head. These local results do not assert that all PR CI jobs are green.

The default ci:atom matrix selects DeepSeek-R1-0528 and gpt-oss-120b. A targeted downstream follow-up must verify that the model actually selects the 384-expert sqrtsoftplus HIP branch; a generic downstream green result alone is not claimed as coverage of this dispatch. No model CI run was triggered for this follow-up.

PR-specific question

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

The new dispatch requires runtime architecture gfx950, score function sqrtsoftplus, exactly 384 routed experts, and supported top-k 1–8. There is no row-count cutoff. Existing validation and dtype dispatch continue to accept FP16/BF16/FP32 logits and the existing correction-bias combinations (FP32, or BF16 with BF16/FP32 logits, or no bias).

The launcher selects WPT=1 with one WARP_SIZE block per row. On gfx950 this means 64 lanes, six experts per lane, and top-k bounded by the kernel's eight selections. Scalar loads introduce no extra vector-alignment requirement; existing accepted strides, renormalization modes, shared experts, and dynamic valid-row counts retain their contracts. The architecture/score/expert/top-k gates keep other configurations on their previous paths, and the existing host validation remains in force before launch.

Changed op tests

None. No op_tests/ files are changed. Existing test_moe_topk_gating.py sections cover sqrtsoftplus, non-finite values, ties, expert remapping, shared experts, padded rows, and unaligned inputs. The external #7846 test results are identified separately above and are not presented as tests added by this PR.

@yzhou103
yzhou103 requested review from a team and a balanced review from Copilot November 19, 2026 05:02
@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 8258 --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.

@github-actions github-actions Bot added the HIP label Nov 19, 2026
@aiter-bot

aiter-bot commented Nov 19, 2026 •

Copy link
Copy Markdown

NOT READY FOR HUMAN REVIEW

PR Self-Review

Revision 5be669a848b7 · 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

The gfx950 384-expert sqrtsoftplus path automatically uses the wave64 vwave kernel for top-k 1–8. The intent is to reduce routing latency while preserving the existing output contract, including tie order, normalization, padding, and shared experts. The implementation and measured benefit are described above.

Validation and unverified scope

On MI355X/gfx950, ran `python3 op_tests/test_moe_topk_gating.py --section softplus,nan,ties,eplb,shared,pad-rows,unaligned --num-experts 384 --num-tokens 1,128,2048 --topk 1,6,8,9` after rebuilding revision `5be669a848b7bc0aa83e76af8201959e7508e938`. It passed with exit 0 and `All topk_gating benchmarks passed!` (443 decorated invocations plus unaligned checks). Another 432 baseline comparisons passed with identical expert IDs and FP32 weight bits.

The review follow-up rebuilt baseline and head in the same container and passed a further 64-case performance/correctness sweep: rows 1/64/128/256/512/2048/4096/16384, every top-k 1–8, and five alternating-order rounds. All 64 cases match the baseline bit for bit and pass the independent FP32 reference. GPU traces verify the top-k 1–8 optimized dispatch and top-k 9 fallback. The Performance section provides all measurements, including the small profiled-graph slowdowns, and separates the earlier three-way run from the supplemental HIP-only run.

**Unverified / deferred:** downstream model/end-to-end validation is deferred for this PR; no model accuracy or throughput result is claimed. MI250X/MI300X and gfx1250 hardware tests were not run. gfx1250 evidence is limited to offline compilation and ISA comparison. The #7846 tests and earlier three-way timings were run in that comparison tree with this HIP patch, while canonical tests, the 432-case baseline checks, and the supplemental HIP sweep used the final main-based head. These local results do not assert that all PR CI jobs are green.

The default `ci:atom` matrix selects DeepSeek-R1-0528 and gpt-oss-120b. A targeted downstream follow-up must verify that the model actually selects the 384-expert sqrtsoftplus HIP branch; a generic downstream green result alone is not claimed as coverage of this dispatch. No model CI run was triggered for this follow-up.

PR-specific question

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

The new dispatch requires runtime architecture **gfx950**, score function **sqrtsoftplus**, exactly **384 routed experts**, and supported **top-k 1–8**. There is no row-count cutoff. Existing validation and dtype dispatch continue to accept FP16/BF16/FP32 logits and the existing correction-bias combinations (FP32, or BF16 with BF16/FP32 logits, or no bias).

The launcher selects `WPT=1` with one `WARP_SIZE` block per row. On gfx950 this means 64 lanes, six experts per lane, and top-k bounded by the kernel's eight selections. Scalar loads introduce no extra vector-alignment requirement; existing accepted strides, renormalization modes, shared experts, and dynamic valid-row counts retain their contracts. The architecture/score/expert/top-k gates keep other configurations on their previous paths, and the existing host validation remains in force before launch.

Changed op tests

None. No `op_tests/` files are changed. Existing `test_moe_topk_gating.py` sections cover sqrtsoftplus, non-finite values, ties, expert remapping, shared experts, padded rows, and unaligned inputs. The external #7846 test results are identified separately above and are not presented as tests added by this PR.

PR state

  • PASS — pull request is marked ready for review

Copilot findings

  • PASS — no active Copilot finding lacks a substantive author reply

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.

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.

🔵 Needs a closer look

The changed default gfx950 wave64 dispatch for the 384-expert sqrtsoftplus path requires hardware validation because no head-matched GPU correctness results or base/head latency comparisons were supplied.

No open issues 🎉

What changed in this PR

This PR targets faster HIP top-k expert gating on gfx950 for 384-expert workloads using sqrtsoftplus scoring.

Changes:

  • Adds a gfx950-specific single-wave dispatch for top-k values up to 8, with and without renormalization.
  • Extends the existing single-wave kernel to wave64 using architecture-appropriate ballot handling.
  • Preserves wave64 padded-row early exits and the existing expert tie order.
File Description
csrc/​include/​topk_gating_kernels.cuh Adds the gfx950 dispatch and adapts the single-wave kernel for wave64 execution.

Review effort: Balanced

@yzhou103

Copy link
Copy Markdown
Contributor Author

@valar-cop review

@valar-cop valar-cop left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

a few small things..

gfx950 base-vs-head latency for topk 1, 2, 4 and 7?

ci green.

Comment thread csrc/include/topk_gating_kernels.cuh Resolved
Comment thread csrc/include/topk_gating_kernels.cuh Resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants