Skip to content

[Bug] How does canvas_ids reach the model in the DiffusionGemma training loop? #7515

Closed

Description

@j-dant

Note: Please do not remove the questions. Answer beside them.

  1. Did you update? pip install --upgrade unsloth unsloth_zoo
    Yes
  2. Colab or Kaggle or local / cloud
    local
  3. Number GPUs used, use nvidia-smi
    1
  4. Which notebook? Please link!
    https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/DiffusionGemma_(26B-A4B)-Sudoku.ipynb
  5. Which Unsloth version, TRL version, transformers version, PyTorch version?
    unsloth: 2026.7.4, TRL: 0.24.0, transformers: 5.11.0, PyTorch: 2.10.0+cu128

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.

Is there a layer I'm overlooking that maps canvas_ids to decoder_input_ids? If so, could you point me to where that mapping happens?
Separately, where is the usage of canvas_ids documented? I found decoder_input_ids documented under "Setting a starting denoising output" (https://huggingface.co/docs/transformers/main/en/model_doc/diffusion_gemma) in the HF docs, but no mention of canvas_ids anywhere.

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.

Activity

  1. InfoSage05 commented on Jul 28, 2026

    @InfoSage05
    Contributor

    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.

  2. danielhanchen commented on Oct 10, 2026

    @danielhanchen
    Member

    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.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions