Add TPU Ulysses context parallelism - #4687
Conversation
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
|
🤖 Hi @huytransformer, I've received your request, and I'm working on it now! You can track my progress in the logs for more details. |
There was a problem hiding this comment.
This Pull Request introduces highly performant TPU Ulysses context parallelism on the TPU Tokamax Splash attention training path. The implementation is exceptionally clean, well-integrated, and backed by comprehensive unit, collective, and integration tests that verify correctness against dense references and compiled HLO collectives.
🔍 General Feedback
- Excellent Test Coverage: The newly added tests (including CPU multi-device mock checks and HLO collective pattern assertions) set a very high bar for correctness and robustness.
- Robust Config Validation: The comprehensive validation in
configs/types.pyensures that unsupported combinations (like MQA, packing, ragged attention, dropout, etc.) are proactively rejected with precise errors. - Clean Shared Utilities: Factoring out mesh and sharding operations into
context_parallel_utils.pyis a great design choice that improves maintainability. - Thorough Documentation: The update to
sharding.mdis incredibly detailed and accurately captures Ulysses constraints and architectural mechanics.
| if self.use_ragged_attention: | ||
| raise ValueError("TPU Ulysses attention does not support ragged attention.") | ||
| if self.config.context_parallel_load_balance: | ||
| raise ValueError("TPU Ulysses attention does not support context_parallel_load_balance.") |
There was a problem hiding this comment.
| raise ValueError("TPU Ulysses attention does not support context_parallel_load_balance.") | |
| if self.config.context_parallel_load_balance: | |
| raise ValueError("TPU Ulysses attention does not support context_parallel_load_balance=True.") |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
Description
Start with a short description of what the PR does and how this is a change from
the past.
The rest of the description includes relevant details and context, examples:
If the change fixes a bug or a Github issue, please include a link, e.g.,:
FIXES: b/123456
FIXES: #123456
You can also provide a comma-separated list. If you don't want to close a bug but
simply to reference it, use BUGS, e.g.:
BUGS: b/123456
Notice 1: Once all tests pass, the "pull ready" label will automatically be assigned.
This label is used for administrative purposes. Please do not add it manually.
Notice 2: For external contributions, our settings currently require an approval from a MaxText maintainer to trigger CI tests.
Tests
Please describe how you tested this change, and include any instructions and/or
commands to reproduce.
Checklist
Before submitting this PR, please make sure (put X in square brackets):
gemini-reviewlabel.