[maxtext] Add reusable block-diffusion rollout transitions#4588
Open
ethannnnnn wants to merge 3 commits into
Open
[maxtext] Add reusable block-diffusion rollout transitions#4588ethannnnnn wants to merge 3 commits into
ethannnnnn wants to merge 3 commits into
Conversation
Add block_diffusion as a default-off attention type with one namespaced block-size setting. Resolve it in the shared attention layer so ordinary global layers need no model-name dispatch while explicit specialized attention remains intact. Implement matching dense, Splash, Tokamax, packed-sequence, and load-balanced context-parallel masks. Preserve the autoregressive path and support partial final blocks. Tests: attention 42 passed/37 skipped; config 18 passed plus 21 subtests; Tokamax 3 passed; pyink, yamllint, git diff --check.
Add a model-agnostic block-diffusion training objective without changing the causal LM default. The data pipeline emits separate validity, completion, corruption, and loss masks, supports same-position/all-masked and shifted/seeded canvases, and preserves those fields through context-parallel reordering and shaped batches. Align model logits to physical targets in a shared scoring utility and consume explicit loss weights in Linen, NNX, native gradient accumulation, and the Tunix SFT adapter. The adapter composes the stock Tunix PeftTrainer and its LossOutput contract, including denominator-aware accumulation and evaluation; the existing MaxText AR trainer path remains unchanged. Tests cover partial blocks, prompt protection, deterministic corruption, alignment after sequence reordering, strict mask requirements, zero-weight gradients, causal no-regression, weighted accumulation/evaluation acceptance, and SFT adapter validation. Test Plan: - 196 passed, 14 skipped, 3 deselected; 66 subtests passed in focused MaxText unit suite - 11 passed in Tunix-backed post-training SFT suite - Pylint 10.00/10 on new scoring and loss/GA tests - Pyink, yamllint, codespell, pycompile, and git diff checks pass
Add a model-independent low-confidence block rollout that consumes target- aligned logits. It supports the two public model contracts, logical-position block boundaries after context-parallel reordering, heterogeneous batches, partial final blocks, confidence-threshold commits, and forced-argmax progress. The initial OPD scope validates a single contiguous completion suffix so clean future turns cannot leak through bidirectional intra-block attention. Shifted rollouts also require logical position zero to remain prompt context. Test Plan: - 7 passed in tests/unit/diffusion_denoise_test.py, including jax.jit execution - Pylint 10.00/10 - Pyink, pycompile, and git diff checks pass
ethannnnnn
requested review from
SurbhiJainUSC,
aireenmei,
darisoy,
richjames0 and
shralex
as code owners
July 23, 2026 22:44
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
ethannnnnn
requested review from
NuojCheng,
RissyRan,
bvandermoon,
gagika,
gobbleturk,
igorts-git,
jiangjy1982,
parambole,
shuningjin and
suexu1025
as code owners
July 23, 2026 22:44
ethannnnnn
requested review from
A9isha,
abhinavclemson,
dipannita08,
hengtaoguo,
huytransformer,
khatwanimohit,
vipannalla and
xibinliu
as code owners
July 23, 2026 22:44
|
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. |
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
OPD and RL need a denoising transition program that can be tested independently from a concrete model, trainer, serving scheduler, or KV-cache implementation.
Scope
Design
Each step evaluates the current canvas, proposes clean tokens, and commits positions above the configured confidence threshold. If no eligible position clears the threshold, the transition commits the highest-confidence eligible position. Logical positions break confidence ties and define block boundaries after physical reordering.
The program accepts completion and validity masks explicitly and returns the final canvas without owning model execution or trainer state.
Compatibility
This is a new model-independent module. Existing causal training, generation, and model code do not import or invoke it.
Extensibility
Model integrations supply the target-aligned logits function. Sampling schedules and alternative commit policies can be added at this boundary without coupling them to a model implementation.
Tests
tests/unit/diffusion_denoise_test.py: 7 passed, includingjax.jitexecution.git diff --checkpassed.Known limitations
The initial correctness scope accepts one contiguous completion suffix. Shifted rollouts require logical position zero to remain prompt context. The implementation is cacheless and is not a serving-throughput claim.
Stack
Depends on the preceding upstream PR: #4587
MaxText block-diffusion design document