Skip to content

DiffusionGemma: set UNSLOTH_IS_PRESENT so the shim runs on a clean install#6259

Merged
danielhanchen merged 1 commit into
mainfrom
studio-diffusiongemma-shim-unsloth-present
Jun 12, 2026
Merged

DiffusionGemma: set UNSLOTH_IS_PRESENT so the shim runs on a clean install#6259
danielhanchen merged 1 commit into
mainfrom
studio-diffusiongemma-shim-unsloth-present

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

A clean install cannot run DiffusionGemma. The runner spawns python -m unsloth_zoo.diffusion_studio.shim, and unsloth_zoo/__init__.py refuses to import unless UNSLOTH_IS_PRESENT is in the environment (normally set by import unsloth). The shim never imports unsloth, so on a fresh PyPI/install.sh setup the subprocess dies with:

ImportError: Please install Unsloth via `pip install unsloth`!

and the model load returns a 500 (DiffusionGemma runner failed to become healthy). It only appeared to work in dev because an already-exported UNSLOTH_IS_PRESENT was inherited from the shell.

Fix

Set UNSLOTH_IS_PRESENT=1 in the runner child environment, exactly as unsloth does 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_PRESENT stripped from the parent env (the clean-install condition): loading unsloth/diffusiongemma-26B-A4B-it-GGUF now returns 200, the shim child has UNSLOTH_IS_PRESENT=1, the visual-server reaches READY, and a streaming request produces diffusion_frame events. Previously this was a 500 with the ImportError.

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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 danielhanchen merged commit 2a01ba8 into main Jun 12, 2026
32 checks passed
@danielhanchen danielhanchen deleted the studio-diffusiongemma-shim-unsloth-present branch June 12, 2026 14:36
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).
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