Repository navigation
Windows installer: always build Studio on a uv-managed Python, never one already installed - #13399
Conversation
…one already installed A fresh install on a machine with Python 3.12 took that interpreter, so the cu130 torch 2.13 route (cp313 only) closed and the box got torch 2.11 with no prebuilt flash-attn / causal-conv1d / mamba-ssm. uv only provided Python when nothing 3.11-3.13 was installed, and Windows on ARM never used it. The environment is now always built on a uv-managed CPython, requested by minor and architecture (cpython-3.13-windows-x86_64-none, or aarch64 for the native Windows on ARM CUDA stack and UNSLOTH_ALLOW_ARM64_PYTHON), resolved after uv is installed and before the existing environment is touched. A reinstall keeps the environment's minor so its cached wheels are reused; UNSLOTH_TORCH_UPGRADE=1 moves it to 3.13. When uv cannot provide one, an earlier uv-installed runtime is used, else the installer stops with the mirror / pre-install fix; there is no system fallback. --python X.Y[.Z] now works as the header always said, and an explicit request is exact. Legacy layouts on a non-uv base are rebuilt instead of moved in.
|
@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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b93ae3750d
ℹ️ 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 ($legacyOk -and -not (Test-VenvBaseIsUvManaged -VenvDir $OldVenv)) { | ||
| substep "legacy environment runs on a Python uv did not install -- creating a fresh environment; the old one stays at $OldVenv" "Yellow" | ||
| } elseif ($legacyOk) { |
There was a problem hiding this comment.
Honor Python overrides when migrating legacy environments
When a healthy legacy .venv is based anywhere in uv's store, this condition migrates and reuses it without checking its Python version. Consequently, a legacy Python 3.12 environment survives even when the user requests an exact --python 3.13.9 or sets UNSLOTH_TORCH_UPGRADE=1; the requested 3.13 runtime is downloaded but never used because the later venv-creation branch sees the migrated interpreter. Check the legacy environment's minor/patch against the request, or rebuild it when an explicit/upgrade request requires another version; the same issue exists in the CWD-relative migration branch.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 9409b1a. Both legacy branches now call Test-LegacyVenvReusable, which also requires the pyvenv.cfg version to match the resolved interpreter: same minor, or the exact patch when --python / UNSLOTH_PYTHON named one. Since an upgrade or explicit request changes the resolved minor, a legacy 3.12 environment is rebuilt on the requested Python instead of being migrated. Covered by test_a_legacy_environment_is_reused_only_on_the_resolved_python.
A legacy .venv / ~/unsloth_studio on a uv-managed base was moved in and kept even when --python, UNSLOTH_PYTHON or UNSLOTH_TORCH_UPGRADE asked for another version. It is now reused only when its pyvenv.cfg version matches the resolved interpreter's minor (its exact patch when one was requested).
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep it up! 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". |
…venv.cfg, older cached patch past a skip - A legacy .venv / ~/unsloth_studio reinstall keeps its Python minor, as the current layout does. - A legacy environment is reused only on a uv build of the selected architecture. - pyvenv.cfg is read as UTF-8 (uv writes it without a BOM; Windows PowerShell 5.1 read it as ANSI and rejected a non-ASCII store path). - Past a skipped patch the resolver tries the next one, then an older one, so an offline machine with 3.13.7 cached still installs.
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep it up! 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". |
|
pre-commit.ci run |
The Windows installer now always builds the Studio environment on a uv-managed CPython (default 3.13), never on a Python already installed on the machine. This applies to fresh installs, reinstalls and Windows on ARM; the desktop app runs the same
install.ps1.Why
A fresh native Windows install (RTX PRO 6000 + RTX 5090, driver 591.86) on a machine that already had Python 3.12.6 logged
Python 3.12 already installed, built the environment on it, and so missed the cu130 torch 2.13 route (cp313 only): torch 2.11.0+cu130 and no flash-attn, causal-conv1d or mamba-ssm, since everyprebuilt-wheels-cu13Windows wheel is cp313 for torch 2.13 / 2.14.Find-CompatiblePythonreturned any system 3.13, 3.12 or 3.11 it found, uv only provided Python when none existed (#7825), and Windows on ARM never used uv at all.UNSLOTH_PYTHON=3.13did not help either: the search still fell back to 3.12. The header also advertised a--pythonflag that the argument parser silently ignored.What changes
Resolve-UvManagedPython -Minor -Patch -Archasks uv for an arch-qualified build (cpython-3.13-windows-x86_64-none, oraarch64), with--no-bin --no-registryso nothing on PATH or in the py launcher changes, thenuv python find --system --managed-python. It runs the interpreter (-S -I) and refuses anything that is not the requested minor, architecture and GIL build. A skipped patch (3.13.8 cannot import torch) is stepped past by asking for the next patch, since an arch-qualified key takes no version range.UNSLOTH_ALLOW_ARM64_PYTHONis set, as before. The interpreter is resolved once uv is installed, before the existing environment is moved aside. A failed native ARM64 resolve degrades to x64 as today.UV_PYTHON_DOWNLOADS=never), a runtime uv installed earlier is used; otherwise the installer stops with the fix (UV_PYTHON_INSTALL_MIRROR, oruv python install cpython-3.13-windows-x86_64-noneonce while online) and says the existing environment was not changed.pyvenv.cfg), so torch stays the release it was and comes from the uv cache.UNSLOTH_TORCH_UPGRADE=1(Settings > Repair) moves it to 3.13 and torch 2.13.--python X.Y[.Z]/--python=X.Y[.Z]now work; precedence--python>UNSLOTH_PYTHON> the existing minor > 3.13. An explicit request must be 3.11 to 3.13 and is exact..venv,~/unsloth_studio) are only moved in and reused when their base lies in uv's own store; otherwise a fresh environment is built and the old one is left where it was.Find-CompatiblePython, the winget / python.org Python bootstraps,Install-X64Python,Resolve-WindowsOnArmX64Python,Get-StudioVenvBasePythonand the WoA re-probe/re-select loop, which only existed to steer the system-Python choice. winget is still used for uv.Windows staging (windows-2022 and windows-11-arm, no GPU, cu130 forced, every runner Python except 3.12 masked)
keeping it)UNSLOTH_TORCH_UPGRADE=1UV_PYTHON_DOWNLOADS=neveruv could not provide Python 3.13 (x86_64); no environment createdThe fresh and upgrade rows ran with #13396 merged in, which installs causal-conv1d and mamba-ssm at setup; both legs also ended with mamba-ssm 2.3.2.post1.
Tests
tests/python/test_windows_uv_managed_python.py(43): the arch-qualified request and the exact uv calls; a failed download still finding an earlier runtime; refusing the wrong architecture, a free-threaded build, another minor and unreadable output; stepping past a skipped patch; exact patches;--python/UNSLOTH_PYTHONprecedence and validation; the existing-minor rule and its upgrade / explicit overrides; the Windows on ARM arch choice; the x64 degrade and the stops; the legacy base check; and an ordering check that no system-Python path remains and resolution precedes the environment rollback. Removing the arch check, the existing-minor rule or the ARM64 degrade each fails it.test_windows_arm64_python_choice.pyandtest_windows_python_313_8_screen.py, and the cases intest_windows_on_arm_python_arch.py,test_windows_python_venv_hardening.py,test_woa_torch_index_persistence.pyandtest_installer_conda_path_guard.pythat exercised the removed discovery and bootstraps.test_installer_profile_hardening.pynow expects winget only for uv.TestProgressStepCountMatchesTotal::test_progress_reaches_total_on_both_core_paths[*-False]cases fail identically on main.Not covered
install.shcan still use a system python3.13 (it always requests 3.13, so the torch route is unaffected); a follow-up makes it uv-only as well.