You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] How does canvas_ids reach the model in the DiffusionGemma training loop? #7515
Hi, in the official DiffusionGemma Sudoku fine-tuning notebook, the training loop uses:
out = model(input_ids=..., canvas_ids=corrupt(x0), self_conditioning_logits=None)
I couldn't find canvas_ids as a parameter anywhere in the implementation neither in DiffusionGemmaForBlockDiffusion.forward() (which accepts decoder_input_ids), nor in DiffusionGemmaGenerationMixin.generate(), nor in the FastDiffusionModel wrapper. As far as I can tell, it falls into **kwargs and is silently dropped, causing the model to fall back to random canvas initialization.
If canvas_ids is indeed not mapped, the corrupt(x0) tensor is discarded during training and the model only ever sees fully random canvases (max noise), which would mean the intended partial corruption schedule is unused likely reducing sample efficiency.
Correct me if I am wrong, but I just couldn't trace the path and thought it was worth raising.
Hey, great catch as you're right, and I traced it end to end to confirm.
Short version: canvas_ids isn't a real argument. The model's forward() method only knows about decoder_input_ids for the corrupted canvas. Because Python functions with **kwargs don't error on unknown keyword arguments, canvas_ids=corrupt(x0) just gets silently absorbed and thrown away that is no crash, no warning. Since decoder_input_ids was never actually passed, the model falls back to its own default: a completely random canvas (torch.randint(...)) on every single training step, instead of the partially-corrupted one the notebook was trying to build.
So yes, your read was exactly right. The notebook was never using the partial-noise curriculum it was designed around. It still trains through pure luck (cross-entropy toward the clean answer still teaches something), which is why it doesn't look broken, but it's working with one hand tied behind its back.
Thanks for digging into this instead of just assuming it worked, this is exactly the kind of thing that's easy to miss because it fails silently rather than loudly.
Fixed! Sorry on the delay. The notebook passed the corrupted canvas as canvas_ids, which DiffusionGemmaForBlockDiffusion.forward does not take (the canvas is decoder_input_ids), so it was dropped and every step denoised random noise. #13157 adds DiffusionTrainer / DiffusionConfig with the reference DiffusionGemma objective (EOS-filled canvas, self-conditioning, encoder AR co-loss), and unslothai/notebooks#393 switches the Sudoku notebook to it. Cell accuracy on held-out puzzles went from 18.1% with the old loop to 85.8%.
To update: uv pip install --upgrade unsloth unsloth_zoo --force-reinstall --no-cache-dir (if it's not in the current release yet it'll be in the next one). Reopen if it still happens.
Activity
InfoSage05 commentedon Jul 28, 2026
Hey, great catch as you're right, and I traced it end to end to confirm.
Short version: canvas_ids isn't a real argument. The model's forward() method only knows about decoder_input_ids for the corrupted canvas. Because Python functions with **kwargs don't error on unknown keyword arguments, canvas_ids=corrupt(x0) just gets silently absorbed and thrown away that is no crash, no warning. Since decoder_input_ids was never actually passed, the model falls back to its own default: a completely random canvas (torch.randint(...)) on every single training step, instead of the partially-corrupted one the notebook was trying to build.
So yes, your read was exactly right. The notebook was never using the partial-noise curriculum it was designed around. It still trains through pure luck (cross-entropy toward the clean answer still teaches something), which is why it doesn't look broken, but it's working with one hand tied behind its back.
Where it actually lives: this notebook isn't part of the unsloth repo itself as it's maintained separately in unslothai/notebooks (https://github.com/unslothai/notebooks). I've opened a fix there: unslothai/notebooks#311 —> it's a one-line rename (canvas_ids → decoder_input_ids), applied consistently across the Colab, Kaggle, and script versions of the notebook so they all stay in sync.
Thanks for digging into this instead of just assuming it worked, this is exactly the kind of thing that's easy to miss because it fails silently rather than loudly.
danielhanchen commentedon Oct 10, 2026
Fixed! Sorry on the delay. The notebook passed the corrupted canvas as
canvas_ids, whichDiffusionGemmaForBlockDiffusion.forwarddoes not take (the canvas isdecoder_input_ids), so it was dropped and every step denoised random noise. #13157 addsDiffusionTrainer/DiffusionConfigwith the reference DiffusionGemma objective (EOS-filled canvas, self-conditioning, encoder AR co-loss), and unslothai/notebooks#393 switches the Sudoku notebook to it. Cell accuracy on held-out puzzles went from 18.1% with the old loop to 85.8%.To update:
uv pip install --upgrade unsloth unsloth_zoo --force-reinstall --no-cache-dir(if it's not in the current release yet it'll be in the next one). Reopen if it still happens.