Repository navigation
Conversation
[ghstack-poisoned]
This was referenced Feb 23, 2024
Closed
[ghstack-poisoned]
payoto
pushed a commit
to graphcore-research/torchtitan-fork
that referenced
this pull request
Feb 7, 2025
Two basic tests on the method `is_metrics_rank` to check the Github action setup is working properly. Additionally, removed the couple of imports using `torchtitan.torchtitan` pattern.
weifengpy
added a commit
to weifengpy/torchtitan-flexshard
that referenced
this pull request
Oct 9, 2026
The flex_shard backend rejected CUDA graphs (training.disable_cuda_graphs=False, the recipes' default). Like FSDP2, FlexShard needs nothing capture-specific: its training step is self-contained, finishing within the step everything it starts (prefetches, all-gathers, reduce-scatters, finalization). The trainer's wrapper can then run its eager warmup steps, capture the forward-backward once and replay it. meta-pytorch/flex_shard#66 tests FlexShard under that capture pattern; FlexShard needs no code change for it beyond pytorch#65. This lifts the rejection and updates the README. Tests: - test_flex_shard.py: test_matches_fsdp2_with_cuda_graphs trains the DeepSeek V3 debug model through the trainer's wrapper (wrap_fwd_bwd_with_cuda_graph): two eager warmup steps, the captured step and two replays, with the chunked loss, 1 and 2 microbatches, and reshard after forward "default" and "never". Losses, grad norms, gradients and parameters are bitwise equal to FSDP2's with CUDA graphs. EP 1: with EP > 1, torchtitan supports CUDA graphs only with HybridEP, which CI doesn't install. _train now runs each step's microbatches in one forward-backward function, as the trainer does. - test_config_validation.py: flex_shard accepts CUDA graphs; the rejection test uses CPU offload instead. Gates (8 H100s, 10 steps, scripts/loss_compare.py --assert-equal on loss and grad_norm, CUDA graphs on for both backends, FlexShard pytorch#65): - DeepSeek V3 debug model, EP 1: equal at every step; both runs recorded a CUDA graph. - The same with PP 2 Interleaved1F1B: equal; both runs recorded a CUDA graph. - DeepSeek V3 16B, the README comparison's settings except EP 1 and CUDA graphs on: equal at every step. - Throughput, median over steps 4-10 (the replays): 11,248 tokens/s per GPU for FSDP2, 11,286 for FlexShard. - Step 7 on rank 0, a replay: GPU time 1,429.6 vs 1,402.5 ms; exposed communication 52.4 vs 44.3 ms (all-gathers 20.3 vs 14.0, reduce-scatters 20.1 vs 18.9, all-reduces 12.0 vs 11.4). A collective is exposed while its NCCL kernels run and no compute kernel does. - Peak reserved memory 58.86 vs 59.24 GiB. Peak active memory 49.42 vs 51.17 GiB, reached in the eager warmup steps; FlexShard is 1.75 GiB higher from step 1, with or without CUDA graphs. The cause: FlexShard kept two reduce-scatters pending by default, so a second 2,231 MiB packed input of a MoE block was alive at the backward peak. meta-pytorch/flex_shard#67 makes the default one, as in FSDP2. With it, peak active memory is 49.42 vs 49.42 GiB and peak reserved 58.86 vs 57.80 GiB, at 11,174 vs 11,397 tokens/s per GPU and 41.8 vs 41.3 ms of exposed communication. - DeepSeek V3 debug model, EP 4 with HybridEP (non_blocking_capacity_factor 1.0; DeepEP's hybrid-ep branch at 10d4dd7), with and without PP 2 Interleaved1F1B: equal; both runs recorded a CUDA graph. This covers FlexShard's explicit prefetch schedule under EP. - DeepSeek V3 16B, EP 4 with HybridEP, 2 x 4,096 tokens per GPU (4 x 4,096 ran out of memory on FSDP2: HybridEP sizes its buffers for the worst-case routing), FlexShard with pytorch#67: equal at every step. - Throughput, median over steps 4-10: 9,154 vs 9,344 tokens/s per GPU. - Step 7 on rank 0: GPU time 866.0 vs 852.5 ms; exposed communication 32.9 vs 32.3 ms. - Peak active memory 57.46 vs 57.59 GiB; peak reserved 65.56 vs 66.36 GiB. ghstack-source-id: c7887f3 ghstack-comment-id: 6075195472 Pull-Request: #18
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.
Stack from ghstack (oldest at bottom):