transformers
2cf9f889 - [distributed] Add the context parallel module, with Ulysses

Commit
8 hours ago
[distributed] Add the context parallel module, with Ulysses Each rank of a `cp` device mesh holds a contiguous slice of every sequence. The plan pairs two kinds of styles: `cp_split_sequence` cuts the layer inputs to that slice, and an attention style, `cp_ulysses`, runs the attention call of the attention modules over the whole sequence, with the mask and the keyword arguments the model built before the sequence was cut. Ulysses is two all-to-all exchanges around the model's own attention function; another algorithm is a `ContextParallelAttention` subclass registered in `ALL_PARALLEL_STYLES`. The styles share `ContextParallelLayer`, with the `install_forward` contract of the TP and EP styles. `apply_context_parallelism` installs a resolved plan on a model, and `ModelContextParallel` on the model itself: the model checks, a forward without a cache, and the loss of the whole sequences, which every rank reports. Not wired into `DistributedConfig` yet: nothing changes for users.
Author
Parents
Loading