Repository navigation
Conversation
This was referenced Nov 9, 2026
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
3outeille
force-pushed
the
cp-11-trainer
branch
from
November 10, 2026 02:51
06310a9 to
0291cac
Compare
3outeille
force-pushed
the
cp-11-trainer
branch
from
November 10, 2026 03:01
0291cac to
d3f12fb
Compare
3outeille
force-pushed
the
cp-11-trainer
branch
from
November 10, 2026 05:19
d3f12fb to
41ec5d2
Compare
3outeille
force-pushed
the
cp-11-trainer
branch
from
November 10, 2026 05:45
41ec5d2 to
b056220
Compare
3outeille
force-pushed
the
cp-11-trainer
branch
2 times, most recently
from
November 12, 2026 06:19
3719a79 to
2a753bb
Compare
3outeille
force-pushed
the
cp-11-trainer
branch
from
November 12, 2026 07:15
2a753bb to
55fda3f
Compare
3outeille
force-pushed
the
cp-11-trainer
branch
from
November 12, 2026 08:01
55fda3f to
22e3bd9
Compare
3outeille
force-pushed
the
cp-11-trainer
branch
from
November 12, 2026 09:14
22e3bd9 to
128e5d7
Compare
3outeille
force-pushed
the
cp-11-trainer
branch
from
November 20, 2026 06:58
b4ac00d to
ef0b392
Compare
distributed] Train a model with context parallelism in Trainerdistributed] Train a model with sequence parallelism in Trainer
3outeille
force-pushed
the
cp-11-trainer
branch
from
November 20, 2026 08:49
ef0b392 to
8c73587
Compare
3outeille
force-pushed
the
cp-11-trainer
branch
from
November 30, 2026 06:28
8c73587 to
3cdee72
Compare
3outeille
force-pushed
the
cp-11-trainer
branch
from
November 30, 2026 07:09
3cdee72 to
ccc9127
Compare
3outeille
force-pushed
the
cp-11-trainer
branch
4 times, most recently
from
December 3, 2026 07:15
4038af3 to
e398b6a
Compare
`Trainer` trains a model loaded with `DistributedConfig(sp_size=N)` like a model on a single device. Its dataloader mesh is `(dp_shard, cp, tp)` — the `cp` dim holds the `sp` size, the name Accelerate's dataloader shards over — so the ranks of an sp group (and of a tp group) get the same batch and only the data parallel ranks split them. The token count that normalizes the loss counts each sequence once, the logged loss is the loss of the full sequences, and the per-rank token and FLOP counts gathered over every rank are divided by the batch replicas. Evaluation supports the loss only: each rank holds the logits of its own slice of the sequences, so `predict` refuses to gather them. The refusal added with `DistributedConfig(sp_size=N)` goes away. The script trains a tiny model through `Trainer` with sp / tp / fsdp sizes and writes the loss, the gradient norm, the evaluation loss and the token count, so the test compares five configurations against a single-device run of the same samples.
…ngle device `sp_distributed_config.py` trains a tiny model through `Trainer` with sp / fsdp / tp sizes and writes the loss, the gradient norm, the evaluation loss and the token count of two steps. Five configurations (sp, sp with gradient accumulation, fsdp x sp, tp x sp, and sp with tokens not averaged across devices) are compared with a single-device run of the same samples, launched with one process so that the reference does not use `DataParallel`.
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.
What does this PR do?
Stack: #50493 → #50496 → #50796 → #50511 → #50514 → this PR → #50522
Adds [
Trainer] support for models loaded withDistributedConfig(sp_size=N)(including combinations with FSDP2/HSDP and TP), while keeping Accelerate's DeepSpeed Ulysses SP path intact.model.sp_size(matchingtp_size/fsdp_size), unifyTrainer.get_sp_size()acrossDistributedConfigand Accelerate'sParallelismConfig, and reject combining both.(dp_shard, cp, tp)device mesh to Accelerate so ranks in the same(sp, tp)group receive the same batch (using thecpdim name that Accelerate's dataloader expects, without enabling Accelerate's CP).num_items_in_batch(whenaverage_tokens_across_devices=True), loss scaling,num_input_tokens_seen, and FLOPs across replicated(sp, tp)ranks.prediction_loss_only=True) and raise otherwise, since logits remain sequence-sharded on each rank.Tests
test_sequence_parallelintests/trainer/distributed/test_trainer_distributed_transformers.pycompares step losses, grad norms,eval_loss, andnum_input_tokens_seenagainst a single-process baseline:sp=2sp=2, grad accum 2fsdp=2 × sp=2, grad accum 2tp=2 × sp=2sp=2,average_tokens_across_devices=FalseVerified alongside the existing FSDP/HSDP, Accelerate CP (
test_cp_equivalence), and DeepSpeed Ulysses SP (test_alst_ulysses_sp) distributed Trainer tests.