Repository navigation
modify data split to use HF api - #65
Merged
Merged
Conversation
[ghstack-poisoned]
Just found out that HF dataset has its own [API](https://huggingface.co/docs/datasets/v2.17.0/en/package_reference/main_classes#datasets.distributed.split_dataset_by_node) to do data split (across DP ranks). Verified that it has the expected data behavior (same on SP ranks, different on DP ranks). Note: This is still a map-style dataset, that has to be loaded in memory. Setting `streaming=True` for [load_dataset](https://huggingface.co/docs/datasets/v2.17.0/en/package_reference/loading_methods#datasets.load_dataset) returns an IterableDataset whose data doesn't have to fit in memory, but the data loading speed is significantly slower. [ghstack-poisoned]
philippguevorguian
pushed a commit
to YerevaNN/YNNtitan
that referenced
this pull request
Aug 17, 2024
ghstack-source-id: e23d5e0 Pull Request resolved: pytorch#65
payoto
pushed a commit
to graphcore-research/torchtitan-fork
that referenced
this pull request
Feb 7, 2025
Adding FP8 version, removing multinode one.
This was referenced Oct 9, 2026
Merged
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
weifengpy
added a commit
to weifengpy/torchtitan-flexshard
that referenced
this pull request
Oct 20, 2026
The flex_shard PRs this fork uses have landed on meta-pytorch/flex_shard main: pytorch#51 through pytorch#77, ending at 7cdaf16 (pytorch#48 to pytorch#62 were re-landed as pytorch#96 to pytorch#103). The DeepSeek V3 16B reproduction now installs FlexShard from main instead of gh/weifengpy/55/head, the head of pytorch#65, which lacks pytorch#66 to pytorch#77: torchtitan-flexshard#20's fake backend for a size-1 edp_shard needs pytorch#71, and this fork's DistMuon (#22 to #27) needs pytorch#73 to pytorch#77. Checked: pip resolves git+https://github.com/meta-pytorch/flex_shard.git@main, and the fork's main (fa7a9b1) passes its 18 FlexShard and 9 DistMuon GPU tests (tests/unit_tests/gpu/test_flex_shard.py, tests/unit_tests/gpu/flex_shard/test_dist_muon.py) against flex_shard 7cdaf16. ghstack-source-id: 09ed3f5 ghstack-comment-id: 6284173360 Pull-Request: #43
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):
Just found out that HF dataset has its own API to do data split (across DP ranks). Verified that it has the expected data behavior (same on SP ranks, different on DP ranks).
Note: This is still a map-style dataset, that has to be loaded in memory. Setting
streaming=Truefor load_dataset returns an IterableDataset whose data doesn't have to fit in memory, but the data loading speed is significantly slower.