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 12, 2026 09:29
128e5d7 to
ab3ea9c
Compare
3outeille
force-pushed
the
cp-11-trainer
branch
from
November 12, 2026 10:09
ab3ea9c to
bba8dec
Compare
`Trainer` trains a model loaded with `DistributedConfig(cp_size=N)` like a model on a single device. Its dataloader mesh is `(dp_shard, cp, tp)`, so the ranks of a cp 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(cp_size=N)` goes away. The script trains a tiny model through `Trainer` with cp / 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.
…gle device `cp_distributed_config.py` trains a tiny model through `Trainer` with cp / fsdp / tp sizes and writes the loss, the gradient norm, the evaluation loss and the token count of two steps. Five configurations (cp, cp with gradient accumulation, fsdp x cp, tp x cp, and cp 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`.
3outeille
force-pushed
the
cp-11-trainer
branch
from
November 12, 2026 10:32
bba8dec to
7633829
Compare
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 → #50511 → #50514 → #50499 → this PR → #50522
[
Trainer] can now train a model loaded withDistributedConfig(cp_size=N), also combined withfsdp_sizeandtp_size.Trainergives Accelerate's dataloader a(dp_shard, cp, tp)device mesh, so the batches are split over the data parallel ranks only. Accelerate's own context parallelism is not used: the model shards its own inputs.num_items_in_batch, the loss scale,num_input_tokens_seenand the FLOPs count each batch once per data parallel group, not once per cp rank.predictand metrics on logits raise, because each rank only holds the logits of its own slice.Trainerdoes not build theParallelismConfigit builds for TP models, because that model'sdp_sizecounts the cp ranks.Tests
test_context_parallelintests/trainer/distributed/test_trainer_distributed_transformers.pyruns the same samples twice, once with CP and once in a single process. It compares the per-step loss, the grad norm, the eval loss andnum_input_tokens_seen:average_tokens_across_devices=FalseAll cases pass on 4× H100 (NCCL) and on CPU (gloo). The existing FSDP / HSDP Trainer tests pass too.