Repository navigation
Studio: train and chat with every text-diffusion LM family - #13342
Conversation
… a diffusion model the config probe missed
…p for diffusion, keep max_length on unpatched TRL
… the 5.5 sidecar does not ship it
…annot reach the worker processes
…e pickled for dataset workers
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2d16a16101
ℹ️ 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".
| temperature = temperature, | ||
| max_new_tokens = max_new_tokens, | ||
| cancel_event = cancel_event, | ||
| _adapter_state = _adapter_state, | ||
| stop = stop, |
There was a problem hiding this comment.
Do not silently discard diffusion sampling controls
When a diffusion chat request supplies non-default top_p, top_k, min_p, repetition_penalty, or presence_penalty, this early branch forwards only temperature and the token limit; the raw-prompt diffusion branch does the same. The API accepts those controls but they have no effect on the generated result, which makes client-side sampling configurations misleading. Forward the controls supported by the family sampler, or explicitly reject/disable unsupported settings.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
The family samplers decode by confidence remasking, which has no top-p / top-k / min-p / penalty analogue. The chat UI sends those fields on every request, so rejecting them would break diffusion chat for everyone; they are ignored like other unsupported fields.
…mbedding learning rate, refuse MLX training of text-diffusion models
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b415b88ca1
ℹ️ 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".
| yield from self._generate_diffusion_lm( | ||
| model_info, | ||
| messages = _without_image_parts(template_messages), |
There was a problem hiding this comment.
Include tool schemas in diffusion chat prompts
When tools are enabled, this early diffusion branch forwards only the conversation messages to the family sampler and bypasses the normal renderer below that supplies tools to apply_chat_template. The agentic loop still expects a tool call, but the model is never shown the available tool names or argument schemas, so diffusion-model tool turns generally produce ordinary text or exhaust the loop. Render the prompt with the same tool-aware template path before invoking the sampler, or explicitly disable tool mode for these models.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
These diffusion LMs are not trained for tool calling and the family samplers decode one completion by remasking, with no tool-call parser behind them. When no tool call comes back the agentic loop returns the text as the final answer, so nothing is lost; rendering tool schemas would only add prompt text these models do not use.
…les, refuse MLX chat for text-diffusion models, turn layer offloading off before the VRAM budget
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f49fa175fd
ℹ️ 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".
| candidate | ||
| for candidate in candidates | ||
| if candidate not in hardcoded | ||
| if not _hardcoded_tier_ships(candidate) |
There was a problem hiding this comment.
Check the aliased DiffusionGemma type for upgrades
For a legacy DiffusionGemma checkpoint whose model_type is diffusion_gemma, this now correctly notices that the installed 5.5 sidecar lacks the type, but it then queries latest-transformers support using that same legacy name. Current Transformers registers the implementation as diffusion_gemma4—the core loader explicitly rewrites the legacy type to that name—so latest_transformers_supports("diffusion_gemma") reports unsupported and the validation path never offers the required latest-transformers install. The worker subsequently selects the hardcoded 5.5 tier and fails when the loader imports DiffusionGemma4Config; normalize this legacy candidate before checking the latest mappings.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Transformers registers this model as diffusion_gemma (plus diffusion_gemma_text), not diffusion_gemma4: CONFIG_MAPPING_NAMES in both 5.17.0 and 5.19.0 lists only those, and latest_transformers_supports('diffusion_gemma') returns supported_in_pypi=True for 5.19.0 while 'diffusion_gemma4' returns False. Normalising to diffusion_gemma4 would break the prompt.
…rs, refuse an autoregressive load in diffusion chat, resolve Hub LoRA bases before the MLX refusal, keep the denied-credential sentinel in detection
…be export limits with the caller's credential
…ar exists, classify a Hub LoRA by its base before the vision loader
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 48789ad7e6
ℹ️ 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".
| if use_rslora: | ||
| peft_kwargs["use_rslora"] = True |
There was a problem hiding this comment.
Honor rsLoRA in diffusion adapter setup
When a text-diffusion run enables rsLoRA, this forwards use_rslora=True, but the dispatched FastDiffusionModel.get_peft_model in unsloth/models/diffusion.py filters extra kwargs to only modules_to_save and init_lora_weights, so PEFT receives an ordinary LoraConfig and the experiment silently uses standard LoRA scaling. Either pass use_rslora through to LoraConfig or reject it alongside DoRA and LoftQ so the recorded configuration matches the training algorithm.
Useful? React with 👍 / 👎.
| generate_text = getattr(require_diffusion_api("FastDiffusionModel"), "generate_text", None) | ||
| if generate_text is None: | ||
| raise RuntimeError( | ||
| "Unsloth: chatting with a text-diffusion model needs a newer Unsloth " | ||
| "(FastDiffusionModel.generate_text). Update with `unsloth studio update`." |
There was a problem hiding this comment.
Ship the sampler used by diffusion chat
On an installation built from this repository revision, every text-diffusion chat reaches this check and fails because the bundled FastDiffusionModel in unsloth/models/diffusion.py has no generate_text method, and there is no other sampler implementation that adds it. Consequently the newly added chat path can only emit the update error rather than generate a response; the sampler API needs to be included in the same release or this path must call an API that the bundled core actually provides.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
| embedding_lr = training_args.get("embedding_learning_rate") if is_cpt else None | ||
| if embedding_lr is not None: | ||
| if "embedding_learning_rate" not in fields: | ||
| raise RuntimeError( | ||
| "Continued pretraining of a text-diffusion model with an embedding " | ||
| "learning rate needs a newer Unsloth. Upgrade with: " | ||
| "`pip install -U unsloth unsloth_zoo`." |
There was a problem hiding this comment.
Support the default diffusion CPT optimizer settings
The default Studio continued-pretraining configuration includes embed_tokens and lm_head, so the worker derives a non-null embedding_learning_rate (defaulting it to lr/10) and this branch is taken. However, the bundled unsloth.models.diffusion_trainer.DiffusionConfig has no embedding_learning_rate field, causing default diffusion CPT runs to terminate with this upgrade error even on the same repository revision. Add the optimizer-field support to the bundled diffusion trainer or provide a working fallback for CPT.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
This PR depends on #13341 (stated at the top of the description; merge #13341 first), which adds DiffusionConfig.embedding_learning_rate and builds the optimizer through UnslothTrainer so embeddings get their own group. Against an older core the CPT run stops with the upgrade message instead of training at the wrong rate.
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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: # studio/backend/core/training/trainer.py
|
Codex Review: Didn't find any major issues. What shall we delve into next? Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
…eam and SDAR Their output-head rows for <|im_end|>, <tool_call>, <|fim_pad|> and the other special tokens are near-duplicates, so at 2e-4 a LoRA run swaps them: replies end in <tool_call> or come back empty. Clean at 5e-5. Only the untouched Studio default is lowered; any other value is kept.
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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: # studio/backend/core/inference/inference.py # studio/backend/core/training/trainer.py
Studio can now train and chat with every text-diffusion family Unsloth Core supports: LLaDA, LLaDA-MoE, Dream, Nemotron-Labs-Diffusion, LLaDA2, SDAR and DiffusionGemma. Picking one of these models on the training page now runs the family's denoising objective via
DiffusionTrainer, instead of failing or silently training it as an autoregressive model. Needs #13341 (Core dispatch and samplers); without it Studio says which Unsloth update is required.What changes
Training
utils/models/diffusion_lm.py), and also resolves local checkpoints and Hub adapters back to their base. After load, the loaded model's profile is re-checked, so a model is never trained as autoregressive by mistake.FastModel. LoRA's default "all linear" choice maps to the family's own target modules. DoRA and LoftQ fail with a clear message instead of being ignored.DiffusionTrainer/DiffusionConfigfrom the same arguments and keeps the chosen context length. Packing is turned off for diffusion runs. CPT supervises every token.<|im_end|>,<tool_call>,<|fim_pad|>and the other special tokens are near-duplicates (cosine 0.97), so at 2e-4 a LoRA run swaps them: replies ended in<tool_call>or came back empty. At 5e-5 both answer cleanly; the other families are fine at 2e-4.cannot pickle 'SSLContext' object.check_model_inputs, which 5.3 does not have.Chat
FastModel. Replies come from the family's denoising sampler as one completion, held under the generation lock, with Stop cancelling it.Export
Hub
Testing
End to end through the Studio HTTP API on a fresh install (
install.sh --local). For each family: remote-code scan and approval,/api/train/start, poll to completion, adapter on disk,/api/inference/loadof the adapter, then/v1/chat/completions. The server log must say the diffusion sampler answered.GSAI-ML/LLaDA-8B-InstructinclusionAI/LLaDA-MoE-7B-A1B-InstructDream-org/Dream-v0-Instruct-7Bnvidia/Nemotron-Labs-Diffusion-3BinclusionAI/LLaDA2.0-miniJetLM/SDAR-1.7B-Chattrl-internal-testing/tiny-DiffusionGemmaForBlockDiffusionTiny checkpoints are random weights, so the chat text itself is noise; the check is that the request is answered by the family's sampler.
Then the real checkpoints, 30 LoRA steps each at Studio's defaults, chat "Question 3: what is 3 plus 3?" (greedy; needs the companion PR's weight-loading and end-of-turn fixes):
tests/test_diffusion_lm_studio.py: 72 tests covering detection, LoRA targets, trainer choice, packing, the Dream / SDAR learning-rate default, export refusals, chat dispatch and the pickling fallback.text-diffusion-lm-capabilities.test.ts; the build passes.Export page, before and after
The same LLaDA LoRA training run (trained in Studio) is selected on both sides. Before, GGUF and Merged can be picked: there is no merged save for these models yet, and Studio would serve a GGUF through llama-server as an ordinary left-to-right model. After, both are disabled with the reason on hover, and LoRA Only remains.