Repository navigation
[graph_trainer] Overlap chunk-owned paged stashing with HybridEP - #5541
Draft
sanketpurandare wants to merge 1 commit into
Draft
sanketpurandare wants to merge 1 commit into
sanketpurandare wants to merge 1 commit into
Conversation
sanketpurandare
added this pull request to stack #5544
October 19, 2026 17:47
sanketpurandare
force-pushed
the
ep-overlap-04-paged-stashing
branch
from
October 19, 2026 20:07
a5021cf to
38d44cb
Compare
sanketpurandare
force-pushed
the
ep-overlap-04-paged-stashing
branch
3 times, most recently
from
October 20, 2026 13:14
02b1f07 to
5245315
Compare
sanketpurandare
force-pushed
the
ep-overlap-04-paged-stashing
branch
from
October 20, 2026 17:54
5245315 to
757fef8
Compare
Annotate chunk-owned stash, reload, waits and joins and preserve page queue order and copy-input lifetimes while scheduling native EP and independent compute. Keep immediate residency and terminal alias-aware joins explicit in the graph; preserve deferred overflow reporting through full CUDA replay. Compose paging with either selective recomputation or explicit no activation recomputation. The no-remat policy reuses existing save-all tagging and runner behavior, so matched controls do not hide SAC. Keep the real FX policy and no-remat eager full-CUDA exact loss/norm regressions in this owning commit; PP consumes the same policy unchanged. Calibrate with compact live prefixes rather than retaining every capacity-padded activation before stash buffers exist. Reload restores the existing capacity shape and meaningful live bytes without new shape metadata, recomputation, or backend changes. Preserve full-count and unpaged-rerun identity, and cover zero, partial, and full data/block-scale storage and lifetime contracts through the real ops. Use one high-priority paging stream with an environment-controlled CTA maximum. Preserve each explicit source's issue/lifetime order while allowing independent multiplexed sources to interleave; the stream serializes freelist mutations and per-slot records remain FIFO. Check real captured kernel-node priorities, launch grids and exact replay bytes rather than relying on CUPTI replay-lane priorities. Reserve only the terminal eager chunk's wgrad-only branch until its backward combine is issued, using actual parameter-gradient, chunk and paging annotations and data dependencies. Shared experts, the earlier backward chunk and unchunked PP stay available; waits remain late. Assert dispatch/shared-expert and combine/wgrad order on real native paged and unpaged graphs. Vectorize existing copy/pop loops into page-aligned flat multi-token tiles. Resolve each page once per tile, preserve byte payloads and the original allocator, host spill, overflow and FIFO protocol, and mask partial pages with 64-bit addressing. Exercise small grids, non-divisible rows, arbitrary BF16/FP8 bytes and changing device counts in full CUDA-graph replay.
sanketpurandare
force-pushed
the
ep-overlap-04-paged-stashing
branch
from
October 21, 2026 01:25
757fef8 to
ed5c1c1
Compare
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.
AI-Generated Details
Prepared with Codex from the author's explicit HybridEP and paging design.
Bind live counts, final-consumer stash commits, reloads, prefetches and waits to
source layer/chunk annotations. Preserve native requests, copy-input lifetimes
and each source's page issue order while scheduling independent compute. The
single high-priority paging stream serializes freelist mutations; independent
multiplexed F/B sources can interleave without an extra whole-backward-before-
forward chain. Per-slot records remain FIFO.
Waits remain late. For eager paging, reserve only the terminal backward chunk0's
wgrad-only branch until its own combine launches. Existing gradient/chunk/paging
annotations and dataflow identify that branch; shared experts, chunk1 and
unchunked PP remain eligible for earlier exchanges. No shape/name classifier,
new annotation key, timing threshold or compute resource limit.
Vectorize the existing copy/pop loops into page-aligned multi-token tiles. Resolve
one page per tile instead of duplicating page metadata per element. Only its first
tile records/recycles the page; live-prefix and page-tail masks preserve payload
bytes with 64-bit addressing. CUDA allocation, host spill, sticky overflow and
FIFO semantics are unchanged.
TORCHTITAN_PAGED_STASH_MAX_CTAS, set before import,bounds the grid (default 2048), not capacity or copied rows. Compute retains its
normal launch geometry. The copy layout no longer claims to be verbatim Megatron.
Paging composes with selective recomputation (
sac_and_paged_stash) or explicitsave-all (
none_and_paged_stash,activation_remat = None). Both benchmark armspage activations; no-overlap controls expose paging overhead too. Deferred
overflow handling and device-side optimizer skipping stay outside the CUDA
callable. Calibration parks independent live prefixes, avoiding padded retention
before buffers exist, and reload restores the original capacity shape; full-count
inputs and unpaged reruns retain their identity.
Verification
Combined-stack tree
9542fd0f3872179b0f9c4042a8bb85107f56908bpassed 69 focusedcases and 3 full-CUDA numerical comparisons: no-AC SPMD, no-AC combined PP and
DualPipeV with paging. Real 16B graph inspection checks all 26 terminal eager
combines before both expert wgrads. Local 16B SPMD/PP loss/norm pairs are exact;
active/reserved memory and replay kernel counts match their controls.
The existing paging suite exercises real byte copies, wrapped allocation and
recycling, changing device counts in CUDA replay, non-divisible/large hidden
sizes, BF16/FP8 payloads, host spill and overflow. Native graph tests use actual
source markers/paging passes, not patched metadata. Captured priorities/grids,
wait/input lifetimes and backend capacity contracts are checked.
Local 64-CTA PP profiling regressed throughput despite faster bounded copies,
so that scale setting was rejected. Resource bounds require actual model trace
and throughput evidence. New 32/64-GPU speedup and near-total hiding are not
claimed here; the target remains 1.2x. Owned lint/doc hooks passed; the untouched
video optional-time-base typing baseline is outside EP scope.