Skip to content

Run DiffusionGemma and LLaDA2 pipeline tests through the shared PipelineTesterMixin - #14661

Open
kashif wants to merge 10 commits into
mainfrom
test-diffusion-gemma-pipeline-mixin
Open

Run DiffusionGemma and LLaDA2 pipeline tests through the shared PipelineTesterMixin#14661
kashif wants to merge 10 commits into
mainfrom
test-diffusion-gemma-pipeline-mixin

Conversation

@kashif

@kashif kashif commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Follow-up to #14652. Runs DiffusionGemma and LLaDA2 pipeline tests through the shared PipelineTesterMixin, the same way audioldm2 does it for a non-image output, skipping the tests that assume image/video semantics (CFG, latents, per-row generator lists). Existing hand-written generation/regression tests stay as-is alongside.

Running the mixin's save/load and to-device tests on a real accelerator caught two real bugs, fixed here too:

  • DiffusionGemma's canvas init and all three block-diffusion schedulers called torch.randint/multinomial/rand with a CPU generator on a CUDA tensor, which torch rejects. Fixed like randn_tensor does: sample on the generator's device, move after.
  • LLaDA2Pipeline.tokenizer defaults to None and works fine without one, but wasn't declared in _optional_components, so save/load silently dropped it.

Includes akshan-main's #14652 commit as a base — needed for DiffusionGemma's own save/load tests to pass.

Self-review notes (/code-review medium): caught two more torch.rand calls in add_noise with the same generator/device bug (fixed), and DiffusionGemma's pipeline duplicating the device-selection logic instead of reusing the new shared helper (fixed). Also flagged that the _optional_components fix wasn't actually exercised since that mixin test was skipped — adapted it to run with input_ids instead.

Before submitting

Who can review?

@sayakpaul

akshan-main and others added 8 commits August 31, 2026 10:58
…ma's canvas init

torch.randint/multinomial/rand need the generator and the sampled tensor
on the same device. A CPU generator (the portable default recommended
for reproducible pipeline calls) broke on any accelerator.
it already defaults to None and works without one; just wasn't
declared, so save/load silently dropped it.
follows the audioldm2 pattern for a non-image output; skips the handful
of tests that assume guidance/latents/generator-lists.
same treatment as DiffusionGemma; keeps the existing regression tests
as-is alongside it.
missed this one earlier; two more torch.rand calls with the same
CPU-generator-on-CUDA mismatch.
was skipped; adapt it to use input_ids instead of prompt so it
actually runs.

@sayakpaul sayakpaul left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

Comment thread src/diffusers/pipelines/diffusion_gemma/pipeline_diffusion_gemma.py Outdated
Comment thread src/diffusers/schedulers/scheduling_discrete_ddim.py Outdated
Comment thread src/diffusers/schedulers/scheduling_utils.py Outdated
@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.

per review: it's a one-liner, not worth a shared helper.
@github-actions github-actions Bot added the size/L PR with diff > 200 LOC label Sep 1, 2026
# Conflicts:
#	tests/pipelines/llada2/test_llada2.py
@sayakpaul
sayakpaul requested a review from yiyixuxu September 1, 2026 07:42
@sayakpaul

Copy link
Copy Markdown
Member

@yiyixuxu could you also review the changes introduced in the core files?

token = flat_logits.argmax(dim=-1, keepdim=True)
else:
scaled_probs = torch.softmax(flat_logits.float() / temperature, dim=-1)
token = torch.multinomial(scaled_probs, num_samples=1, generator=generator)

@sayakpaul sayakpaul Sep 1, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we use this scheduler in any of the pipelines for dLLM? If not, let's remove these changes.

@kashif kashif Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, DiffusionGemma supports it directly and our tests exercise it, so it's in scope.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants