{{ message }}
Repository navigation
Conversation
Discrete (token-space) diffusion had grown three schedulers with three
different step signatures, three different return types, and pipelines that
reached into scheduler internals or dispatched on `inspect.signature`. That
made a scheduler unusable outside the one pipeline it shipped with.
This gives them one contract, so that a single denoising loop drives any of
them and a new discrete model only has to add a scheduler:
scheduler.set_timesteps(num_inference_steps, device=device)
for t in scheduler.timesteps:
sample = scheduler.step(logits, t, sample).prev_sample
- Add `DiscreteSchedulerOutput` in `scheduling_utils`, replacing the
per-scheduler `DiscreteDDIMSchedulerOutput` / `EntropyBoundSchedulerOutput`.
It carries `prev_sample`, `pred_original_sample`, `sampled_probs`,
`pred_logits`, `committed_mask` and the optional `edited_mask`.
- Give every discrete scheduler the same timestep grid, `step_index` /
`begin_index` bookkeeping, and `step(model_output, timestep, sample)` order.
- Move sampling knobs (temperature, top-k, top-p, thresholds) out of pipeline
`__call__` and into the scheduler config, where they belong; the pipeline
arguments are deprecated for 1.0.0 and still honored meanwhile.
- Split the uniform-corruption process out of `BlockRefinementScheduler` into
`UniformRefinementScheduler`, which is what `DiffusionGemmaPipeline` uses.
- Drop the `inspect.signature` dispatch from both pipelines and make the
denoising loops explicit.
- Add `tests/schedulers/test_discrete_scheduler_contract.py`, which
parameterizes the contract over every discrete scheduler.
Two intended behavior changes: `sampled_probs` is now always taken from the
unmodified denoiser distribution (so a confidence threshold means the same
thing across schedulers and temperatures), and editing is gated on
`editing_threshold` being set rather than on the pipeline's arguments.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
Author
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
kashif
approved these changes
Sep 11, 2026
Contributor
This branch has not been deployed
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.

What does this PR do?
This PR refactors the existing discrete diffusion pipelines
LLaDA2PipelineandDiffusionGemmaPipelineand schedulers with the goal of establishing common conventions among discrete diffusion pipelines, which should make it easier to integrate and review discrete diffusion models, and making discrete schedulers interchangeable between pipelines.The key design principles are as follows:
diffusersdecreasing timestep convention. This matches the usual timestep convention in the discrete diffusion literature, but is generally different from continuous schedulers in thatnum_train_timestepsis not defined and thustimestepsare not scaled by it (so heretimestepsare more analogous tosigmasin e.g.FlowMatchEulerDiscreteScheduler). The motivation is for discrete pipelines to use consistent denoising loop logic.DiscreteSchedulerOutput. The goal here is to give standard names to concepts such as "the (possibly shaped) distribution the tokens are actually sampled from" (pred_logits), which should help with scheduler interchangeability.temperature, top-check_eos_finishedandcheck_block_should_continuemethods which are currently inBlockRefinementScheduler, which have been refactored into the LLaDA 2 pipeline.set_timesteps,step, etc. a common signature so that schedulers are easily interoperable (without needing e.g. reflection viainspect.signature).Target Discrete Scheduler API
Some other notable changes are as follows:
BlockRefinementSchedulerhas been split into a masked scheduler (BlockRefinementScheduler) and a uniform scheduler (UniformRefinementScheduler). The latter is now used byDiffusionGemmaPipeline.LLaDA2PipelineandBlockRefinementScheduler.sampled_probsnow has a unified definition as the unmodified denoiser logit distribution, whereas it used to mean different things in different schedulers.temperaturehave been moved to scheduler configs, the default pipeline behavior with a bare scheduler has changed.This should help with #12911 by giving the discrete diffusion pipelines there a common set of conventions to aim at.
EDIT: will need to be be reconciled with #14661 when that PR is merged.
Before submitting
self-reviewskill on the diff?documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.
@yiyixuxu
@sayakpaul
@kashif