[tunix] Add model-agnostic JAX diffusion contracts - #1832
Open
ethannnnnn wants to merge 1 commit into
Open
Conversation
ethannnnnn
requested review from
abheesht17,
hgao327,
jiangyangmu,
lc5211,
s-noghabi,
sizhit2,
tianshub and
wang2yn84
as code owners
August 5, 2026 17:53
wang2yn84
reviewed
Aug 6, 2026
ethannnnnn
force-pushed
the
block-diffusion-tunix-v2-pr1-contracts
branch
from
August 6, 2026 05:09
33d93ae to
e0a12bd
Compare
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
Diffusion training integrations need a small, stable JAX boundary that does
not depend on MaxText, a specific model, or a training algorithm.
Scope
This PR adds only:
DiffusionTokenBatchwith target-aligned token IDs andexplicit loss weights;
It does not add an SFT or distillation objective, change gradient reduction,
prepare a rollout, alter RL behavior, or import MaxText.
Design
Every model-input leaf has the same leading batch axis. Static model
configuration remains in the logits-function closure rather than becoming a
batch leaf. Targets refer to physical prediction positions, so model-specific
same-position or shifted-logit alignment happens before constructing the
canonical batch.
DiffusionLogitsFnreceives an NNX model and prepared model inputs and returnsfloating-point logits with shape
[batch, length, vocabulary]. Constructionand scoring boundaries validate array structure, target alignment, and active
values. Static checks remain safe under JIT and sharding; concrete finite and
range checks run when arrays are eagerly addressable.
Compatibility
The package is new and opt-in. Existing SFT, distillation, RL, and
autoregressive paths do not construct these contracts and remain unchanged.
Tests
Pyink, isort, scoped Pylint, Python compilation, and
git diff --checkalsopass for the changed files.
Follow-Ups
Denominator-aware weighted reduction will be proposed separately after this
contract lands. Diffusion SFT, prepared distillation, OPD, rollout transport,
policy scoring, and GRPO integration remain later independent reviews.
Design document:
https://docs.google.com/document/d/1Xe-98ScS2RSH29AdhTdc9tO4WHQG5wCbFkJA3gmIUZQ/edit