transformers
6b11f3a2 - [distributed] Add sequence parallelism: DistributedConfig(sp_size=N)

Commit
7 hours ago
[distributed] Add sequence parallelism: DistributedConfig(sp_size=N) `sp_size` splits every sequence across the ranks of an `sp` mesh, which get the same batch and keep a contiguous slice each. The plan follows the other parallelisms: a `base_model_sp_plan` default in `PreTrainedConfig`, an `sp_plan` override merged and expanded like `tp_plan`, and `apply_sequence_parallelism` installing the plan's styles after TP/EP and before FSDP2. The model keeps taking whole sequences: the first decoder layer cuts `hidden_states`, every layer cuts the rotary embeddings, the model-built mask and positions stay whole, and the loss is the one of the whole sequences. FSDP2 shards over `sp`, and `dp_size` counts the sp ranks. `fsdp_size`, `tp_size`, `pp_size` and `ep_size` are refused with it for now, and so is the `Trainer`, whose dataloader would split the batch across an sp group.
Author
Committer
Parents
Loading