Skip to content

fix(diffusiongemma): use decoder_input_ids instead of canvas_ids in Sudoku training loop - #311

Closed
InfoSage05 wants to merge 1 commit into
unslothai:mainfrom
InfoSage05:fix/diffusiongemma-sudoku-canvas-ids
Closed

InfoSage05 wants to merge 1 commit into
unslothai:mainfrom
InfoSage05:fix/diffusiongemma-sudoku-canvas-ids

Conversation

@InfoSage05

@InfoSage05 InfoSage05 commented Jul 28, 2026 •

Copy link
Copy Markdown

Summary

The DiffusionGemma Sudoku fine-tuning notebook's training loop calls model(input_ids=..., canvas_ids=corrupt(x0), self_conditioning_logits=None), but DiffusionGemmaForBlockDiffusion.forward() in transformers takes decoder_input_ids for the corrupted-canvas argument -- there is no canvas_ids parameter anywhere in the implementation.

Root Cause

canvas_ids is not a recognized argument of DiffusionGemmaForBlockDiffusion.forward(), so it falls into the trailing **kwargs and is silently discarded (no TypeError). decoder_input_ids therefore stays None, and the model defaults to torch.randint(...) -- a fully random canvas on every training step -- instead of using the intended partial-noise-corrupted canvas from corrupt(x0). This defeats the partial-noise curriculum the block-diffusion objective relies on.

Verified directly against the HF transformers source (modeling_diffusion_gemma.py): forward()'s signature takes decoder_input_ids: torch.LongTensor | None = None, and falls back to torch.randint(...) when it is None.

Changes

Renamed canvas_ids -> decoder_input_ids in the training-loop call, in the source notebook and all five generated mirrors so they stay in sync:

  • original_template/DiffusionGemma_(26B-A4B)-Sudoku.ipynb (source)
  • nb/DiffusionGemma_(26B-A4B)-Sudoku.ipynb
  • nb/Kaggle-DiffusionGemma_(26B-A4B)-Sudoku.ipynb
  • molab/DiffusionGemma_(26B-A4B)-Sudoku.py
  • python_scripts/DiffusionGemma_(26B-A4B)-Sudoku.py
  • python_scripts/Kaggle-DiffusionGemma_(26B-A4B)-Sudoku.py

No other changes -- single-kwarg-name fix, 1-line diff per file.

Testing

  • Confirmed canvas_ids is now absent repo-wide (grep -rln canvas_ids . -> no results).
  • Validated all three .ipynb files still parse as well-formed JSON after the edit.
  • Verified against the live HF transformers source for DiffusionGemmaForBlockDiffusion.forward() that decoder_input_ids is the correct parameter name.

Fixes #7515

…udoku training loop

The Sudoku fine-tuning training loop called
model(input_ids=..., canvas_ids=corrupt(x0), ...), but
DiffusionGemmaForBlockDiffusion.forward() (transformers) takes
decoder_input_ids for the corrupted-canvas argument, not canvas_ids.
canvas_ids falls into the trailing **kwargs and is silently dropped, so
decoder_input_ids stays None and the model defaults to a fully random
canvas (torch.randint(...)) on every step instead of the intended
partial-noise curriculum, hurting sample efficiency.

Renamed the kwarg to decoder_input_ids in the original_template source
notebook and its five generated mirrors (nb/, nb/Kaggle-, molab/,
python_scripts/, python_scripts/Kaggle-) so they stay in sync.

Fixes unslothai/unsloth#7515
@danielhanchen

Copy link
Copy Markdown
Member

Confirmed the training loop in original_template/DiffusionGemma_(26B-A4B)-Sudoku.ipynb still passes canvas_ids, which the forward call does not take, so the corrupted canvas never reaches the model; could you re-run update_all_notebooks.py so the AMD mirrors pick this up too? Will get this reviewed.

@danielhanchen

Copy link
Copy Markdown
Member

Thank you for the PR and for tracking this down! You were right that canvas_ids is not a parameter of DiffusionGemmaForBlockDiffusion.forward(), so it was swallowed by **kwargs and the corrupted canvas never reached the model.

This has since been fixed on main by #393, which replaces the hand-written training loop with Unsloth's DiffusionTrainer (the reference block-diffusion objective, including self-conditioning). The lines this PR edits no longer exist on main, so the PR now only conflicts and there is nothing left for it to change. Closing it as superseded by #393. Thanks again for the careful report and root-cause analysis.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants