Skip to content

Studio: finish an update with the installer it installs - #11566

Merged
danielhanchen merged 2 commits into
unslothai:mainfrom
oobabooga:update-runs-new-installer
Sep 22, 2026
Merged

danielhanchen merged 2 commits into
unslothai:mainfrom
oobabooga:update-runs-new-installer

Conversation

@oobabooga

Copy link
Copy Markdown
Member

unsloth studio update from 2026.9.7 to 2026.9.8 leaves Diffusers at 0.40.0, so Qwen-Image-2.1 refuses to load with "needs diffusers >= 0.41.0 (QwenImage21Pipeline)". Running the update again does nothing: it reports "unsloth 2026.9.8 is up to date" and skips the dependency pass. Some users only got Qwen-Image-2.1 working after updating twice. The desktop app is affected the same way, because its in-app update runs the same unsloth studio update.

Cause

Three separate problems:

  1. The update runs the old installer. setup.sh / setup.ps1 run the installed install_python_stack.py. Its core-packages step upgrades unsloth, which replaces that file on disk, but the running process keeps the old code and finishes the old step list. The 2026.9.7 installer has no pinned Diffusers main step (Add the Qwen-Image-2.1 family, and the Diffusers it needs by default #11405), so the update that installs 2026.9.8 skips it. The update log shows 17 steps, ending at "diffusers pin"; the 2026.9.8 installer has 18.
  2. The fast path cannot see a missing Diffusers build. Once unsloth matches PyPI, setup.sh / setup.ps1 skip the dependency pass, and none of the fast-path escapes checks for the pinned Diffusers build. The install stays on the release until the next version bump.
  3. Pinned git builds never count as installed. diffusers-main.txt and triton-kernels.txt name https://github.com/<org>/<repo>.git, while uv records the URL without .git in direct_url.json. _direct_reference_is_installed compared the two after stripping only a trailing slash, so neither build ever matched. Every dependency pass reinstalled the Diffusers release, then re-cloned and rebuilt the pinned commit, and re-cloned triton_kernels.

Fix

  • install_python_stack.py reads its own source at startup. If the file differs after the core-packages step, it raises past the pass lock and reruns the new file in a subprocess, which finishes the pass. UNSLOTH_INSTALLER_RERUN=1 on the rerun prevents a loop. A subprocess instead of os.exec*, because on Windows exec returns to setup.ps1 while the child keeps running.
  • New probe, install_python_stack.py --diffusers-main-needs-dependency-pass, called from the fast-path escapes in both setup.sh and setup.ps1. It exits 0 (force the pass) when the build is wanted but not installed, or when UNSLOTH_DIFFUSERS_MAIN=0 is set and the main build is still installed. It keeps the fast path when there is no git, on Python below 3.10, or when the last pass recorded a failed build. A failed build is now recorded as failed instead of skipped, so a host that cannot reach github.com does not rerun the whole pass on every update. Under UV_OFFLINE, the probe's answer is reported and the pass is left for the next online update, the same way the missing-torch escape handles it.
  • _vcs_url_key drops a trailing / and .git before comparing, so an installed pinned build is recognized and skipped.

Before and after

Live updates, each in an isolated copy of a real Studio venv (CUDA, Linux), run through unsloth studio update with UNSLOTH_TAURI_UPDATE=1.

Existing install on 2026.9.8 with Diffusers 0.40.0, the state the 2026.9.7 to 2026.9.8 update left behind:

main this PR
Update 1 "up to date", Diffusers 0.40.0 pass forced, Diffusers 0.41.0.dev0 @ 80c7ed26
Update 2 "up to date", Diffusers 0.40.0 "dependencies up to date"

Upgrade between two locally built releases: the old one lacks the Diffusers main step, the new one has it.

main this PR
Update 1 unsloth upgraded, Diffusers 0.40.0 unsloth upgraded, Diffusers 0.41.0.dev0 @ 80c7ed26
Update 2 Diffusers 0.41.0.dev0 unchanged

Before the URL fix, the second update in the first table forced the pass again and rebuilt Diffusers even though the pinned build was installed.

Tests

tests/studio/install: 7526 passed, 1631 skipped. New cases cover the rerun decision and handoff, every probe branch (not installed, installed, no git, recorded failure, opt-out), and uv's direct_url.json URL shape. bash -n studio/setup.sh passes.

Scope

  • The rerun lives in the installer that starts the update, so it only takes effect for updates that start from a release containing this change. The update into this release still runs the older installer. The probe covers the Diffusers case either way.
  • After the rerun, the rest of setup.sh / setup.ps1 (transformers sidecars, llama.cpp) is still the old script. Only the dependency pass reruns.
  • The rerun repeats the pip bootstrap and core-packages steps once, and it runs with no prior-pass evidence, as a version-bumping update already does.
  • The setup.ps1 change was not executed: no Windows host or PowerShell was available. The Windows installer's structural tests pass.

@oobabooga

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@danielhanchen

Copy link
Copy Markdown
Member

This is right and it should go in. It covers three causes I did not, and cause 1 explains the "worked after updating twice" reports directly: the running installer is the old one, so the update that installs the version carrying the Diffusers main step never runs that step.

Cause 2 matches something I hit while testing #11565 and wrote off as out of scope. A plain unsloth studio update on a 2026.9.8 install prints

python         unsloth 2026.9.8 is up to date
python         dependencies up to date

and skips the whole pass, so an install left on 0.40.0 has no way back on its own. Your probe is the fix for that.

Cause 3 is a good catch and worth calling out for how quiet it was: every pass was re-cloning and rebuilding a pinned commit that was already installed, and nothing in the output said so.

One interaction to fix before both land. #11565 makes a host with no working git install the same pinned commit from https://github.com/huggingface/diffusers/archive/<commit>.zip, so git is no longer the thing that decides whether the pass could succeed. Your probe has

if sys.version_info < DIFFUSERS_MAIN_MIN_PYTHON or not _has_working_git():
    return False

With both changes in, that early return keeps the fast path on exactly the hosts that can now be repaired, and a git-less install stays on 0.40.0 forever with no update that forces the pass. It wants to be "no git AND no archive route" rather than "no git", which is one call to the helper #11565 adds. The Python floor stays as is.

We also both touch _direct_reference_is_installed, so whichever lands second needs a small rebase. Mine teaches it to read an archive install back out of direct_url.json (archive_info instead of vcs_info), which is a separate branch from your _vcs_url_key normalisation and should compose cleanly. Your .git fix is needed for the git route either way; the archive URL I derive is already normalised, since the .git suffix is stripped when it is built.

Happy for this to go in first and I will rebase #11565 onto it.

Two small things:

  • Recording a failed build as failed rather than skipped is the right call, but it is also now load-bearing for whether an update ever retries. A host that failed once because github.com was briefly unreachable keeps the fast path until the next version bump. Worth a sentence in the note so the state is discoverable, or a way to clear it short of UNSLOTH_STUDIO_FULL_DEPS=1.
  • setup.ps1 being unexecuted is fine to state, but this one is worth a real Windows run before merge given the rerun is a subprocess handoff and that is the platform the subprocess choice exists for. I can put it through the Windows staging leg if that helps.

For reference, the #11565 side reproduced on the shipped bundles with git shimmed to exit 1: 0.1.811 install and 0.1.812 update both leave 0.40.0 on stock, and the same dependency pass with the branch logs diffusers main (no git, from archive) and ends at 0.41.0.dev0 at 80c7ed26.

@danielhanchen
danielhanchen merged commit 6f6d49a into unslothai:main Sep 22, 2026
53 of 73 checks passed
pull Bot pushed a commit to RealShocky/unsloth that referenced this pull request Sep 22, 2026
* Let the stdout guard read writes, not flushes

test_no_direct_stdout_writes flags sys.stdout.write and sys.stdout.flush outside
the progress helpers, and has failed on main since unslothai#11566, which flushes stdout
and stderr before rerunning the installer it just installed. That flush is
needed: the child writes to the same descriptors, so anything still buffered
would land after its output. A flush emits nothing and cannot glue text onto
the progress bar, which is what the guard exists for. It now matches write
only; a direct write on the same line still fails it.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
* Let the stdout guard read writes, not flushes

test_no_direct_stdout_writes flags sys.stdout.write and sys.stdout.flush outside
the progress helpers, and has failed on main since unslothai#11566, which flushes stdout
and stderr before rerunning the installer it just installed. That flush is
needed: the child writes to the same descriptors, so anything still buffered
would land after its output. A flush emits nothing and cannot glue text onto
the progress bar, which is what the guard exists for. It now matches write
only; a direct write on the same line still fails it.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
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.

2 participants