Use attention ops from Tokamax#4465
Open
copybara-service[bot] wants to merge 1 commit into
Open
Conversation
Pallas Triton is heading towards deprecation, so these ops will eventually be removed from JAX. Closes #4384. PiperOrigin-RevId: 945567777
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
kocchop
reviewed
Jul 15, 2026
| out = gpu_pallas_attention.mha(query, key, value, decoder_segment_ids, sm_scale=1.0, causal=True) | ||
| mask = tokamax_attention_base.Mask(is_causal=True) | ||
| if decoder_segment_ids is not None: | ||
| seg_mask = decoder_segment_ids[:, :, None] == decoder_segment_ids[:, None, :] |
Collaborator
There was a problem hiding this comment.
I needed to add the following to make it work:
seg_mask = seg_mask[:, None, :, :]
Tokamax infers batch dims by rank, so a rank-3 (B, T, t) mask matches its rank-3 (#heads, T, t) annotation exactly and the batch dim gets misread as the head dim — adding an explicit singleton head dim ((B, 1, T, t)) lets it vmap over batch and broadcast across heads.
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.
Use attention ops from Tokamax
Pallas Triton is heading towards deprecation, so these ops will eventually be
removed from JAX.
Closes #4384.