Skip to content

Commit 7b7b1f4

Browse files
committed
added unified attention docs and removed test file
1 parent 2797619 commit 7b7b1f4

File tree

2 files changed

+19
-131
lines changed

2 files changed

+19
-131
lines changed

docs/source/en/training/distributed_inference.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,4 +289,22 @@ Pass the [`ContextParallelConfig`] to [`~ModelMixin.enable_parallelism`].
289289

290290
```py
291291
pipeline.transformer.enable_parallelism(config=ContextParallelConfig(ulysses_degree=2))
292-
```
292+
```
293+
294+
### Unified Attention
295+
296+
[Unified Sequence Parallelism](https://huggingface.co/papers/2405.07719) combines Ring Attention and Ulysses Attention into a single approach for efficient long-sequence processing. It applies Ulysses's *all-to-all* communication first to redistribute heads and sequence tokens, then uses Ring Attention to process the redistributed data, and finally reverses the *all-to-all* to restore the original layout.
297+
298+
This hybrid approach leverages the strengths of both methods:
299+
- **Ulysses Attention** efficiently parallelizes across attention heads
300+
- **Ring Attention** handles very long sequences with minimal memory overhead
301+
- Together, they enable 2D parallelization across both heads and sequence dimensions
302+
303+
[`ContextParallelConfig`] supports Unified Attention by specifying both `ulysses_degree` and `ring_degree`. The total number of devices used is `ulysses_degree * ring_degree`, arranged in a 2D grid where Ulysses and Ring groups are orthogonal (non-overlapping).
304+
Pass the [`ContextParallelConfig`] with both `ulysses_degree` and `ring_degree` set to bigger than 1 to [`~ModelMixin.enable_parallelism`].
305+
306+
```py
307+
pipeline.transformer.enable_parallelism(config=ContextParallelConfig(ulysses_degree=2, ring_degree=2))
308+
```
309+
310+
Unified Attention is to be used when there are enough devices to arrange in a 2D grid (at least 4 devices).

tests/others/test_unified_sp_attention.py

Lines changed: 0 additions & 130 deletions
This file was deleted.

0 commit comments

Comments
 (0)