Repository navigation
Studio: torch 2.13 for new Linux cu130 Python 3.13 installs, existing installs keep their torch - #12150
Conversation
…eep existing torch The prebuilt-wheels-cu13 release ships flash-attn, causal-conv1d and mamba-ssm for torch 2.13 and 2.14 on cp313 linux_x86_64 cu13. New installs on exactly that route now get torch 2.13 (the release vLLM and SGLang pin) with torchvision 0.28 and torchaudio 2.11. Every other route keeps its window unchanged. Existing installs keep their torch: the kept-release pin is evaluated against its own 2.4-2.14 window instead of the new-install spec, the kept pairing asks for torchaudio 2.11 once the torch minor is past it, and studio update repairs on the cu130 route reinstall the resident release rather than a range.
…e torch >= 2.13 through core updates studio update first runs the setup code of the installed release, which upgrades unsloth under its own torch cap: with 2026.9.11 (torch<2.13.0) a torch 2.13 install was swapped for PyPI's generic 2.12.1 and lost its prebuilt kernels. The 2.13 route now also requires the newest unsloth on PyPI to admit torch 2.13, answering no on any fetch or parse failure, and the core package update pins a resident torch >= 2.13 via UV_OVERRIDE the way install.sh already does for every unsloth install.
|
@codex security review |
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 Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
… override undo the update freeze
…e override includes resolvable
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2590d3f327
ℹ️ 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".
| include = _OVERRIDE_INCLUDE.match(line) | ||
| if include and "://" not in include[2] and not os.path.isabs(include[2]): | ||
| line = f"{include[1]}{(base / include[2]).resolve()}{include[3]}" | ||
| lines.append(line) |
There was a problem hiding this comment.
Filter torch overrides in recursively included files
When an inherited UV_OVERRIDE contains -r nested.txt or -c nested.txt and that included file constrains torch, torchvision, or torchaudio, rewriting and retaining the include leaves that constraint active beside the newly generated exact pins. For example, a nested torch<2.13 conflicts with the generated torch==2.13.0+cu130, causing uv to report an unsatisfiable resolution; the newly disabled pip fallback then aborts every core update. The fresh case not covered by the earlier relative-path fix is that torch entries are filtered only from the top-level inherited file, not from files reached through these retained includes.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Leaving this: a nested file in a user-supplied UV_OVERRIDE that caps torch below the installed release is a request uv should refuse, and install.sh's own merge filters only the top-level files the same way. Recursing through include chains here would go past what either installer does.
…ving 2.13 to install.sh's gate
|
@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: cdc1933b74
ℹ️ 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".
| _pypi_unsloth_admits_torch() { | ||
| _pua_off=$(printf '%s' "${UV_OFFLINE:-}" | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]') | ||
| case "$_pua_off" in 1|t|true|y|yes|on) echo "no"; return ;; esac | ||
| if [ -n "${UV_EXCLUDE_NEWER:-}${UV_EXCLUDE_NEWER_PACKAGE:-}" ] || _mirror_configured uv; then |
There was a problem hiding this comment.
Disable the route for find-links package sources
When UV_FIND_LINKS (or find-links in uv configuration) supplies a newer/internal unsloth distribution, this condition does not reject the gate because _mirror_configured uv checks only index-related settings. The local uv 0.12.1 help pip install describes --find-links as locations providing candidate distributions in addition to registry indexes, so uv can select a release whose torch cap differs from the public-PyPI JSON checked here. The generated override then forces torch 2.13 anyway, and the first update can run that selected release's older setup and downgrade torch—the exact failure this gate is intended to prevent. Treat find-links as an alternate package source or inspect the release uv will actually select.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing this: an Unsloth Studio home that pulls unsloth itself from a find-links location is not a supported setup, and indexes and mirrors, which is where custom sources actually come from, already disable the route.
|
Codex Review: Didn't find any major issues. Hooray! 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/install_python_stack.py
|
@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: cc868cb288
ℹ️ 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 { [ "$_EXISTING_INSTALL" = false ] || [ "${UNSLOTH_TORCH_UPGRADE:-0}" = "1" ]; } \ | ||
| && [ "$(_pypi_unsloth_admits_torch "2.13.0")" = "yes" ]; then | ||
| _CU130_NEW_INSTALL_ROUTE=true |
There was a problem hiding this comment.
Keep the resident torch when the upgrade gate closes
When an existing Linux x86_64/cu130/Python 3.13 home already has torch 2.13 or 2.14, the Settings repair passes UNSLOTH_TORCH_UPGRADE=1. If this PyPI gate returns no because of a transient metadata timeout, offline/cutoff settings, or a configured mirror, _CU130_NEW_INSTALL_ROUTE remains false, but the same upgrade variable makes _previous_torch_pin return empty. The installer consequently falls back to the old <2.12 constraint and downgrades the working installation to torch 2.11, losing its matching kernels. Preserve the resident release unless the newer route has actually passed its gate.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in bf1cd08: when UNSLOTH_TORCH_UPGRADE=1 is set and the 2.13 route stays closed, a resident release above the default range is now kept instead of reinstalled at 2.11. Covered for an unreachable and a capped PyPI in tests/sh/test_cu130_torch213_route.sh.
…rch above the default range
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Delightful! 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". |
…isting installs keep their torch (unslothai#13263) * Studio: torch 2.13 for new Windows x64 cu130 Python 3.13 installs, existing installs keep their torch Windows port of unslothai#12150. install.ps1 gives a new install torch 2.13 when the torch index is cu130, the machine and the venv interpreter are both x64, the venv is CPython 3.13, and the newest unsloth on PyPI admits torch 2.13 (no on UV_OFFLINE, UV_EXCLUDE_NEWER*, a configured uv index, or any fetch/parse failure; UNSLOTH_PYPI_JSON_URL points the check elsewhere). That is the only Windows route the prebuilt-wheels-cu13 kernel wheels can serve. Existing installs keep their release: on that route the preservation window widens to <2.15, every earlier layout (occupied venv, legacy .venv with or without a working interpreter, CWD-relative venv) counts as an existing home, and UNSLOTH_TORCH_UPGRADE=1 opts in. An upgrade with the route closed keeps a resident release above the default range instead of moving it down. A kept torch 2.12+ now pairs with torchaudio 2.11 (the last release) in install.ps1 and in setup.ps1's kept-release paths. setup.ps1 picks the triton-windows minor from the installed torch (2.13 -> 3.7, 2.14 -> 3.8, otherwise <3.7; Windows on ARM unchanged). install_python_stack.py's repair specs and core-update torch freeze cover native Windows x64 as well as Linux. * install.ps1: keep an occupied venv's torch from version.py when its interpreter cannot answer * Windows: the missing-Triton hint names the triton-windows range for the resident torch * Keep the CWD-relative legacy venv's torch on migration; Windows-on-ARM Triton hint * Trim comments in the Windows torch 2.13 install route * Keep the resident torch on every Windows repair path: forced setup reinstall, migrated venv, CWD venv without python.exe; bounded fallback; UV_OFFLINE through Test-UvEnvFlag * Gate the cu130 torch 2.13 route on --package unsloth and ignore prerelease resident torch * Skip the core-update torch freeze when the override path cannot be made space-free; match --package unsloth case-insensitively in install.sh * Never let a setup or update retry move torch to another release; keep the resident torch on unforced setup runs * Keep the torch freeze file user-private and pin a resident torch only within the index's published range * Give the Windows torch freeze file a current-user-only ACL; freeze emulated x64 venvs on Windows on ARM too
New Studio installs on Linux x86_64 with an NVIDIA driver on the cu130 route and Python 3.13 now get torch 2.13, together with the
prebuilt-wheels-cu13flash-attn 2.8.4, causal-conv1d 1.7.0 and mamba-ssm 2.3.2.post1 wheels built for it. Existing installs keep the torch they have.What changes
New installs (install.sh): one new route, used only when all of these hold:
cu130(driver >= 13.0, no pre-Turing GPU, which is capped to cu126 before this point)That route installs
torch>=2.13.0,<2.14.0,torchvision>=0.28.0,<0.29.0and torchaudio 2.11. torchaudio 2.11 is the last release (stable ABI, no torch pin), and vLLM 0.30 and SGLang 0.5.20 use the same pairing: both pin torch 2.13.0. Every other route keeps its current window unchanged: cu126, cu128, CPU, ROCm, XPU, macOS, aarch64, Windows, and Python 3.11/3.12.Why the PyPI check:
unsloth studio updatefirst runs the setup code bundled in the installed release. That code re-resolves unsloth under the release's own torch cap. With 2026.9.11 (torch<2.13.0), a torch 2.13 install was swapped for PyPI's generic torch 2.12.1 on the first update and lost the matching prebuilt kernels (reproduced below). Until a release admits 2.13, the route stays off and new installs get exactly what they get today. Any fetch or parse failure answers no.UNSLOTH_PYPI_JSON_URLcan point the check at a mirror.Existing installs:
torch>=2.4,<2.15.0window, not the new-install spec, so a re-run keeps any 2.4 to 2.14 release. Before this, raising the default would also have moved every 2.11 user.2.11.*instead of a2.12.*/2.13.*that does not exist.studio updaterepairs (_ensure_cuda_torch,_ensure_expected_torch_flavor): on the cu130 route they reinstall the resident release instead of the<2.12range, which would have downgraded a 2.13 install.studio updatecore package step: pins a resident torch >= 2.13 throughUV_OVERRIDE, the same way install.sh already freezes the trio for every with-deps unsloth install.UNSLOTH_TORCH_UPGRADE=1or a fresh home still moves an existing install to the new default.UNSLOTH_TORCH_UPGRADE=1, so a user who asks for a reinstall gets the newest supported torch. The automatic startup repair is unchanged and keeps the resident release.~/.unsloth/studio/.venvwhose interpreter is missing or broken still counts as an existing install, so it keeps its recorded torch instead of taking the new-install route.Real installs on a B200 (driver 590, isolated HOME and UNSLOTH_STUDIO_HOME per cell)
"future PyPI" is PyPI's current unsloth metadata with only the torch cap changed to
<2.15.0, served throughUNSLOTH_PYPI_JSON_URL.studio update --localagainst PyPI's real<2.13.0studio updatewith main's setup codestudio update --localUNSLOTH_TORCH_UPGRADE=1re-run--python 3.12, future PyPIStudio's own on-demand installers on the A3 venv pulled
causal_conv1d-1.7.0+cu13torch2.13andmamba_ssm-2.3.2.post1+cu13torch2.13from the release, and both import.On the A3 venv (torch 2.13.0+cu130), 20 LoRA SFT steps each on GPU 2, with a CUDA profiler pass on step 5:
flash_fwd_kernel,flash_bwd_dq_dk_dv_loop_seqk_parallel_kernelDirect kernel checks on the same venv: flash-attn forward matches SDPA to 0.0081 max abs error, causal-conv1d forward runs, and mamba-ssm forward and backward run.
Rechecked on a B200 at the current head
prebuilt-wheels-cu13, each kernel matches its reference (bf16 flash-attn max error 0.016)unsloth/Qwen3-0.6B, 30 steps)existing install has torch 2.11.0+cu130 -- keeping itUNSLOTH_TORCH_UPGRADE=1(what the manual repair now sets)Tests
tests/sh/test_cu130_torch213_route.sh(80 checks, including the legacy home cases) covers the route predicate across index, OS, arch, Python and PyPI answers, plus the preservation window, the torchaudio pairing, and the kept pin being evaluated against the preservation window. Against main's install.sh: 25 of 36 fail (before the PyPI gate checks were added).studio/backend/tests/test_cu130_repair_torch_specs.py(29 tests) covers the repair specs and the core-update freeze. Every non-cu130 route returns the identical spec object.only_a_manual_repair_asks_the_installer_for_a_newer_torch; all 654cargo testtests pass.tests/shscripts pass.tests/python,tests/studio/installand the spec tests fail the same 5 tests on this branch and on its merge base (torchcodec provenance, RL config pickling and dependency-pass tests, which this venv cannot satisfy).Release order
The published cap comes from the
pipbranch. #12152 raises it to<2.15.0, and #12151 adds the matching Core extras. This route turns itself on once a release with that ceiling is on PyPI, whatever order the PRs merge in.Not tested here
Cloud and AMD runs
These ran from a branch combining this PR with #11491 and #12024:
studio/setup.sh --localfollowed by a 5 step LoRA SFT onunsloth/Qwen2.5-0.5B-Instruct. Colab T4, L4, A100 and G4 all passed with finite losses on Colab's system torch 2.11.0+cu130, so an existing torch is kept. Kaggle 2x T4 passed on both GPUs with torch 2.10+cu128. On AMD Strix Halo gfx1151, torch stayed at 2.11.0+rocm7.13.0 on both base and head, re-running the installer kept it, and the training loss matched (NO_REGRESSION).The switchboard (Studio journeys on merge base vs head) reported no functional regression: 47 SAME and one DOM-only difference with 0 changed pixels. The Desktop repair dialog text cannot be rendered on this host.