Skip to content

[maxtext] Add reusable block-diffusion rollout transitions#4588

Open
ethannnnnn wants to merge 3 commits into
AI-Hypercomputer:mainfrom
ethannnnnn:block-diffusion-maxtext-pr3-rollout-transitions
Open

[maxtext] Add reusable block-diffusion rollout transitions#4588
ethannnnnn wants to merge 3 commits into
AI-Hypercomputer:mainfrom
ethannnnnn:block-diffusion-maxtext-pr3-rollout-transitions

Conversation

@ethannnnnn

Copy link
Copy Markdown

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

  • Add a pure low-confidence block rollout over a supplied target-aligned logits function.
  • Support both declared alignment/canvas contracts, heterogeneous batches, logical block positions, and partial completion blocks.
  • Guarantee forward progress while excluding the mask token from committed outputs.

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, including jax.jit execution.
  • Coverage includes both alignment contracts, heterogeneous and partial blocks, threshold progress, mask exclusion, and invalid inputs.
  • Pylint 10.00/10, Pyink, Python compilation, and git diff --check passed.

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

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
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@google-cla

google-cla Bot commented Jul 23, 2026

Copy link
Copy Markdown

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant