Support packed TPU Tokamax ring attention - #4622
Open
huytransformer wants to merge 1 commit into
Open
Conversation
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
huytransformer
force-pushed
the
htn/ring-packing
branch
from
July 27, 2026 09:04
0865ce8 to
8913a00
Compare
huytransformer
force-pushed
the
htn/ring-packing
branch
from
July 27, 2026 20:22
8913a00 to
3afe7b3
Compare
huytransformer
marked this pull request as ready for review
July 27, 2026 23:32
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
huytransformer
requested review from
A9isha,
NuojCheng,
RissyRan,
SurbhiJainUSC,
abhinavclemson,
aireenmei,
bvandermoon,
darisoy,
dipannita08,
gagika,
gobbleturk,
hengtaoguo,
igorts-git,
jiangjy1982,
khatwanimohit,
parambole,
richjames0,
shralex,
shuningjin,
suexu1025,
vipannalla and
xibinliu
as code owners
July 27, 2026 23:32
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
Enable sequence packing for TPU Tokamax ring attention.
Packing was previously rejected by config validation when combined with the TPU ring. Ring itself already supports packed sequences so this pr lifts the rej from the TPU Tokamax ring validation in
configs/types.pyand fromAttentionOp, and resolvescontext_parallel_reorder_strategy=AUTOwith packing and ring toDUAL_CHUNK_SWAPon TPU.This is important for ring because ring CP targets long contexts, where real documents rarely fill the window on their own.
Tests
CPU:
python3 -m pytest tests/unit/configs_value_test.py -k tokamax_ring5 passed (18 subtests), including the new
accepts_packingandaccepts_packed_load_balancecases.TPU (v5p, 4 chips):
python3 -m pytest tests/unit/attention_test.py -k ring_context_parallel8 passed. Forward and gradient equivalence against dot product attention for packed and unpacked, with and without load balancing.
E2E (v5p-128)
20 step training run with packing=True on c4 (tfds), context_parallel_strategy=ring, context_parallel_load_balance=True, ici_context_parallelism=4, reorder strategy AUTO. Loss decreased from 10.84 to 8.06 over 20 steps
Checklist
Before submitting this PR, please make sure (put X in square brackets):
gemini-reviewlabel.