transformers
2527f4ab - [distributed] Train a model with sequence parallelism in Trainer

Commit
16 hours ago
[distributed] Train a model with sequence parallelism in Trainer `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.
Author
Committer
Parents
Loading