Skip to content

Studio: torch 2.13 for new Windows x64 cu130 Python 3.13 installs, existing installs keep their torch - #13263

Merged
danielhanchen merged 11 commits into
mainfrom
win-cu130-torch213-route
Oct 11, 2026
Merged

danielhanchen merged 11 commits into
mainfrom
win-cu130-torch213-route

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Oct 11, 2026 •

Copy link
Copy Markdown
Member

New Studio installs on Windows x64 with an NVIDIA driver on the cu130 route and Python 3.13 now get torch 2.13, the same route #12150 added for Linux. That is the torch the new win_amd64 flash-attn 2.8.4, causal-conv1d 1.7.0 and mamba-ssm 2.3.2.post1 wheels on prebuilt-wheels-cu13 are built for. Existing installs keep the torch they have.

What changes

New installs (install.ps1): the route is taken only when all of these hold:

  • the resolved torch index is cu130
  • the machine is x64 (Windows on ARM keeps its NVIDIA index route) and the venv is CPython 3.13 win-amd64
  • the package is unsloth (a --package other than unsloth keeps the default, since the check reads unsloth's metadata; install.sh gets the same one-line gate)
  • the newest unsloth on PyPI declares a torch range containing 2.13.0. The check is native PowerShell and answers no on offline mode, UV_EXCLUDE_NEWER*, a configured uv index, or any fetch or parse failure; UNSLOTH_PYPI_JSON_URL can point it at a mirror. Same reasoning as Studio: torch 2.13 for new Linux cu130 Python 3.13 installs, existing installs keep their torch #12150: studio update re-resolves under the installed release's own cap.

It installs torch>=2.13,<2.14, torchvision>=0.28,<0.29 and torchaudio 2.11. Every other route is unchanged: cu126, cu128, CPU, ROCm, XPU, Windows on ARM, and Python 3.11 / 3.12.

Existing installs

  • A new $script:ExistingInstall is decided before any venv is moved aside, for every earlier layout: the occupied new-layout venv, a legacy .venv with or without a working interpreter, and the CWD-relative ~/unsloth_studio venv.
  • Each of those records its torch release first, from the interpreter or, when that cannot answer, from torch\version.py on disk. Without that a resident 2.13 or 2.14 would fall back to the <2.12 default on a plain re-run.
  • On the cu130 route the kept release is checked against torch>=2.4,<2.15, so any 2.4 to 2.14 release stays. UNSLOTH_TORCH_UPGRADE=1 (what the Desktop manual repair already sets on every platform) opts in to the new default; with the route closed it keeps a resident 2.13 / 2.14 instead of moving it down.
  • A kept release that fails to reinstall in install.ps1 falls back to the old default, never to 2.13, and that fallback is the bounded trio, never a bare torch.
  • A legacy .venv that is migrated into the new layout keeps its torch: the migrated unsloth reinstall runs under the same torch overrides as the other paths and hands the kept release to setup.ps1, like install.sh.
  • setup.ps1 keeps the resident release whenever there is no installer handoff (unsloth studio update, the Desktop startup repair, a re-run of setup), forced or not. Unpinned, a missing torchvision alone resolved the newest torchvision and moved torch 2.13 to 2.14.1. Only a release the selected CUDA index publishes is pinned (cu126 from 2.6, cu128 2.7, cu129 2.8, cu130 2.9); a prerelease or dev build never is.
  • A kept release that fails to reinstall in setup now stops with the error instead of resolving a different release, like install_python_stack.py. That retry downloaded a second torch, usually after a transient failure. An unforced run retries exactly what an unpinned run would have done.
  • The studio update torch freeze writes its overrides file to a directory uv can name (%TEMP% through its short name, else %PUBLIC%, /tmp, /var/tmp) and stops rather than resolving unfrozen when none exists.
  • A kept torch 2.12 or newer pairs with torchaudio==2.11.*, in install.ps1 and in all three setup.ps1 trios.

Triton (studio/setup.ps1)

  • triton-windows is chosen from the installed torch right before the Triton step: torch 2.13 gets >=3.7,<3.8, torch 2.14 >=3.8,<3.9, anything else keeps <3.7. torch 2.13 pins triton 3.7.1 and 2.14 pins 3.8, and PyPI has cp313 win_amd64 triton-windows wheels for both. Windows on ARM is unchanged.
  • The worker's "Triton not found" hint (_msvc_env.py) names the same range for the resident torch, and the Windows on ARM floor on ARM64, instead of always <3.7.

studio update (install_python_stack.py): the cu130 repair specs and the core-update torch freeze from #12150 now apply on native Windows x64 too, so studio update does not downgrade a Windows torch 2.13 install. An emulated x64 Python on Windows on ARM is excluded.

Checked and unchanged: the Windows xFormers table already maps torch 2.13 + cu130 to xFormers 0.0.35.

Tests

  • New tests/studio/test_cu130_torch213_route.ps1 (100 checks): the route predicate across index, architecture, interpreter and platform; every PyPI gate answer including offline, upload cutoff and configured mirrors; Requires-Dist parsing; the kept-release window and the closed-route upgrade case; the on-disk version read for broken and CWD-relative venvs; the --package gate; the resident-torch probe on release, local, rc and dev versions; setup's own torch block run with the installer stubbed (unforced keep, forced keep, failed pins, UPGRADE=1, index floors); triton pairing; and where each piece is wired in.
  • studio/backend/tests/test_cu130_repair_torch_specs.py: 29 on main, 43 here, all passing. The main-side case asserting "win32 cu130 unchanged" now expects Windows x64 on the route; Windows on ARM exclusion and freeze cases are added.
  • New studio/backend/tests/test_msvc_env_triton_hint.py (6 tests).
  • tests/sh/test_cu130_torch213_route.sh: the --package gate on Linux.
  • Every tests/studio/*.ps1 that touches install.ps1 or setup.ps1 passes. The 4 test_rocm_support.py::TestProgressStepCountMatchesTotal failures are the same on main.

Windows install runs

On a windows-2022 runner (no GPU, so the cu130 index is forced with UNSLOTH_TORCH_INDEX_FAMILY=cu130), with the Windows wheels from #13261 attached to a staging release:

Run torch flash-attn
main, fresh install 2.11.0+cu130 none
this PR, re-run over that install 2.11.0+cu130, kept, no reinstall skipped (no wheel for 2.11)
this PR, re-run with UNSLOTH_TORCH_UPGRADE=1 2.13.0+cu130, triton-windows 3.7.1 2.8.4, flash_attn_2_cuda imports
this PR, fresh install 2.13.0+cu130, triton-windows 3.7.1 2.8.4, flash_attn_2_cuda imports
this PR, install-kernels causal_conv1d 2.13.0+cu130 causal-conv1d 1.7.0, causal_conv1d_cuda imports
this PR, re-run over the fresh install 2.13.0+cu130, kept unchanged

Merge order

The newest unsloth on PyPI already admits torch 2.13, so this route turns on as soon as it merges. It should go in after #13261 has published the Windows wheels and #13262 (the Studio side that installs them); merged first it would only give new installs torch 2.13 without the kernels yet. No kernel has run on a Windows NVIDIA GPU yet; torchcodec, torchao and bitsandbytes resolution against torch 2.13 on Windows is worth a real install before release.

…isting installs keep their torch

Windows port of #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.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-11T11:26:44.195088Z 19b56c9 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

…install, migrated venv, CWD venv without python.exe; bounded fallback; UV_OFFLINE through Test-UvEnvFlag
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 11, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex security review

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 11, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c28b265bca

ℹ️ 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".

Comment thread install.ps1
$baseInstallExit = Invoke-InstallCommandRetry -Label "install unsloth (migrated)" { & $script:UvExe pip install --python $VenvPython --reinstall-package unsloth --reinstall-package unsloth-zoo "$_unslothReleaseInstallSpec" "unsloth-zoo>=2026.10.3" }
# As install.sh: freeze the trio for this with-deps resolve, then keep the release for the
# flavor repair below, which would otherwise reinstall the default range.
$script:TorchOverridesFile = New-UnslothTorchOverridesFile -PythonExe $VenvPython

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Honor upgrade requests while migrating legacy environments

When UNSLOTH_TORCH_UPGRADE=1 migrates a healthy legacy .venv or CWD-relative environment on the new Windows x64/cu130/Python 3.13 route, this unconditional override freezes the old torch trio during the core install, while the later Get-PreviousTorchPin deliberately returns null for an upgrade. The migrated branch never calls Resolve-Cu130TorchRoute, and setup.ps1 subsequently installs bare, already-satisfied package names unless another condition forces reinstall, so a resident 2.11 installation remains on 2.11 instead of opting into the intended 2.13 default; if a reinstall is forced, it may instead select the newest unconstrained release. Skip this preservation for an explicit upgrade and route the migrated environment through the same 2.13 selection used by other existing layouts.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Leaving this one as is. The legacy migration in install.sh freezes torch the same way (its migrated branch always runs under _UNSLOTH_TORCH_OVERRIDES, whatever UNSLOTH_TORCH_UPGRADE says), and before this PR the Windows migrated branch never went through the 2.13 route either, so nothing that used to upgrade stops upgrading. The migration only fires once, when the old ~/.unsloth/studio/.venv layout exists and the new one does not. The next install with UNSLOTH_TORCH_UPGRADE=1 runs on the migrated venv as a normal existing install, and that path takes the upgrade.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

…de space-free; match --package unsloth case-insensitively in install.sh
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: aad4e37b9a

ℹ️ 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".

chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 11, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 11, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 11, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 11, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 19b56c9a34

ℹ️ 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".

@danielhanchen
danielhanchen merged commit 9c4c4a1 into main Oct 11, 2026
@danielhanchen
danielhanchen deleted the win-cu130-torch213-route branch October 11, 2026 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant