Repository navigation
[maxtext] Add block-causal attention - #4743
Merged
copybara-service[bot] merged 1 commit intoAug 7, 2026
Merged
copybara-service[bot] merged 1 commit into
copybara-service[bot] merged 1 commit into
Conversation
ethannnnnn
requested review from
A9isha,
NuojCheng,
RissyRan,
SurbhiJainUSC,
abhinavclemson,
aireenmei,
bvandermoon,
darisoy,
dipannita08,
gagika,
gobbleturk,
hengtaoguo,
huytransformer,
igorts-git,
jiangjy1982,
khatwanimohit,
parambole,
richjames0,
shralex,
shuningjin,
vipannalla and
xibinliu
as code owners
August 5, 2026 17:17
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
ethannnnnn
force-pushed
the
block-diffusion-maxtext-v2-pr2-attention
branch
from
August 5, 2026 18:39
ff2b021 to
04d6f47
Compare
ethannnnnn
force-pushed
the
block-diffusion-maxtext-v2-pr2-attention
branch
from
August 5, 2026 21:46
04d6f47 to
61d4ae5
Compare
entrpn
reviewed
Aug 6, 2026
ethannnnnn
force-pushed
the
block-diffusion-maxtext-v2-pr2-attention
branch
from
August 6, 2026 04:04
61d4ae5 to
b827f6d
Compare
shralex
approved these changes
Aug 6, 2026
shralex
left a comment
Collaborator
There was a problem hiding this comment.
Thank you for the contribution! Added a few documentation suggestions to make it easier to navigate for future users / maintainers.
ethannnnnn
force-pushed
the
block-diffusion-maxtext-v2-pr2-attention
branch
from
August 6, 2026 15:04
b827f6d to
6bf2279
Compare
entrpn
approved these changes
Aug 6, 2026
ethannnnnn
force-pushed
the
block-diffusion-maxtext-v2-pr2-attention
branch
from
August 6, 2026 21:09
6bf2279 to
df9c7da
Compare
hengtaoguo
approved these changes
Aug 6, 2026
hengtaoguo
left a comment
Collaborator
There was a problem hiding this comment.
The github actions are temporarily down so the PR tests are queued. Let's watch out for this.
hengtaoguo
approved these changes
Aug 7, 2026
| "vocab_size=256", | ||
| "max_target_length=2048", | ||
| "hardware=cpu", | ||
| "packing=False", |
Collaborator
| "vocab_size": 256, | ||
| "max_target_length": 2048, | ||
| "hardware": "cpu", | ||
| "packing": False, |
Collaborator
There was a problem hiding this comment.
Add "skip_jax_distributed_system": True here too.
Add a `block_diffusion` attention type that is causal across blocks and bidirectional within each block. The dense dot-product and TPU Splash/Tokamax paths share the same mask semantics. Existing autoregressive decode behavior remains unchanged, unsupported kernels fail during config validation, and packed training remains outside this feature scope. Test Plan: - block mask unit tests for dense, Splash, load-balanced CP, rectangular queries, and AR fallback - block attention config validation tests - focused branch tests cover every changed executable line and branch in `attention_op.py` fix: skip_jax_distributed_system
hengtaoguo
force-pushed
the
block-diffusion-maxtext-v2-pr2-attention
branch
from
August 7, 2026 07:27
1bb8c3e to
7a4b75e
Compare
copybara-service
Bot
merged commit Aug 7, 2026
2d872a9
into
AI-Hypercomputer:main
53 of 54 checks passed
4 tasks done
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.
Motivation
Block diffusion needs attention that is causal across blocks while remaining
bidirectional within the block currently being corrupted or denoised. This is
an attention-kernel concern and can be reviewed independently of corruption,
training objectives, rollout, and RL.
Scope
This PR adds only:
block_diffusionattention type and positivecausal_block_sizeconfiguration;combinations; and
It does not depend on the block-diffusion primitive PR, corrupt training data,
change a loss function, add a model-specific branch, or enable diffusion by
default.
Mask semantics
For query position
qand key positionk, attention is allowed whenTherefore, all positions in the current block can attend to one another and to
all earlier blocks, but no earlier block can attend to a later block. Segment
boundaries remain enforced. Packing is rejected because document-local block
origins are not yet represented by the attention metadata. Autoregressive
decode keeps the existing causal mask path unchanged.
Compatibility
The default remains
attention_type=global. The new behavior is activated onlywhen
attention_type=block_diffusionis selected explicitly. Specializedper-layer attention declarations continue to override the global configuration.
This implementation remains code-independent from the primitives landed in
#4737: it does not import or activate them. The branch is rebased onto the
current
maincontaining #4737 so reviewers see only this attention change.Tests
The skipped cases require unavailable platform-specific kernels. Pyink, Python
compilation, and
git diff --checkalso pass for the changed files.Focused branch coverage for the changed executable code in
src/maxtext/layers/attention_op.pyis complete: 53/53 changed lines and26/26 changed branches are covered.
Checklist
Design document:
https://docs.google.com/document/d/1N7KcCoAIErB2CV9EJ2G1u_mdN-AQgqwNUYSvM0mtqMI/edit