Skip to content

[graph_trainer] Overlap chunk-owned paged stashing with HybridEP - #5541

Draft
sanketpurandare wants to merge 1 commit into
ep-overlap-03-capacity-budgetfrom
ep-overlap-04-paged-stashing
Draft

sanketpurandare wants to merge 1 commit into
ep-overlap-03-capacity-budgetfrom
ep-overlap-04-paged-stashing

Conversation

@sanketpurandare

@sanketpurandare sanketpurandare commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

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 explicit
save-all (none_and_paged_stash, activation_remat = None). Both benchmark arms
page 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 9542fd0f3872179b0f9c4042a8bb85107f56908b passed 69 focused
cases 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.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 19, 2026
@sanketpurandare
sanketpurandare added this pull request to stack #5544 October 19, 2026 17:47
@sanketpurandare
sanketpurandare force-pushed the ep-overlap-04-paged-stashing branch from a5021cf to 38d44cb Compare October 19, 2026 20:07
@sanketpurandare
sanketpurandare force-pushed the ep-overlap-04-paged-stashing branch 3 times, most recently from 02b1f07 to 5245315 Compare October 20, 2026 13:14
@sanketpurandare
sanketpurandare force-pushed the ep-overlap-04-paged-stashing branch from 5245315 to 757fef8 Compare October 20, 2026 17:54
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
sanketpurandare force-pushed the ep-overlap-04-paged-stashing branch from 757fef8 to ed5c1c1 Compare October 21, 2026 01:25

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant