Repository navigation
[CUDA][QMoE] Wire LaunchFusedRouteMaps into CutlassMoeFCRunner for S<=8 and E<=512 - #33596
Open
Tianlei Wu (tianleiwu) wants to merge 2 commits into
Open
Tianlei Wu (tianleiwu) wants to merge 2 commits into
Tianlei Wu (tianleiwu) wants to merge 2 commits into
Conversation
…-expert routing Extend isFusedMoeRoutingSupported and launchFusedRoutingBuildExpertMaps in moe_kernels.cu to dispatch to onnxruntime::cuda::LaunchFusedRouteMaps (FusedSoftmaxTopKMapsKernel) when CanUseFusedRouteMaps(num_tokens, num_experts, experts_per_token) holds (e.g. num_tokens <= 8, num_experts <= 512, experts_per_token <= 16 for FP16/BF16 router logits), while preserving the single-warp fusedRoutingBuildExpertMapsSingleTokenKernel fast path for num_tokens == 1 && num_experts <= 32. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The eligibility helper is undefined, the launcher call is incompatible with the existing API, and the new path lacks regression coverage.
3 open issues
What changed in this PR
This PR aims to reduce CUDA INT4 QMoE routing overhead by integrating fused routing and expert-map generation into CutlassMoeFCRunner for small token batches and larger expert counts.
Changes:
- Extends fused-routing eligibility beyond the existing single-token, ≤32-expert path.
- Adds FP16/BF16 dispatch to
LaunchFusedRouteMaps, while preserving the existing small-expert kernel. - Passes the token count into the routing launcher.
| File | Description |
|---|---|
onnxruntime/contrib_ops/cuda/llm/moe_gemm/moe_kernels.cu |
Extends routing eligibility and connects the runner to fused route-map generation. |
Review effort: Balanced
…l and fallback, and add tests Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This branch has not been deployed
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.


Description
isFusedMoeRoutingSupportedinonnxruntime/contrib_ops/cuda/llm/moe_gemm/moe_kernels.cuto queryonnxruntime::cuda::CanUseFusedRouteMaps(num_tokens, num_experts, experts_per_token)when(num_tokens == 1 && num_experts <= 32)does not apply.launchFusedRoutingBuildExpertMapsto dispatch toonnxruntime::cuda::LaunchFusedRouteMaps<T>(FusedSoftmaxTopKMapsKernel) forhalfand__nv_bfloat16router logits whennum_tokens > 1ornum_experts > 32, while preservingfusedRoutingBuildExpertMapsSingleTokenKernelfornum_tokens == 1 && num_experts <= 32.Motivation and Context
FusedSoftmaxTopKMapsKernel(LaunchFusedRouteMapsinqmoe_fused_route.cuh) was already used by the INT2/INT3 fast path inmoe_quantization.ccfor1 <= num_tokens <= 8,64 <= num_experts <= 512,experts_per_token <= 16, butisFusedMoeRoutingSupportedinmoe_kernels.cuonly allowednum_tokens == 1 && num_experts <= 32.num_experts = 512and speculative verification batches (S = 8) fell back to two separate kernel launches per layer (SoftmaxTopKMergeKernel+fusedBuildExpertMapsSortFirstToken,~9.0 µs/layer).LaunchFusedRouteMapsintoCutlassMoeFCRunnerreplaces both launches with a single-CTAFusedSoftmaxTopKMapsKernel(4.31 µs/layeron H200 atS = 8, E = 512, K = 10), eliminating 1 kernel launch and~4.7 µsper INT4 MoE layer (48launches /~0.22 msper 48-layer decode cycle).