Repository navigation
refactor topk softplus bias and opt - #3067
Merged
Merged
Conversation
Contributor
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
|
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors the MoE fused top-k routing implementation by replacing the dedicated topk_softplus kernel with a unified “topk gating” kernel that supports multiple scoring functions (sqrtsoftplus, sigmoid, softmax) and adds an optimized register-only path for common expert counts.
Changes:
- Replaces
topk_softplus_kernels.cuwith a new unified kernel implementation intopk_gating_kernels.cu(adds score-function dispatch + opt/fallback variants). - Extends the Python API to expose a unified
topk_gating(...)wrapper and forwardsscore_funcinto the existingtopk_softplusbinding. - Expands the sigmoid/softplus op test matrix (more expert counts + adds
topk=6) and updates benchmarks.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| op_tests/test_moe_topk_sigmoid.py | Expands correctness/benchmark configs; uses topk_gating(..., score_func="sigmoid") for larger expert counts. |
| csrc/kernels/topk_softplus_kernels.cu | Removes the previous dedicated softplus kernel implementation. |
| csrc/kernels/topk_gating_kernels.cu | Adds unified fused top-k gating kernels with score-function selection and an optimized register-only variant. |
| csrc/include/rocm_ops.hpp | Updates pybind signature/docs to include score_func for topk_softplus. |
| csrc/include/moe_op.h | Extends topk_softplus C++ signature to accept score_func. |
| aiter/ops/topk.py | Adds Python-level topk_gating wrapper + validates/threads through score_func. |
| aiter/jit/optCompilerConfig.json | Updates build sources to compile the new unified gating kernel file. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
Author
valarLip
approved these changes
May 8, 2026
valarLip
pushed a commit
that referenced
this pull request
May 8, 2026
chuanbowang2026
pushed a commit
that referenced
this pull request
May 9, 2026
test_moe_topk_sigmoid.py was renamed to test_moe_topk_gating.py in #3067 but split_tests.sh was not updated, causing CI to fail with file not found.
valarLip
pushed a commit
that referenced
this pull request
May 10, 2026
* perf(topk): optimize radix top-k kernel for MI308X and MI355X - Tune BitsPerPass: MI308X mb=10/ob=11, MI355X mb=11/ob=12 - Add multi-block persistent radix kernel with cross-block atomic barrier - Add __syncthreads after MB histogram flush before atomicInc - Fix rowStarts offset for non-zero prefix in prefill path - Add row_len<=k fast path for multi-block kernel - Fix stride bug in MB row_len<=k guard - Fix in_idx_buf+rowStart double-add semantic issue * fix(topk): restore topk_plain entry after removing standalone_stable_radix_11bits topk_plain_kernels.cu still called the deleted aiter::standalone_stable_radix_11bits, breaking op_tests/test_topk_plain.py. Add a non-template radix_topk_dispatch in topk_per_row_kernels.cu that dispatches between mb and ob paths via should_use_mulblocks, and route topk_per_row_kernel_launcher through it. * fix(ci): update renamed test file in split_tests.sh test_moe_topk_sigmoid.py was renamed to test_moe_topk_gating.py in #3067 but split_tests.sh was not updated, causing CI to fail with file not found. * perf(topk): add wave-cap for multiblock grid_dim on high-CU parts (MI35X/MI355X) --------- Co-authored-by: root <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Motivation
optimization and add support sigmoid and softmax topk
Technical Details
Test Plan
Test Result
Submission Checklist