DiffusionGemma: set UNSLOTH_IS_PRESENT so the shim runs on a clean install#6259
Merged
Merged
Conversation
A clean install could not run DiffusionGemma: the runner spawns python -m unsloth_zoo.diffusion_studio.shim, and unsloth_zoo refuses to import unless UNSLOTH_IS_PRESENT is set (normally by import unsloth). The shim never imports unsloth, so the subprocess died with 'Please install Unsloth via pip install unsloth!' and the model load failed with a 500. Set the flag in the runner child env, as unsloth does on import.
Contributor
There was a problem hiding this comment.
Code Review
This pull request modifies _start_diffusion_server in studio/backend/core/inference/llama_cpp.py to set the UNSLOTH_IS_PRESENT environment variable to "1", preventing loading issues with unsloth_zoo when imported by the shim. There are no review comments on this pull request, and I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
danielhanchen
added a commit
that referenced
this pull request
Jun 12, 2026
The studio backend lazily imports unsloth_zoo submodules (export's llama_cpp, hardware's vllm_utils, mlx, chat_templates). Each imports the top-level unsloth_zoo, which raises 'Please install Unsloth via pip install unsloth' unless UNSLOTH_IS_PRESENT is set (normally by import unsloth). Only hardware.py set it per-site; the rest crash on a clean install, and it surfaced on Windows. Set it once at backend startup (as unsloth does on import) so every site, and the DiffusionGemma runner, works across platforms. Follow-up to #6259 (which covered only the shim subprocess env).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A clean install cannot run DiffusionGemma. The runner spawns
python -m unsloth_zoo.diffusion_studio.shim, andunsloth_zoo/__init__.pyrefuses to import unlessUNSLOTH_IS_PRESENTis in the environment (normally set byimport unsloth). The shim never importsunsloth, so on a fresh PyPI/install.sh setup the subprocess dies with:and the model load returns a 500 (
DiffusionGemma runner failed to become healthy). It only appeared to work in dev because an already-exportedUNSLOTH_IS_PRESENTwas inherited from the shell.Fix
Set
UNSLOTH_IS_PRESENT=1in the runner child environment, exactly asunslothdoes on import. Follow-up to #6255 (the flag belongs with the runner launch but landed after that PR merged).Verification
Launched Studio with
UNSLOTH_IS_PRESENTstripped from the parent env (the clean-install condition): loadingunsloth/diffusiongemma-26B-A4B-it-GGUFnow returns 200, the shim child hasUNSLOTH_IS_PRESENT=1, the visual-server reaches READY, and a streaming request producesdiffusion_frameevents. Previously this was a 500 with the ImportError.