Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
fix: no-torch install deps without pulling torch transitively (#4650)
Daniel Haneacaf6827c0c
diff --git a/install.ps1 b/install.ps1index df80f23716a..215c8f6040e 100644--- a/install.ps1+++ b/install.ps1@@ -663,14 +663,29 @@ shell.Run cmd, 0, False# CUDA wheels. Missing dependencies (transformers, trl, peft, etc.)# are still pulled in because they are new, not upgrades.#+ # ── Helper: find no-torch-runtime.txt ──+ function Find-NoTorchRuntimeFile {+ if ($StudioLocalInstall -and (Test-Path (Join-Path $RepoRoot "studio\backend\requirements\no-torch-runtime.txt"))) {+ return Join-Path $RepoRoot "studio\backend\requirements\no-torch-runtime.txt"+ }+ $installed = Get-ChildItem -Path $VenvDir -Recurse -Filter "no-torch-runtime.txt" -ErrorAction SilentlyContinue |+ Where-Object { $_.FullName -like "*studio*backend*requirements*no-torch-runtime.txt" } |+ Select-Object -ExpandProperty FullName -First 1+ return $installed+ }+if ($_Migrated) {# Migrated env: force-reinstall unsloth+unsloth-zoo to ensure clean state# in the new venv location, while preserving existing torch/CUDAWrite-Host "==> Upgrading unsloth in migrated environment..."if ($SkipTorch) {- # No-torch: install packages without deps to avoid pulling torch.- # Runtime deps are installed by install_python_stack.py via no-torch-runtime.txt.+ # No-torch: install unsloth + unsloth-zoo with --no-deps, then+ # runtime deps (typer, safetensors, transformers, etc.) with --no-deps.uv pip install --python $VenvPython --no-deps --reinstall-package unsloth --reinstall-package unsloth-zoo "unsloth>=2026.3.14" unsloth-zoo+ $NoTorchReq = Find-NoTorchRuntimeFile+ if ($NoTorchReq) {+ uv pip install --python $VenvPython --no-deps -r $NoTorchReq+ }} else {uv pip install --python $VenvPython --reinstall-package unsloth --reinstall-package unsloth-zoo "unsloth>=2026.3.14" unsloth-zoo}@@ -692,9 +707,13 @@ shell.Run cmd, 0, FalseWrite-Host "==> Installing unsloth (this may take a few minutes)..."if ($SkipTorch) {- # No-torch: install packages without deps to avoid pulling torch.- # Runtime deps are installed by install_python_stack.py via no-torch-runtime.txt.+ # No-torch: install unsloth + unsloth-zoo with --no-deps, then+ # runtime deps (typer, safetensors, transformers, etc.) with --no-deps.uv pip install --python $VenvPython --no-deps --upgrade-package unsloth --upgrade-package unsloth-zoo "unsloth>=2026.3.14" unsloth-zoo+ $NoTorchReq = Find-NoTorchRuntimeFile+ if ($NoTorchReq) {+ uv pip install --python $VenvPython --no-deps -r $NoTorchReq+ }if ($StudioLocalInstall) {Write-Host "==> Overlaying local repo (editable)..."uv pip install --python $VenvPython -e $RepoRoot --no-deps@@ -735,9 +754,8 @@ shell.Run cmd, 0, Falsereturn}# Tell setup.ps1 to skip base package installation (install.ps1 already did it)- # When no-torch, don't skip base so install_python_stack installs- # no-torch-runtime.txt (the runtime deps that --no-deps skipped).- $env:SKIP_STUDIO_BASE = if ($SkipTorch) { "0" } else { "1" }+ # Tell setup.ps1 to skip base package installation (install.ps1 already did it)+ $env:SKIP_STUDIO_BASE = "1"$env:STUDIO_PACKAGE_NAME = $PackageName$env:UNSLOTH_NO_TORCH = if ($SkipTorch) { "true" } else { "false" }if ($StudioLocalInstall) {diff --git a/install.sh b/install.shindex 16736b43ee2..4c960a129e9 100755--- a/install.sh+++ b/install.sh@@ -891,6 +891,21 @@ fi# ── Resolve repo root (for --local installs) ──_REPO_ROOT="$(cd "$(dirname "$0" 2>/dev/null || echo ".")" && pwd)"+# ── Helper: find no-torch-runtime.txt (local repo or site-packages) ──+_find_no_torch_runtime() {+ # Check local repo first (for --local installs)+ if [ -f "$_REPO_ROOT/studio/backend/requirements/no-torch-runtime.txt" ]; then+ echo "$_REPO_ROOT/studio/backend/requirements/no-torch-runtime.txt"+ return+ fi+ # Check inside installed package+ _rt=$(find "$VENV_DIR" -path "*/studio/backend/requirements/no-torch-runtime.txt" -print -quit 2>/dev/null || echo "")+ if [ -n "$_rt" ]; then+ echo "$_rt"+ return+ fi+}+# ── Detect GPU and choose PyTorch index URL ──# Mirrors Get-TorchIndexUrl in install.ps1.# On CPU-only machines this returns the cpu index, avoiding the solver@@ -947,12 +962,17 @@ if [ "$_MIGRATED" = true ]; then# in the new venv location, while preserving existing torch/CUDAecho "==> Upgrading unsloth in migrated environment..."if [ "$SKIP_TORCH" = true ]; then- # No-torch: install packages without deps to avoid pulling torch.- # Runtime deps (safetensors, transformers, etc.) are installed by- # install_python_stack.py via no-torch-runtime.txt.+ # No-torch: install unsloth + unsloth-zoo with --no-deps (current+ # PyPI metadata still declares torch as a hard dep), then install+ # runtime deps (typer, safetensors, transformers, etc.) with --no-deps+ # to prevent transitive torch resolution.uv pip install --python "$_VENV_PY" --no-deps \--reinstall-package unsloth --reinstall-package unsloth-zoo \"unsloth>=2026.3.14" unsloth-zoo+ _NO_TORCH_RT="$(_find_no_torch_runtime)"+ if [ -n "$_NO_TORCH_RT" ]; then+ uv pip install --python "$_VENV_PY" --no-deps -r "$_NO_TORCH_RT"+ fielseuv pip install --python "$_VENV_PY" \--reinstall-package unsloth --reinstall-package unsloth-zoo \@@ -974,11 +994,15 @@ elif [ -n "$TORCH_INDEX_URL" ]; then# Fresh: Step 2 - install unsloth, preserving pre-installed torchecho "==> Installing unsloth (this may take a few minutes)..."if [ "$SKIP_TORCH" = true ]; then- # No-torch: install packages without deps to avoid pulling torch.- # Runtime deps are installed by install_python_stack.py via no-torch-runtime.txt.+ # No-torch: install unsloth + unsloth-zoo with --no-deps, then+ # runtime deps (typer, safetensors, transformers, etc.) with --no-deps.uv pip install --python "$_VENV_PY" --no-deps \--upgrade-package unsloth --upgrade-package unsloth-zoo \"unsloth>=2026.3.14" unsloth-zoo+ _NO_TORCH_RT="$(_find_no_torch_runtime)"+ if [ -n "$_NO_TORCH_RT" ]; then+ uv pip install --python "$_VENV_PY" --no-deps -r "$_NO_TORCH_RT"+ fiif [ "$STUDIO_LOCAL_INSTALL" = true ]; thenecho "==> Overlaying local repo (editable)..."uv pip install --python "$_VENV_PY" -e "$_REPO_ROOT" --no-deps@@ -1036,21 +1060,15 @@ if [ -n "$VENV_ABS_BIN" ]; thenfiecho "==> Running unsloth setup..."-# When no-torch, don't skip base so install_python_stack installs-# no-torch-runtime.txt (the runtime deps that --no-deps skipped).-_SKIP_BASE=1-if [ "$SKIP_TORCH" = true ]; then- _SKIP_BASE=0-fiif [ "$STUDIO_LOCAL_INSTALL" = true ]; then- SKIP_STUDIO_BASE="$_SKIP_BASE" \+ SKIP_STUDIO_BASE=1 \STUDIO_PACKAGE_NAME="$PACKAGE_NAME" \STUDIO_LOCAL_INSTALL=1 \STUDIO_LOCAL_REPO="$_REPO_ROOT" \UNSLOTH_NO_TORCH="$SKIP_TORCH" \bash "$SETUP_SH" </dev/nullelse- SKIP_STUDIO_BASE="$_SKIP_BASE" \+ SKIP_STUDIO_BASE=1 \STUDIO_PACKAGE_NAME="$PACKAGE_NAME" \UNSLOTH_NO_TORCH="$SKIP_TORCH" \bash "$SETUP_SH" </dev/nulldiff --git a/studio/backend/requirements/no-torch-runtime.txt b/studio/backend/requirements/no-torch-runtime.txtindex ea289f694b6..7133fe8922c 100644--- a/studio/backend/requirements/no-torch-runtime.txt+++ b/studio/backend/requirements/no-torch-runtime.txt@@ -1,7 +1,18 @@# Runtime dependencies for no-torch (GGUF-only) mode.-# These are normally pulled in transitively by unsloth-zoo, but-# --no-deps skips them to avoid torch. Install these explicitly.-# Mirrors the [huggingfacenotorch] extras from pyproject.toml.+# Installed with --no-deps to prevent transitive torch resolution+# from packages like accelerate, peft, trl, sentence-transformers.+#+# Includes unsloth's own direct deps (typer, pydantic, pyyaml,+# nest-asyncio) since unsloth is also installed with --no-deps+# (current PyPI metadata still declares torch as a hard dep).++# unsloth direct deps (from pyproject.toml [project].dependencies)+typer+pydantic+pyyaml+nest-asyncio++# HF ecosystem (from [huggingfacenotorch] extras in pyproject.toml)wheel>=0.42.0packagingnumpydiff --git a/studio/install_python_stack.py b/studio/install_python_stack.pyindex d32e29d0f7f..e8ae22f470e 100644--- a/studio/install_python_stack.py+++ b/studio/install_python_stack.py@@ -462,13 +462,25 @@ def install_python_stack() -> int:if skip_base:print(_green(f"✅ {package_name} already installed — skipping base packages"))elif NO_TORCH:- # No-torch mode: unsloth + unsloth-zoo are already installed with- # --no-deps by install.sh/install.ps1. Install the runtime deps- # (safetensors, transformers, datasets, etc.) from no-torch-runtime.txt.+ # No-torch update path: install unsloth + unsloth-zoo with --no-deps+ # (current PyPI metadata still declares torch as a hard dep), then+ # runtime deps with --no-deps (avoids transitive torch)._progress("base packages (no torch)")+ pip_install(+ f"Updating {package_name} + unsloth-zoo (no-torch mode)",+ "--no-cache-dir",+ "--no-deps",+ "--upgrade-package",+ package_name,+ "--upgrade-package",+ "unsloth-zoo",+ package_name,+ "unsloth-zoo",+ )pip_install("Installing no-torch runtime deps","--no-cache-dir",+ "--no-deps",req = REQ_ROOT / "no-torch-runtime.txt",)if local_repo: