[Feat] Add FlyDSL MoE sorting kernel#540
Open
amd-weisun wants to merge 5 commits into
Open
Conversation
4a16adf to
2e21d3c
Compare
Drop-in replacement for OPUS/CK moe_sorting in aiter's fused_moe. Kernel paths: - T <= 16: decode — single-block LDS histogram + DPP prefix sum - 16 < T <= 2048: p0v2 + p23 — per-expert scatter + parallel prefix sum - T > 2048: 4-kernel fused — K1 clear + K2 scatter + K3 count + p23 Correctness: 32 CI tests + 14 large_shape (46 total), covering all 11 production MoE models (E=8..513, topk=2..9).
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new FlyDSL implementation of the MoE token sorting kernel (decode + prefill paths) intended as a drop-in replacement for aiter/OPUS/CK, along with a comprehensive GPU correctness test suite and optional benchmarking helpers.
Changes:
- Introduce
kernels/moe_sorting_kernel.pyimplementing decode (single-kernel LDS) and prefill (HBM workspace; p0v2+p23 or 4-kernel fused) sorting paths, including optional expert-mask (EP) support. - Add
tests/kernels/test_moe_sorting.pyvalidating outputs vs a Python reference and (optionally) aiter, plus EP-mode coverage and benchmark utilities.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| kernels/moe_sorting_kernel.py | New FlyDSL MoE sorting kernel implementation with decode/prefill dispatch, workspace handling, and EP support. |
| tests/kernels/test_moe_sorting.py | New GPU test suite comparing against a reference/aiter and covering multiple shapes + EP mode; includes optional benchmarking. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Drop-in replacement for OPUS/CK moe_sorting in aiter's fused_moe. (aiter uses OPUS by default)
Kernel paths:
Correctness: 32 CI tests + 14 large_shape (46 total), covering all 11 production MoE models (E=8..513, topk=2..9).
Kernel Performance (moe sorting only)
Decode (T≤256): CUDA graph capture + 200 replays.
Prefill (T>256): CUDA events (eager mode), 100 iterations.
MI350X (gfx950), single GPU.
DeepSeek-R1: E=257, topk=9, unit_size=32
DeepSeek-V4: E=385, topk=7, unit_size=32
Qwen3-MoE: E=128, topk=4, unit_size=128
ATOM E2E Benchmark Result
Accuracy validated using llm accuracy validation steps in ATOM