[Perf][MoE] Share FlashInfer B12x MoE workspaces across layers - #53081
Draft
lucifer1004 wants to merge 1 commit into
Draft
[Perf][MoE] Share FlashInfer B12x MoE workspaces across layers#53081lucifer1004 wants to merge 1 commit into
lucifer1004 wants to merge 1 commit into
Conversation
Every MoE layer allocated its own B12xMoEWrapper workspaces, which is a large per-layer GPU memory cost. The workspaces are identical for every layer and layers execute sequentially, so all layers in a worker process can share the buffers allocated by the first wrapper. Depends on flashinfer-ai/flashinfer#4603, which adds the shared_static_workspace / shared_dynamic_workspace / shared_output parameters to B12xMoEWrapper. Signed-off-by: Zihua Wu <13583761+lucifer1004@users.noreply.github.com>
lucifer1004
force-pushed
the
b12x-shared-workspaces
branch
from
August 20, 2026 09:01
9c6feca to
790ab3a
Compare
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.
What
Share the FlashInfer B12x MoE workspaces across layers within each worker process.
Today every MoE layer constructs its own
B12xMoEWrapperwith its own static workspace, dynamic workspace, and output buffer. For large-expert-count models this is a substantial per-layer GPU memory cost (e.g. ~640 MiB per layer on a 384-expert NVFP4 shape — 60+ GiB across layers). The workspaces are identically shaped for every layer and layers execute sequentially, so all layers can share the buffers allocated by the first wrapper.Dependency
Depends on flashinfer-ai/flashinfer#4603, which adds the
shared_static_workspace/shared_dynamic_workspace/shared_outputparameters toB12xMoEWrapper. This PR is opened as a draft until that lands and the FlashInfer version pin is updated; with an older FlashInfer the new keyword arguments would raiseTypeErrorat model init.Notes
(global_num_experts, topk, hidden_dim, intermediate_size_per_partition, max_num_tokens, activation, device); layers with a different MoE config allocate their own buffers.