Perf/pytorch block fp8 moe decode - #4956
Draft
qescccczmr wants to merge 2 commits into
Draft
qescccczmr wants to merge 2 commits into
qescccczmr wants to merge 2 commits into
Conversation
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
The existing PyTorch Block-FP8 MoE path may launch GEMM CTAs for every local
expert during small-batch decode, even though only a small subset of experts
receives tokens. For example, with
M=1,top-k=8, andE=256, at most eightexperts are active while the original dense expert grid still covers all 256
experts.
The activation path also materializes the BF16 SwiGLU result before launching
a separate FP8 quantization kernel:
This PR reduces both the inactive-expert launch overhead and the intermediate
activation traffic in Block-FP8 MoE decode.
Modification
Active-expert block scheduling
Add an opt-in active-block dispatch:
The path reuses the existing compact MoE kernel and routed-block metadata, but
launches GEMM programs only for expert blocks that receive tokens.
Dispatch is selected using backend properties only:
There are no model-name checks. Unknown or unsupported shapes retain the
existing schedule. The optimization also falls back for unsupported expert
layouts, dtypes, GPUs, and tensor shapes.
Fused SwiGLU and FP8 quantization
Fuse
silu_and_mulwith group-wise FP8 quantization for the default Block-FP8MoE activation:
This removes one kernel launch and avoids materializing and rereading the BF16
activation. Custom activation functions continue using the existing fallback.
Performance
End-to-end active-block scheduling
Environment:
The baseline and candidate both used the fused SwiGLU/quant path, so this table
isolates the contribution of active-block scheduling.
SwiGLU and FP8 quantization microbenchmark
The benchmark used the TP8 local routed-MoE shape with
top-k=8and localintermediate size 256.
This is an operator-level result and is not added directly to the end-to-end
active-block gain.
BC-breaking
No backward-incompatible API changes are introduced.
The active-block schedule is opt-in, and unsupported shapes fall back to the
existing implementation. The fused activation preserves the established
custom-activation fallback.
Correctness and validation
quant_fp8(silu_and_mul(x))for the measured shapes.97 passed.py_compileandgit diff --checkpass.Commands:
Checklist