[Dev] Reuse caller-owned HybridEP dispatch and expert output buffers - #6800
Draft
lhb8125 wants to merge 6 commits into
Draft
[Dev] Reuse caller-owned HybridEP dispatch and expert output buffers#6800lhb8125 wants to merge 6 commits into
lhb8125 wants to merge 6 commits into
Conversation
lhb8125
force-pushed
the
denliu/hybridep-caller-provided-buffer
branch
from
August 25, 2026 11:02
7018b40 to
4b8deef
Compare
lhb8125
force-pushed
the
denliu/hybridep-caller-provided-buffer
branch
from
August 26, 2026 15:52
85407be to
0a454aa
Compare
This was referenced Aug 28, 2026
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 draft bounds two HybridEP cross-stream allocation patterns with caller-owned persistent buffer rings:
The final-consumer release points are intentional. A generic
ScheduleNode.free_inputownership probe must not mutate ring state because an old alias can be encountered after the same storage has already been acquired by a later operation.Configuration
Both paths require a static HybridEP output bound from
moe_expert_rank_capacity_factorormoe_pad_expert_input_to_capacity.Dispatch-output reuse additionally requires HybridEP flex dispatch, EP communication overlap, FP8/FP4 expert GEMMs, and a DeepEP
dispatch_with_permute(..., output_token=...)API.Expert-output reuse requires the Transformer Engine op fuser and grouped MLP. It depends on Transformer Engine PR #3161 (GroupedLinear caller-provided output), plus a cuDNN frontend wrapper that forwards the caller output pointer. Megatron fails early if the TE API is unavailable.
Motivation
A 64-GPU DeepSeek-V3 MBS2 allocator snapshot showed 9 HybridEP dispatch outputs × 1,078 MiB = 9.47 GiB in the caching allocator pending-free queue at the max-active point. Those buffers are logically dead after grouped-MLP consumption, but the generic allocator cannot infer the higher-level producer/consumer ordering across streams.
FC2/grouped-GEMM outputs have the analogous lifetime:
The application-owned rings make these final-consumer dependencies explicit without a CPU or stream-wide synchronization and bound the amount of persistent output storage.
Validation
dev: Black, isort, pylint (10.00/10), and ruff passed.Known limitations
fused_group_mlpactivation offload because that path releases the persistent dispatch input storage.