feat(kernel): introduce unified moe kernel api#374
Merged
Conversation
Signed-off-by: Pengzhan Zhao <borontion@gmail.com>
Signed-off-by: Pengzhan Zhao <borontion@gmail.com>
Signed-off-by: Pengzhan Zhao <borontion@gmail.com>
Signed-off-by: Pengzhan Zhao <borontion@gmail.com>
Signed-off-by: Pengzhan Zhao <borontion@gmail.com>
Signed-off-by: Pengzhan Zhao <borontion@gmail.com>
Signed-off-by: Pengzhan Zhao <borontion@gmail.com>
Signed-off-by: Pengzhan Zhao <borontion@gmail.com>
Signed-off-by: Pengzhan Zhao <borontion@gmail.com>
Signed-off-by: Pengzhan Zhao <borontion@gmail.com>
Signed-off-by: Pengzhan Zhao <borontion@gmail.com>
Signed-off-by: Pengzhan Zhao <borontion@gmail.com>
Signed-off-by: Pengzhan Zhao <borontion@gmail.com>
Signed-off-by: Pengzhan Zhao <borontion@gmail.com>
Signed-off-by: Pengzhan Zhao <borontion@gmail.com>
Signed-off-by: Pengzhan Zhao <borontion@gmail.com>
Signed-off-by: Pengzhan Zhao <borontion@gmail.com>
Signed-off-by: Pengzhan Zhao <borontion@gmail.com>
Signed-off-by: Pengzhan Zhao <borontion@gmail.com>
Signed-off-by: Pengzhan Zhao <borontion@gmail.com>
Signed-off-by: Pengzhan Zhao <borontion@gmail.com>
Signed-off-by: Pengzhan Zhao <borontion@gmail.com>
Signed-off-by: Pengzhan Zhao <borontion@gmail.com>
Signed-off-by: Pengzhan Zhao <borontion@gmail.com>
Signed-off-by: Pengzhan Zhao <borontion@gmail.com>
Signed-off-by: Pengzhan Zhao <borontion@gmail.com>
Signed-off-by: Pengzhan Zhao <borontion@gmail.com>
Signed-off-by: Pengzhan Zhao <borontion@gmail.com>
Signed-off-by: Pengzhan Zhao <borontion@gmail.com>
Signed-off-by: Pengzhan Zhao <borontion@gmail.com>
Signed-off-by: Pengzhan Zhao <borontion@gmail.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 682fdb6fb2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Signed-off-by: Pengzhan Zhao <borontion@gmail.com>
Signed-off-by: Pengzhan Zhao <borontion@gmail.com>
Signed-off-by: Pengzhan Zhao <borontion@gmail.com>
Signed-off-by: Pengzhan Zhao <borontion@gmail.com>
panditsa
added a commit
to panditsa/tokenspeed
that referenced
this pull request
Jun 11, 2026
Squashed warp-decode work (coop-LDS stage1 + per-M split-K stage2, interleave/ K-tail/scale fixes) for rebase onto the PR lightseekorg#374 MoE-API refactor. Full per-commit history preserved in backup/gptoss-warp-decode-moe-* . Signed-off-by: Sanket Pandit <sanket.pandit@amd.com>
antiagainst
approved these changes
Jun 11, 2026
antiagainst
left a comment
Member
There was a problem hiding this comment.
Awesome! Looks large change but mostly moving code around and fleshing out kernel interface and registration. Just two nits from me.
panditsa
added a commit
to panditsa/tokenspeed
that referenced
this pull request
Jun 12, 2026
Squashed warp-decode work (coop-LDS stage1 + per-M split-K stage2, interleave/ K-tail/scale fixes) for rebase onto the PR lightseekorg#374 MoE-API refactor. Full per-commit history preserved in backup/gptoss-warp-decode-moe-* . Signed-off-by: Sanket Pandit <sanket.pandit@amd.com>
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.
Summary
This PR moves moe backend concepts into tokenspeed kernel. MoE will be a platform-agnostic layer that invoke moe kernel api.
MoE entrypoint
Introduce a single
moe_applyapi. Under the hood it can launch a single or more multiple kernels depending on the implementation. This api is too coarse from kernel-level. Moving forward, we will replace it as a kernel execution plan.See
tokenspeed-kernel/python/tokenspeed_kernel/ops/moe/__init__.py.Supported type and backend
Currently I keep the following weight dtype + implementation:
Other data types are not actively used in our current target models. Also drop the past triton backend for fp8/unquant, which has convoluted dependencies. A portable impl for fp8/unquant which can run amd gpu will be added later. Also renamed the backend name for 'triton_kernel' to 'triton'.
Kernel early selection
MoE is different from attention where the weights need to be preshuffled after model loaded. The preshuffle and actual moe impl are tightly coupled. So we need to determine the kernel implementation earlier, before engine accepts incoming requests.
This is done by adding a specific
moe_planutility function. It will select the corresbonding moe kernel based on various features and the current platform. The selection is encoded into a dict which includes the target kernel name, which will be passed tomoe_apply.AMD Gluon kernel
Decouple amd gluon kernel from other kernel utilit by copying used code into
tokenspeed-kernel-amdmodule. This includes 3 partsSee:
tokenspeed-kernel-amd/python/tokenspeed_kernel_amd/ops/moe/utils.pyfor ported triton kernel code.Currently I lower the priority for the gluon kernel due to known performance issue.