feat: experimental two-phase (head-chunked) Ulysses all-to-all#428
Open
csgoogle wants to merge 1 commit into
Open
feat: experimental two-phase (head-chunked) Ulysses all-to-all#428csgoogle wants to merge 1 commit into
csgoogle wants to merge 1 commit into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
7240f50 to
0d936f8
Compare
Perseus14
reviewed
Jun 24, 2026
| # math is identical to the single-shot path (heads are independent); requires | ||
| # async-collective LIBTPU flags to actually overlap, and the per-chunk head | ||
| # count must still be shardable across the context axis. | ||
| num_chunks = int(os.environ.get("ULYSSES_ATTENTION_CHUNKS", "1")) |
Collaborator
There was a problem hiding this comment.
Let's move this to config file to be used for any ulysses type kernel
| f"got heads={num_heads} and context_shards={num_shards}." | ||
| ) | ||
|
|
||
| # EXPERIMENTAL: split the all-to-all into `num_chunks` head-groups so XLA's |
Collaborator
There was a problem hiding this comment.
Does this work on ulysses + ring as well?
Collaborator
Author
There was a problem hiding this comment.
yes, updated the code.
14eb661 to
e09195e
Compare
ec4e407 to
064a87f
Compare
prishajain1
reviewed
Jul 13, 2026
064a87f to
8287cb6
Compare
Add a ulysses_attention_chunks attention config to split the Ulysses all-to-all into head-group passes. The chunked path lets XLA overlap all-to-all collectives with head-parallel local attention compute while preserving the existing single-shot path by default. Apply the same chunking to plain Ulysses and Ulysses+Ring, and allow the final chunk to carry the remainder when the requested chunk count does not divide the Ulysses head groups evenly. Add mocked attention tests for numerical and layout equivalence across chunk counts.
8287cb6 to
cb463cf
Compare
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.
Description
Overview
This PR introduces the ulysses_attention_chunks attention config, which splits the Ulysses all-to-all communication into head-group passes. This chunked path allows XLA to overlap all-to-all collectives with head-parallel local attention compute, while preserving the existing single-shot path by default.
Key Changes
Performance Results & Impact
We ran a comprehensive matrix of benchmarks on Wan 2.2 at both 480p and 720p resolutions, testing across cp=4 and cp=8 . By splitting into chunks ( chunks=2 and
chunks=5 ), we observed consistent generation time improvements due to XLA communication overlapping compute:
We observe greater performance gains when the all-to-all communication time is comparable to or dominates the attention compute time, as demonstrated by the 480p resolution benchmarks where communication overhead is more pronounced.
Internal doc: go/ulysses-chuncked