Skip to content

DiffusionGemma Sudoku: train with DiffusionTrainer (canvas was never passed) - #393

Merged
danielhanchen merged 3 commits into
mainfrom
fix-diffusiongemma-training
Oct 10, 2026
Merged

danielhanchen merged 3 commits into
mainfrom
fix-diffusiongemma-training

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

The DiffusionGemma Sudoku notebook trained with model(input_ids = ..., canvas_ids = corrupt(x0), ...). DiffusionGemmaForBlockDiffusion.forward has no canvas_ids argument (the canvas is decoder_input_ids), so it was dropped through **kwargs and every step denoised a fresh uniform random canvas instead of the corrupted solution. Reported in unslothai/unsloth#7515. The loop also differed from the reference recipe: no self-conditioning, no encoder autoregressive co-loss, an unsupervised pad tail instead of the EOS-filled canvas, and t drawn from U(0.1, 1).

This switches the training cell to DiffusionTrainer / DiffusionConfig from Unsloth, which implements the reference block-diffusion objective, on a prompt / completion dataset with completion_only_loss. Only original_template/DiffusionGemma_(26B-A4B)-Sudoku.ipynb changes; the generated copies come from update_all_notebooks.py.

Other changes in the notebook:

  • The eval cell defines the tokenizer and device it uses instead of relying on the removed training loop.
  • warmup_steps instead of warmup_ratio (removed in transformers 5).
  • The save cell keeps the adapter unmerged and says why: the encoder and decoder share tied base weights with separate adapters, so merging would apply both deltas to the same tensors.

On one B200 (bf16, LoRA r=64, 60 steps x grad accum 4, 30 held-out puzzles, greedy), cell accuracy at 32 denoising steps went from 82.8% (base) to 18.1% with the old loop and to 85.8% with DiffusionTrainer. The converted notebook also runs end to end on the tiny DiffusionGemma.

Needs unslothai/unsloth#13157 (which adds DiffusionTrainer) merged and released first.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-09T17:45:40.550555Z 7fae053 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1b820be852

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

"tok = processor.tokenizer if hasattr(processor, \"tokenizer\") else processor\n",
"pad = tok.pad_token_id if tok.pad_token_id is not None else eos\n",
"from datasets import Dataset\n",
"from unsloth import DiffusionTrainer, DiffusionConfig\n",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Ship DiffusionTrainer before importing it

In the generated Colab path, the installation cell installs the ordinary released unsloth package, but the current package and upstream main do not export DiffusionTrainer or DiffusionConfig; the commit message also identifies the implementation PR as not yet merged or released. Consequently, running the notebook now stops here with ImportError before training. Land and release the dependency first, or pin/install the implementation that provides these classes.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Intentional merge order: this PR stays unmerged until unslothai/unsloth#13157 (which adds DiffusionTrainer) is merged and released, as stated in the description.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 9, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1b820be852

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

" opt.step(); sched.step(); opt.zero_grad(set_to_none=True)\n",
" if step % 20 == 0:\n",
" print(f\"step {step:4d}/{STEPS} | loss {step_loss:.4f} | {time.time()-t0:.0f}s\", flush=True)"
"trainer = DiffusionTrainer(\n",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Regenerate the user-facing notebook variants

This trainer replacement exists only in original_template/; the commit leaves nb/DiffusionGemma_(26B-A4B)-Sudoku.ipynb, its Kaggle/AMD variants, and the generated Python/Molab copies on the old broken canvas_ids training loop. Since the README's Colab link points to the nb/ copy (README.md:232) and no workflow regenerates or commits these artifacts after merge, users will not receive the fix at all. Run update_all_notebooks.py --to_main_repo and commit the generated outputs.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 7fae053: regenerated the nb/, Kaggle, python_scripts and molab DiffusionGemma copies with update_all_notebooks.py --to_main_repo.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 7fae053051

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

# Conflicts:
#	molab/DiffusionGemma_(26B-A4B)-Sudoku.py
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.

1 participant