Skip to content

[Discrete Diffusion] Add LLaDA2 pipeline#13226

Open
kashif wants to merge 4 commits intohuggingface:mainfrom
kashif:llada2-support
Open

[Discrete Diffusion] Add LLaDA2 pipeline#13226
kashif wants to merge 4 commits intohuggingface:mainfrom
kashif:llada2-support

Conversation

@kashif
Copy link
Contributor

@kashif kashif commented Mar 8, 2026

Add support for LLaDA2/LLaDA2.1 discrete diffusion text generation:

  • BlockRefinementPipeline: block-wise iterative refinement with confidence-based token commitment, supporting editing threshold for LLaDA2.1 models
  • LLaDA2Pipeline: convenience wrapper with LLaDA2-specific defaults
  • DiscreteDiffusionPipelineMixin: shared SAR sampling utilities (top-k, top-p, temperature) and prompt/prefix helpers
  • compute_confidence_aware_loss: CAP-style training loss
  • Examples: sampling scripts for LLaDA2 and block refinement, training scripts with Qwen causal LM
  • Docs and tests included

What does this PR do?

Fixes # (issue)

Before submitting

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.

kashif added 3 commits March 8, 2026 17:43
…usion

Add support for LLaDA2/LLaDA2.1 discrete diffusion text generation:
- BlockRefinementPipeline: block-wise iterative refinement with confidence-based
  token commitment, supporting editing threshold for LLaDA2.1 models
- LLaDA2Pipeline: convenience wrapper with LLaDA2-specific defaults
- DiscreteDiffusionPipelineMixin: shared SAR sampling utilities (top-k, top-p,
  temperature) and prompt/prefix helpers
- compute_confidence_aware_loss: CAP-style training loss
- Examples: sampling scripts for LLaDA2 and block refinement, training scripts
  with Qwen causal LM
- Docs and tests included
Extract the confidence-based token commit logic from BlockRefinementPipeline
into a dedicated BlockRefinementScheduler, following diffusers conventions.

The scheduler owns:
- Transfer schedule computation (get_num_transfer_tokens)
- Timestep management (set_timesteps)
- Step logic: confidence-based mask-filling and optional token editing

The pipeline now delegates scheduling to self.scheduler.step() and accepts
a scheduler parameter in __init__.
12 tests covering set_timesteps, get_num_transfer_tokens, step logic
(confidence-based commits, threshold behavior, editing, prompt masking,
batched inputs, tuple output).
- Add BlockRefinement and LLaDA2 to docs sidebar navigation
- Add BlockRefinementScheduler to schedulers sidebar navigation
- Move scheduler autodoc to its own page under api/schedulers/
@kashif kashif changed the title [Discrete Diffusion] Add LLaDA pipeline [Discrete Diffusion] Add LLaDA2 pipeline Mar 8, 2026
@kashif kashif mentioned this pull request Mar 8, 2026
6 tasks
@kashif kashif requested a review from dg845 March 8, 2026 19:55
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