Skip to content

[Paged Stash] Add README for cuda_graphable_moe experiment - #3217

Closed
syed-ahmed wants to merge 21 commits into
mainfrom
gh/syed-ahmed/5/head
Closed

syed-ahmed wants to merge 21 commits into
mainfrom
gh/syed-ahmed/5/head

Conversation

@syed-ahmed

@syed-ahmed syed-ahmed commented May 4, 2026 •

Copy link
Copy Markdown
Collaborator

syed-ahmed added 3 commits May 4, 2026 15:17
- Add AVAILABLE_MEMORY_POLICIES registry to passes.py so experiments can
  register custom memory policies without modifying graph_trainer code.
- Refactor tag_with_memory_policy_pass to dispatch via the registry.
- Change memory_policy config from Literal to str for extensibility.
- Add _get_extra_graph_passes hook to GraphTrainer for subclasses to
  inject additional graph passes into the aot_fx_trace pipeline.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

[ghstack-poisoned]
Paged stash SAC for MoE expert activations: pre-allocated paged buffers
store dynamic-shaped _grouped_mm outputs for the backward pass, avoiding
both recomputation cost and memory fragmentation from variable token counts.

- Joint-graph pass (paged_stash_graph_pass.py): inserts paged_stash.copy/pop
  ops using ao's stream infrastructure, redirecting backward consumers through
  paged buffers so SAC+remat naturally ignores stashed activations.
- PagedStashTrainer (train.py): extends GraphTrainer with 3-level overflow
  defense (host spillover, cross-rank detection, retry with buffer growth).
- Memory policy registration: paged_stash and paged_stash_save_only policies.
- Fine-grained annotation via annotate_fn on _run_experts_grouped_mm.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

[ghstack-poisoned]
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

[ghstack-poisoned]
root added 2 commits May 5, 2026 20:17
…e_moe experiment"

Co-Authored-By: Claude Opus 4.7 (1M context) <noreplyanthropic.com>

[ghstack-poisoned]
Co-Authored-By: Claude Opus 4.7 (1M context) <noreplyanthropic.com>

[ghstack-poisoned]
@syed-ahmed syed-ahmed changed the title [Paged Stash] Add README for cuda_graphable_moe experiment [GraphTrainer] Add paged stash memory policy documentation May 6, 2026
@syed-ahmed syed-ahmed changed the title [GraphTrainer] Add paged stash memory policy documentation [Paged Stash] Add README for cuda_graphable_moe experiment May 6, 2026
syed-ahmed added 4 commits May 7, 2026 11:57
…e_moe experiment"

Co-Authored-By: Claude Opus 4.7 (1M context) <noreplyanthropic.com>

[ghstack-poisoned]
Co-Authored-By: Claude Opus 4.7 (1M context) <noreplyanthropic.com>

[ghstack-poisoned]
…e_moe experiment"

Co-Authored-By: Claude Opus 4.7 (1M context) <noreplyanthropic.com>

[ghstack-poisoned]
Co-Authored-By: Claude Opus 4.7 (1M context) <noreplyanthropic.com>

[ghstack-poisoned]
SherlockNoMad pushed a commit that referenced this pull request May 7, 2026
…#3215)

Stack from [ghstack](https://github.com/ezyang/ghstack) (oldest at
bottom):
* #3218
* #3217
* #3216
* __->__ #3215

- Add AVAILABLE_MEMORY_POLICIES registry to passes.py so experiments can
  register custom memory policies without modifying graph_trainer code.
- Refactor tag_with_memory_policy_pass to dispatch via the registry.
- Change memory_policy config from Literal to str for extensibility.
- Add _get_extra_graph_passes hook to GraphTrainer for subclasses to
  inject additional graph passes into the aot_fx_trace pipeline.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

---------

Co-authored-by: root <[email protected]>

Usage::

CUDA_HOME=/usr/local/cuda NGPU=4 \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why would CUDA_HOME be necessary?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because without it hybrid-ep doesn't know where to look for nvcc to jit its kernels.

--parallelism.tensor_parallel_degree=2 \
--parallelism.expert_parallel_degree=2 \
--training.steps=10 \
compile.memory-policy:paged-stash \

@crcrpar crcrpar May 8, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing "--" and redundant ":"?

Suggested change
compile.memory-policy:paged-stash \
--compile.memory-policy paged-stash \

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Not applicable anymore with the recent rebase.

@syed-ahmed syed-ahmed moved this to In Progress in PyTorch + CUDA May 8, 2026
syed-ahmed and others added 4 commits May 12, 2026 14:12
…e_moe experiment"

Co-Authored-By: Claude Opus 4.7 (1M context) <noreplyanthropic.com>

[ghstack-poisoned]
Co-Authored-By: Claude Opus 4.7 (1M context) <noreplyanthropic.com>

[ghstack-poisoned]
…e_moe experiment"


AI assistant used: Claude Opus 4.7 (1M context) <noreplyanthropic.com>

[ghstack-poisoned]
AI assistant used: Claude Opus 4.7 (1M context) <noreplyanthropic.com>

[ghstack-poisoned]
root added 2 commits September 29, 2026 16:34
…e_moe experiment"


AI assistant used: Claude Opus 4.7 (1M context) <noreplyanthropic.com>

[ghstack-poisoned]
AI assistant used: Claude Opus 4.7 (1M context) <noreplyanthropic.com>

[ghstack-poisoned]
@pytorch-bot pytorch-bot Bot added the ciflow/fake-pg Run 1-GPU Fake PG integration tests label Sep 29, 2026
NGPU=4 MODULE=graph_trainer.deepseek_v3 \
CONFIG=graph_trainer_deepseek_v3_debugmodel_hybridep \
./run_train.sh \
--compile.mode aot_fx_trace \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, we have removed this flag.
aot_fx_trace is the only support mode now.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Updated.

CONFIG=graph_trainer_deepseek_v3_debugmodel_hybridep \
./run_train.sh \
--training.disable_cuda_graphs \
--compile.mode aot_fx_trace \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment on lines +151 to +153
- PP and CUDA graphs cannot be combined yet (a torchtitan-wide limitation), so
a single run exercises either the CUDA-graph path or the GraphPP path, not
both.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cudagraph is recently enabled with PP in titan core.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I'll followup with another paged stashing PR targeting core.

…e_moe experiment"


AI assistant used: Claude Opus 4.7 (1M context) <noreplyanthropic.com>

[ghstack-poisoned]
AI assistant used: Claude Opus 4.7 (1M context) <noreplyanthropic.com>

[ghstack-poisoned]
…e_moe experiment"


AI assistant used: Claude Opus 4.7 (1M context) <noreplyanthropic.com>

[ghstack-poisoned]
AI assistant used: Claude Opus 4.7 (1M context) <noreplyanthropic.com>

[ghstack-poisoned]
…e_moe experiment"


AI assistant used: Claude Opus 4.7 (1M context) <noreplyanthropic.com>

[ghstack-poisoned]
AI assistant used: Claude Opus 4.7 (1M context) <noreplyanthropic.com>

[ghstack-poisoned]
syed-ahmed added a commit that referenced this pull request Oct 8, 2026
Stack from [ghstack](https://github.com/ezyang/ghstack) (oldest at
bottom):
* #3218
* #3217
* __->__ #3216

Paged stash SAC for MoE expert activations: pre-allocated paged buffers
store dynamic-shaped _grouped_mm outputs for the backward pass, avoiding
both recomputation cost and memory fragmentation from variable token
counts.
@syed-ahmed
syed-ahmed changed the base branch from gh/syed-ahmed/5/base to main October 8, 2026 00:36
@syed-ahmed

Copy link
Copy Markdown
Collaborator Author

Merged in #3218.

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

Labels

ciflow/fake-pg Run 1-GPU Fake PG integration tests ciflow/8gpu CLA Signed This label is managed by the Meta Open Source bot.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants