Skip to content

[DiffusionGemma] Add DDIM and block refinement samplers#46595

Open
kashif wants to merge 3 commits into
huggingface:mainfrom
kashif:diffusion-gemma-ddim-sampler
Open

[DiffusionGemma] Add DDIM and block refinement samplers#46595
kashif wants to merge 3 commits into
huggingface:mainfrom
kashif:diffusion-gemma-ddim-sampler

Conversation

@kashif

@kashif kashif commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Adds two more samplers for DiffusionGemma so people can try different denoising strategies without writing their own.

  • DiscreteDDIMSampler: samples each canvas position from the exact posterior of the uniform corruption process. Works well with a constant temperature and around 20 steps.
  • BlockRefinementSampler: commits an even share of the canvas per step, most confident tokens first, with optional editing of committed tokens.

The sampler is picked through sampler_config, same as the existing EntropyBoundSampler. Added unit tests for both, parametrized the generate test over them, and documented them in the model page.

Tests: pytest tests/models/diffusion_gemma/test_generation_diffusion_gemma.py and test_modeling_diffusion_gemma.py -k test_generate pass on CPU.

AI assistance was used.

@kashif

kashif commented Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

cc @gante and @sayakpaul

@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

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.

@gante gante left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Out of curiosity, have you benchmarked any of the new samplers with diffusiongemma? :)

@kashif

kashif commented Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

running benchmarks as i type

@gante

gante commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

It would be cool to measure both quality and tokens per forward! (I added tokens per forward as part of the output class in generate)

@gante

gante commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

P.S.: In the first few commits I considered writing a base class for all samplers, since they will almost certainly share the random canvas initialization 🤗

@kashif kashif force-pushed the diffusion-gemma-ddim-sampler branch from 72ada7e to af52a19 Compare June 12, 2026 13:59
@github-actions

Copy link
Copy Markdown
Contributor

CI Dashboard: View test results in Grafana

@github-actions

Copy link
Copy Markdown
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: diffusion_gemma

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.

3 participants