Repository navigation
Windows on ARM: install the native ARM64 CUDA stack on NVIDIA hosts - #10282
Conversation
NVIDIA's Windows-on-ARM parts (GB10 / N1X, the RTX Spark laptops) run CUDA natively, but the installer treated every ARM64 Windows host as "no GPU wheels here" and fell back to x64 Python under emulation. That fallback looks like it works: torch loads and sees the GPU. It then fails on the first kernel, because triton-windows' bundled ptxas is built for the x64 CUDA 12.8 toolkit and cannot target the sm_121 these parts report, so every Unsloth kernel fails to compile. llama.cpp separately picked a CPU-only bundle regardless of the GPU. Detection is evidence based rather than arch based: the installer asks the wheel indexes what actually exists for this interpreter, and only takes the native path when both a win_arm64 CUDA torch and an obtainable pyarrow are found. Anything else keeps the historical x64 path, so a host that cannot be served natively is never left with a half configured venv. The torch index is probed in order: download.pytorch.org first, so this special case ends by itself the day PyTorch publishes these wheels, then NVIDIA's GA channel, then its nightly. Requirement pins with no win_arm64 wheel are split on platform_machine == "ARM64" rather than loosened. Every other platform (linux x86_64 and aarch64, win x64, macOS arm64 and x86_64) evaluates to the pins it had before, checked by evaluating the markers per platform as well as by the test suite. Also: * llama.cpp prebuilt selection learns a windows-arm64-cuda install kind and falls through to upstream's win-cuda-13.4-arm64 asset, so these hosts get a CUDA bundle instead of the CPU one. When neither is hash gated the fallback is still taken, but says so in the log rather than silently. * setup.ps1 keeps an installed cu134 torch on win_arm64 instead of "repairing" it to a cu130 that has no wheel for this platform, and asks the chosen index whether it publishes torchaudio instead of assuming it does not. * install.ps1 checks before the studio handoff that the installed package understands this host, and stops with an explanation if it does not. The two halves ship through different channels (the script is fetched from unsloth.ai, the package comes from PyPI), and an older setup.ps1 handed a working +cu134 torch will reinstall a cu130 that does not exist here, leaving the environment with no torch at all. UNSLOTH_WOA_NATIVE=0 opts back out to the x64 path. Verified on an RTX Spark N1X laptop: clean install into an empty UNSLOTH_STUDIO_HOME ends EXIT=0 with torch 2.14.0+cu134, torchvision 0.29.0, torchaudio 2.11.0, triton-windows 3.8.0.post28 and the llama-b10715-bin-win-cuda-13.4-arm64 bundle; LoRA and QLoRA both train; Studio serves and reports CUDA; Qwen3.8-27B-GGUF UD-Q4_K_XL answers at 8.1 tok/s with the GPU at 94-95 percent through generation.
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. |
|
Follow up on item 2 above (publishing a
There is no That is the case for the upstream fallback in this PR rather than a stopgap: ggml-org does publish |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5556ac20ab
ℹ️ 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".
| substep "windows on arm: downloaded pyarrow wheel $wheelName" | ||
| } catch { | ||
| substep "could not download $wheelName ($($_.Exception.Message))." "Yellow" | ||
| $script:WoaNativeCudaTorch = $false |
There was a problem hiding this comment.
Perform the advertised x64 fallback after staging fails
When the initial wheelhouse probe succeeds but the later pyarrow download fails transiently, this only clears the native flag even though the ARM64 interpreter and venv have already been selected and created. Execution then continues with that ARM64 venv through the ordinary driver-derived CUDA index path (typically cu130), which has no win_arm64 torch wheel, so the installation fails instead of falling back to x64 as the message promises. The staging failure needs to restart interpreter/venv selection or occur before the ARM64 venv is created.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not taking this one. The trigger is a transient download failure, not well-formed input, and the message here says "continuing without the native stack", not that it falls back to x64 (that wording is at a different site). The run fails loudly either way, and the native path was already doomed once pyarrow could not be staged, since datasets cannot resolve without it. Restarting interpreter and venv selection mid-run is a redesign rather than a fix. The sharp edge you name is real though: clearing the flag after the ARM64 venv exists points torch at an index with no wheels for it, and an explicit hard stop there is a reasonable follow-up.
| $env:UV_OVERRIDE = $WoaOverrides | ||
| $env:UV_FIND_LINKS = $WoaWheelDir | ||
| $env:PIP_FIND_LINKS = $WoaWheelDir |
There was a problem hiding this comment.
Restore package-manager environment after installation
For the documented irm ... | iex invocation, assigning UV_OVERRIDE here modifies the caller's PowerShell process, but the outer finally restores only TMP/TEMP. Consequently every later uv command in the same shell, including commands for unrelated projects, continues using this generated ARM64 override file and can silently replace dependency constraints or suppress packages; the find-links variables leak similarly. Save and restore the prior package-manager variables after the setup child has inherited them.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not taking this one. These three are exported deliberately so the unsloth studio setup child inherits them through every uv and pip pass, which is why they are set once here instead of threaded through each call site, and restoring them after the child would have to sit at the end of a long multi-exit region. Re-entry is already handled: the block above removes any inherited value whose path points into this StudioHome's own woa directory, matched by path so a user's own UV_FIND_LINKS survives. TMP/TEMP are restored because that directory is deleted, which is a different hazard. A leaked session variable on a host where those packages genuinely have no win_arm64 wheel is hygiene, not a wrong install.
| # asks for the arm64 bundles and the windows-arm64-cuda kind. | ||
| if arch is None: | ||
| arch = windows_cuda_arch_for_host(host) | ||
| install_kind = windows_cuda_install_kind_for_arch(arch) |
There was a problem hiding this comment.
Honor the architecture when parsing published CUDA assets
When arch is arm64, this now selects windows-arm64-cuda artifacts, but the legacy-name parsing below still matches and synthesizes only *-x64.zip names at lines 3217, 3227, and 3272. A published upstream-style llama-...-arm64.zip is therefore treated as an app bundle: its encoded CUDA minor is not checked against the driver and its matching ARM64 cudart archive is never attached, potentially installing an incompatible or incomplete llama.cpp bundle. Parameterize those legacy expressions and synthetic names with arch as the upstream path already does.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not taking this one. The remaining -x64 spellings are in the legacy-name branch, which no real fork manifest enters: every Windows CUDA artifact the fork publishes is app-named (app--windows-x64-cuda13-portable.zip), and the only legacy llama-...-bin- names in the manifest are macOS, which never reach this function. legacy_minors is empty on both arches, so the x64 spelling is equally unexercised and this is a pre-existing latent inconsistency rather than something this PR introduced. The real future artifact goes through the app-bundle path, which is arch-correct including the cudart pairing. Worth parameterizing for tidiness one day.
Review of the branch turned up one real regression and several sharp edges. All of them are on paths this PR added; none change what a host did before it. The regression. `_is_windows_arm64()` answers for the MACHINE, and says yes even under an emulated x64 Python -- its docstring says so, since that is what it is for. But the requirement markers this PR adds key on `platform_machine == "ARM64"`, which is the INTERPRETER's arch, and every Windows-on-ARM install predating native support is running an emulated x64 interpreter, because install.ps1 deliberately fetched one there. So on exactly those existing installs the two mechanisms disagreed: the marker rows correctly selected the x64 pins while the new skip list dropped ten packages (xformers, tiktoken, tensorboard, librosa, openai-whisper, hf_transfer, sqlite-vec, mecab and the rest) that have working win_amd64 wheels and install fine today. Anyone taking the new UNSLOTH_WOA_NATIVE=0 escape hatch would have hit it too. `_is_win_arm64_interpreter()` answers the other question, from `sysconfig.get_platform()` -- the same authority pip and uv tag wheels with -- and the two call sites this PR added now use it. The pre-existing uses of the machine predicate are left alone, so nothing outside this PR shifts. The rest: * setup.ps1 answers `Test-WinArm64Venv` from the machine arch before launching any interpreter. The callers sit in the stale-venv path, which on x64 previously executed nothing at all; probing a venv's python there to learn something already known gave a corrupt or lock-blocked interpreter a chance to hang the install. * `$expectedKinds` gains windows-arm64-cuda only on the arch that can carry it. Accepting it on x64 would keep an install that machine cannot run, where today it is removed as mismatched. * The wheelhouse reuses a staged wheel only if it opens as a zip. An interrupted run leaves a truncated file, and skipping on mere existence handed the resolver that same corpse on every retry. Both downloads also take a timeout now. * UV_OVERRIDE / UV_FIND_LINKS / PIP_FIND_LINKS are cleared when they point into this StudioHome's own woa directory, so a second `irm | iex` in one shell cannot inherit a previous run's wheelhouse. Matched by path rather than cleared outright: an inherited UV_FIND_LINKS that a user set for their own wheelhouse is left alone, since clearing it would break air-gapped installs on every Windows host. * hf_transfer in no-torch-runtime.txt and cryptography in studio.txt (and its mirror in pyproject) get the same marker split as the other rows. That file installs --no-deps and the extra is installable directly, so neither was covered by the constraints file. * `windows_cuda_arch_for_host` tests is_windows as well as is_arm64. Every caller is already inside a Windows branch, but `is_arm64` is also true on macOS arm64 and Linux aarch64, so the answer should not depend on the caller remembering that. * The published legacy-minor scan uses the arch being resolved instead of a hardcoded x64, which was harmless only while no arm64 CUDA artifact existed. * No `windows_cuda_selection` log line on x64, where the arch is the unspoken default and the line would be new output in every existing install log. Verified: requirement markers resolve identically to origin/main across 65 environments (linux x86_64/aarch64/arm64/armv7l/ppc64le/s390x, win32 AMD64/x86/ARM64EC, darwin arm64/x86_64, freebsd, python 3.10 to 3.14), differing only on win32/ARM64; the studio-extra mirroring guard passes; both PowerShell files parse; and a simulated interpreter matrix confirms the win_arm64 skip list applies on a native ARM64 interpreter and on nothing else, including the emulated x64 case that regressed.
|
Pushed a follow-up commit after a hard look at what this changes for hosts that are not the new one. Recording what was found, including the one real regression, so the review does not have to rediscover it. The regression
But the requirement markers this PR adds key on So on exactly those existing installs the two mechanisms disagreed. The marker rows correctly selected the x64 pins, while the new skip list dropped ten packages that have working
Simulated across eight interpreters:
Also fixed
What was checked and found clean
Still true, and worth repeatingThis PR is inert until the wheelhouse exists at |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8406faa8d6
ℹ️ 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".
| } | ||
| $torchIndex = $null | ||
| foreach ($candidate in $candidates) { | ||
| if (Test-WoaCudaWheel -IndexUrl $candidate -PythonMinor $PythonMinor -Project "torch") { |
There was a problem hiding this comment.
Probe torchvision before selecting the native stack
When an explicitly configured WoA index or mirror publishes torch but lacks a matching win_arm64 torchvision, this probe still selects native ARM64 and creates the native venv; the mandatory install at line 6337 then requests torchvision>=0.19 and fails rather than retaining the working x64 path. Since custom mirrors are supported and torchvision is not optional in the selected stack, require a compatible torchvision wheel alongside torch during this preflight.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not taking this one. Checked both built-in candidates: pypi.nvidia.com/nvtorch_oot publishes win_arm64 torchvision for cp311 through cp314t, matching torch's tag set exactly, and the nightly channel has 154 of them. download.pytorch.org has no win_arm64 wheels at all, so it can never win the torch probe in the first place. The failure needs a custom index that serves win_arm64 CUDA torch but no torchvision, which does not exist publicly, and it would be a loud abort on a user-named index rather than a wrong install.
| "--index-strategy", "unsafe-best-match", | ||
| "--extra-index-url", "https://pypi.org/simple" |
There was a problem hiding this comment.
Keep explicit mirrors from falling through to public PyPI
When UNSLOTH_TORCH_INDEX_URL points to an authenticated corporate or air-gapped mirror, the native branch still adds public PyPI and enables unsafe-best-match, so the explicit source is no longer exclusive and shared dependencies can be selected from or queried against PyPI. uv pip install --help defines --extra-index-url as an index used “in addition to --index-url” and describes --index-strategy as resolution across multiple indexes; therefore this can cause unintended network egress or public-package substitution. Add this fallback only for the built-in NVIDIA indexes, or make the dependency index configurable.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not taking this one. The uv semantics you cite are right, and I confirmed them. But reaching this line requires an index that already serves win_arm64 CUDA torch for this interpreter, which today is only NVIDIA's out-of-tree channel, and that channel publishes only torch, torchvision and torchaudio (its /filelock/ is a 404). So the PyPI fallback is load-bearing for the one configuration that exists, and restricting it to the built-in NVIDIA indexes as suggested would leave a torch-only pinned mirror with no source for filelock, sympy or networkx and break it. Worth revisiting if a private win_arm64 CUDA mirror ever appears.
| pandas==2.3.3 | ||
| # pandas publishes win_arm64 wheels from 3.0 only; 2.3.x would source-build there. | ||
| pandas==2.3.3; sys_platform != "win32" or platform_machine != "ARM64" | ||
| pandas>=3.0,<4; sys_platform == "win32" and platform_machine == "ARM64" |
There was a problem hiding this comment.
Reconcile the local plugin's pandas upper bound
On native Windows ARM64 this constraint now installs pandas 3.x, but studio/backend/plugins/data-designer-unstructured-seed/pyproject.toml still declares pandas>=2,<3. The plugin is deliberately installed with --no-deps, and patch_metadata.py does not patch this distribution, so resolution does not catch the conflict and the completed environment fails pip check while running the plugin against a version its metadata rejects. Widen the plugin dependency after validating pandas 3, or avoid selecting pandas 3 for an environment that includes it.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not taking this one. The pip check this rests on is run with both streams to DEVNULL and its return code ignored, under a comment saying third-party conflicts are expected, and it is the only pip check in the studio flow. Nothing validates Requires-Dist at runtime either. Widening the plugin would not produce a clean check anyway: data-designer-config 0.5.4, also installed --no-deps, declares pandas<3,>=2.3.3 and patch_metadata does not rewrite that line, so the same conflict is reported with or without the local plugin. The plugin's pandas use is read_parquet, DataFrame(list[dict]), to_parquet and to_dict, none of which 3.0 changes. The alternative you offer, not selecting pandas 3 there, would reintroduce the source build this constraint exists to remove, since PyPI has no win_arm64 wheel for 2.3.3.
| if ($script:WoaNativeCudaTorch -and $DetectedPython -and $DetectedPython.Arch -eq "x86_64") { | ||
| substep "windows on arm: found an x64 Python $($DetectedPython.Version); installing the native ARM64 build..." "Yellow" | ||
| $Arm64Python = Install-PythonFromPythonOrg -Arch "arm64" | ||
| if ($Arm64Python -and $Arm64Python.Arch -ne "x86_64") { |
There was a problem hiding this comment.
Require an actual ARM64 interpreter for the native path
On a Windows-on-ARM host that has only a supported 32-bit Python, Find-CompatiblePython records its architecture as unknown and may return it when no ARM64 candidate exists, but this guard replaces only x86_64. The native flag therefore remains enabled, a win32 venv is created, and every staged win_arm64 wheel is unusable; similarly, the success check at line 3844 accepts an installer result whose architecture is merely not x64. Gate continuation on Arch -eq "arm64" and otherwise install a verified ARM64 interpreter or take the x64 fallback.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not taking this one. Reaching Arch = unknown needs a Windows-on-ARM NVIDIA workstation whose only supported Python is a 32-bit x86 build, which is not a configuration this installer receives. The proposed gating is also not safe: CPython gh-145410 has sysconfig.get_platform() returning win32 on a genuine 64-bit interpreter when sys.version is truncated, so requiring Arch -eq arm64 would demote a real ARM64 host to the x64 fallback. The consequence you describe is now closed anyway by the venv platform gate added for the migrated-venv item: a win32 venv drops the native stack regardless of how the interpreter classified itself.
Two parity tests read install.ps1 and setup.ps1 as text, and both changes in this PR moved the strings they look for. The behaviour they guard is intact in each case, so the fix is on this side rather than in the assertions. test_install_ps1_bounds_unknown_leaf_pinned_torch pins the literal "@_torchSpecs --default-index $TorchIndexUrl", which is how it checks that the bounded companion specs actually reach uv. The Windows on ARM branch inserted @_torchExtraArgs between the two halves. Those arguments are all flags and their values, never positional packages, so uv accepts them anywhere on the line; moving them after the index restores the literal and changes nothing about the resolve. test_setup_ps1_scrub_covers_pip_fallback slices a fixed 2500 character window from "function Fast-Install" and requires the pip fallback to appear before the finally that restores the scrub. The flag stripping loop added here is sixteen lines and pushed the finally out of that window: the fallback is still inside the try, but the test could no longer see it. Lifting the loop into Remove-UvOnlyResolverFlags puts Fast-Install back near its original size, with the finally at offset 1695 against a 1629 baseline on main. The helper was exercised against the inlined version it replaces on all six shapes: no flags, --index-strategy in both spellings, --prerelease in both spellings, and an empty list. Output is identical, including the empty-in empty-out case that every caller in the tree takes today.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e9d9fe3e5a
ℹ️ 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".
| resolve_windows_cuda_choices( | ||
| host, | ||
| llama_tag, | ||
| github_release_assets(UPSTREAM_REPO, llama_tag), |
There was a problem hiding this comment.
Fall back to the published ARM64 CPU bundle on API errors
On the default fork path for an ARM64 NVIDIA host without an approved fork CUDA artifact, this extra upstream GitHub API lookup must succeed before the already-resolved windows-arm64 CPU choice is considered. If that request is rate-limited, offline, or transiently fails while the fork manifest and its approved CPU asset are available, the exception escapes to the outer source-build recovery instead of using the CPU prebuilt, which can turn an otherwise viable Windows ARM64 install into a toolchain-dependent build failure. Catch this optional upstream lookup failure locally and continue to the published CPU choice.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not taking this one. The x64 NVIDIA branch calls github_release_assets exactly as unguardedly a few dozen lines earlier, and has no CPU fallback to lose at all, so the new ARM path is already more forgiving than the shipped one. The non-transient case does not exist either: the manifest's upstream_tag is a plain upstream tag and it resolves. That leaves offline, which breaks the asset download too, and a bare rate-limit window that needs the earlier fork-release call to have succeeded first. Reasonable resilience polish for a follow-up rather than a defect here.
test_installer_never_installs_an_unpinned_xformers flags every quoted xformers literal in install.ps1 that is not the exact pin. The Windows on ARM block added one, but it is a removal list: those names are written into the requirement overrides so the package vanishes from the resolve, since win_arm64 has no xFormers wheel and no buildable sdist. A version pin there would be meaningless, and the name has to match the requirement line exactly for the override to bind. The test already carves out wheel filenames on the same grounds, that a filename is not a spec. This adds the drop list beside it rather than loosening the assertion. Checked that it stays narrow: a bare "xformers" appended at end of file is still caught, and so is a loose "xformers>=0" placed on the line immediately above the drop list, while the real file is clean.
Resolve three conflicts against the release-preservation work that landed on main: - install.ps1 torch install: take main's hoisted $_pinTorchSpec trio and its kept-release retry, and skip release preservation on the WoA native route, whose specs are deliberately unbounded and whose install carries $_torchExtraArgs the kept-release command does not. - studio/setup.ps1 CUDA install: same, inside main's new retry loop, with the ARM64 trio and index args applied per iteration. - studio/setup.ps1 $expectedKinds and studio/install_python_stack.py skip lists: keep the new ARM64 entries under main's shortened comments.
Six defects found in review, all on the new WoA path and none reachable on any other host. Probe the interpreter that was actually selected. Initialize-WoaNativeCudaTorch answered for $PythonVersion, but Find-CompatiblePython falls back to another supported minor whenever the requested one is not installed. Every native decision is keyed to an interpreter tag, so a 3.13 answer carried into a 3.12 venv staged a cp313 pyarrow wheel and then pinned pyarrow== to it, forcing the Arrow sdist this path exists to avoid. Re-probe once the interpreter is settled, key the staged tags on the venv's own minor, and clear every script-scope answer on entry so a second probe cannot inherit the first one's. Redact the selected torch index. The status line printed $script:WoaTorchIndexUrl verbatim, and it can be UNSLOTH_TORCH_INDEX_URL with userinfo or a token query. It was the only index line in the file that did not redact. Remove-IndexUrlCredentials moves up to the other helpers, since PowerShell resolves a function only once its definition has executed. Hand uv a space-free override path. uv reads UV_OVERRIDE as a space-separated list of files, which this script splits on \s+ itself, and the default StudioHome sits under %USERPROFILE%. An overrides file under a path with a space was read as two paths, neither of which exists, and every later uv call failed with "File not found". Same defect and same remedy as backend/utils/uv_path_safety.py (issue #6503), which the Python half already applies. pip splits its repeatable options the same way; UV_FIND_LINKS is comma-separated and is untouched. Do not enable the native stack for an x64 venv. The migration branches keep a healthy legacy environment as it is, and on this host those are x64 by design. Get-TorchIndexUrl returns the win_arm64 index on the flag alone while the spec lift is gated on the venv's platform tag, so a migrated venv was asked for the bounded x64 specs from an ARM64-only index and aborted with no fallback. Ask the venv the same question the spec branch asks. Accept every spelling of a local wheelhouse. UNSLOTH_WOA_WHEELHOUSE is documented as taking a directory or a base URL, but only drive-plus-backslash and UNC counted as local, so C:/wheels went to Invoke-RestMethod and the native path was dropped on a host whose wheels were present. Ask the filesystem instead. Count a wheelhouse wheel only for the interpreter it was built for. Staging copies every win_arm64 wheel, cp311 through cp314, but both availability checks keyed on the distribution name alone. A cp311 tiktoken in a cp313 venv cleared its skip and its requirement override, and the resolve fell to an unbuildable sdist. Filter on PEP 425 tags on both sides. WINDOWS_ARM64_SKIP_UNBLOCKED_BY takes the whole blocker set rather than one name, since librosa needs numba as well as llvmlite and whisper needs tiktoken too; its openai-whisper key was also never matched, being looked up canonically. Let an explicit CPU pin through the CUDA preservation guard. It ran ahead of every pin check on both sides, so UNSLOTH_TORCH_INDEX_URL=.../cpu was dropped even though download.pytorch.org publishes win_arm64 /cpu torch and torchvision. In setup.ps1 it also left PinChangedForceReinstall false, which skips the dependency pass entirely, so the run kept the CUDA build and reported success.
|
@codex review |
The CUDA preservation shortcut reads the interpreter, not the machine, and nothing in the suite held it to that. Swapping _is_win_arm64_interpreter for _is_windows_arm64 at the guard leaves 223 of 224 tests here passing, which is the whole margin between a correct guard and one that strands every Windows on ARM install predating native support. Those run an emulated x64 python against ordinary win_amd64 wheels from download.pytorch.org, so the repair has somewhere to go and must still reach them. The fixture drove both predicates from one flag, which is right for every case already here, since a native ARM64 venv is the only place both are true. They separate on an ARM64 machine running an x64 interpreter, so win_arm64_interpreter overrides just that half and defaults to the existing flag. Verified by mutation: with the guard reading the machine instead, the new test is the only one of the 224 that fails.
$expectedKinds asked Get-HostMachineArch, which answers for the machine. A Windows-on-ARM host on the x64 fallback runs the prebuilt helper under an emulated x64 python and installs windows-cuda, so the machine's answer would call that bundle mismatched and discard a working runtime. Test-WinArm64Venv is the same predicate the torch path uses, and it short-circuits free on x64. The block stays inert either way: write_prebuilt_metadata persists no install_kind, so $existingKind is always null.
# Conflicts: # tests/python/test_windows_installer_native_type_fallback.py
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f9ad4a5c37
ℹ️ 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".
| windows_cuda_attempts( | ||
| host, | ||
| release_tag, | ||
| assets, | ||
| torch_preference.runtime_line, | ||
| torch_preference.selection_log, | ||
| arch = "arm64", |
There was a problem hiding this comment.
Apply release digests in the direct ARM64 plan
When published_repo is set to ggml-org/llama.cpp (or another non-default repository), resolve_simple_install_release_plans routes through direct_upstream_release_plan, and this new ARM64 CUDA attempt is returned with synthetic empty checksums and expected_sha256=None. The installer therefore downloads and executes the archive during its smoke test without the fail-closed GitHub digest check added in resolve_release_asset_choice; populate these attempts from release_asset_digests(release) and drop any asset lacking a digest before returning the plan.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changed. direct_upstream_release_plan is the opt-in path for a non-default published repo, and by design every attempt it returns carries synthetic checksums: the x64 CUDA, HIP, Vulkan and CPU bundles beside this one. The ARM64 CUDA attempt follows that same contract rather than lowering it; the fail-closed GitHub digest check lives on the default path, where the fork borrows one upstream bundle it does not publish. Verifying the direct plan is a separate change for every platform, not part of the ARM64 support.
… earlier wheelhouse left for PR #10282 Explicit indexes: uv serves an index marked explicit = true only to packages pinned to it via [tool.uv.sources], so it is neither the default nor an extra for the trio's shared dependencies. The block form [[index]] reader in install.ps1 and setup.ps1 read url and default only and flushed such an entry as a general extra, which Get-WoaDependencyIndexArgs then passed as --extra-index-url to the native torch resolve; the inline table reader refused the key outright, which turned the documented PyTorch pattern into an unreadable policy. Both readers and the Python reader now skip an explicit entry; explicit together with default = true also removes PyPI as the default, which is not modelled, so that combination stays doubt. Stale wheels: the managed woa\wheels directory persists across runs, so after UNSLOTH_WOA_WHEELHOUSE changed a wheel the earlier wheelhouse staged stayed in it, the hosted scan read it as current and UV_FIND_LINKS installed it from a source no longer configured. Staging now reconciles the directory against the wheelhouse listing it just read, keeping the listed wheels and the selected pyarrow wheel; an unreadable listing (offline) keeps the staged copies, and the directory used as its own wheelhouse lists everything it holds. Tests: block-form and inline rows on both scripts plus the Python reader, the dependency args never naming an explicit index, and the reconciliation across a local wheelhouse, a URL wheelhouse, an offline listing and the self-sourced directory. Ten mutants on the change are killed.
|
Codex Review: Didn't find any major issues. Keep them coming! 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". |
… changes added for PR #10282
…ec, order xformers after the final torch repair, and key the pip refusal to the generated overrides for PR #10282
…tent WoA overrides for PR #10282
…basing override lines for PR #10282
|
Codex Review: Didn't find any major issues. Nice work! 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". |
…rint its pytest output for PR #10282
|
Codex Review: Didn't find any major issues. Another round soon, please! 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: # install.ps1 # pyproject.toml # studio/backend/requirements/single-env/constraints.txt # studio/install_llama_prebuilt.py # studio/install_manifest.py # studio/install_python_stack.py # tests/studio/install/test_windows_torch_flavor_invariant.py
|
I scanned this branch's shipped scripts on VirusTotal against current It does not. No change, in either direction.
Zero engine timeouts on both
I also checked the three added shapes that looked AV-adjacent and all three are fine. Two merge-hygiene notes, unrelated to antivirus:
Both point at the same thing: worth rebasing onto current |
…code signs and publishes the pyarrow and sqlite-vec win_arm64 wheels for PR #10282
What this is
irm https://unsloth.ai/install.ps1 | iexdoes not produce a working install on NVIDIA's Windows-on-ARM laptops (GB10 / N1X, the RTX Spark parts). This makes it work, without changing what any other host does.Why it fails today
We treat every ARM64 Windows host as "no GPU wheels exist here" and fall back to x64 Python under emulation. That fallback is convincing for a while: x64 torch installs, loads, and reports
torch.cuda.is_available() == True. It then fails on the first kernel, becausetriton-windowsbundles aptxasbuilt for the x64 CUDA 12.8 toolkit and thatptxascannot target thesm_121these parts report:So every Unsloth kernel fails to compile. Separately, llama.cpp picked the CPU-only
windows-arm64-cpubundle regardless of the GPU, then tried to hydrate a source tarball that fails on MAX_PATH and falls back to a source build asking for CMake and Visual Studio Build Tools through UAC.None of this is necessary any more. These machines run CUDA natively, and every piece now exists: NVIDIA publishes
win_arm64CUDA torch (GA atpypi.nvidia.com/nvtorch_oot: torch 2.14.0+cu134, torchvision 0.29.0, torchaudio 2.11.0),triton-windowsshipswin_arm64from 3.8.0.post28,bitsandbytes0.50.2 ships a cuda134 DLL, and ggml-org publishesllama-*-bin-win-cuda-13.4-arm64.Approach
Detection is evidence based, not architecture based. The installer asks the wheel indexes what actually exists for this interpreter, and takes the native path only when it finds both a
win_arm64CUDA torch and an obtainable pyarrow. Anything else keeps the historical x64 path. A host that cannot be fully served natively is never left with a half configured venv that dies at thedatasetsstep.The torch index is probed in order:
download.pytorch.orgfirst, then NVIDIA's GA channel, then its nightly. That ordering matters for maintenance: the day PyTorch publishes these wheels themselves, the official index wins and this special case retires itself with no code change.Requirement pins are split, not loosened. Packages with no
win_arm64wheel get aplatform_machine == "ARM64"marker rather than a widened range."ARM64"is Windows-on-ARM specifically: macOS is"arm64"and Linux is"aarch64", so the isolation is exact. I checked this two ways, by evaluating every marker per platform (linux x86_64, linux aarch64, win x64, macOS arm64, macOS x86_64 all resolve to the pins they had before) and by the test suite.Also in here
windows-arm64-cudainstall kind and falls through to upstream'swin-cuda-13.4-arm64asset, so these hosts get a CUDA bundle. When neither our asset nor upstream's is hash gated the fallback is still taken, but it says so in the log rather than silently.setup.ps1keeps an installed cu134 torch onwin_arm64instead of "repairing" it into a cu130 that has no wheel for this platform, and asks the chosen index whether it publishes torchaudio rather than assuming it does not.install.ps1checks, before handing off to studio setup, that the installed package understands this host, and stops with an explanation if it does not. See the note on merge order below.UNSLOTH_WOA_NATIVE=0opts back out to the x64 path.Verification
Clean install into an empty
UNSLOTH_STUDIO_HOMEon an RTX Spark N1X, invoked the way the one-liner invokes it (piped intoInvoke-Expression, no arguments), endsEXIT=0:llama-b10715-bin-win-cuda-13.4-arm64.zip, backend cuda, validated not rebuilt/api/healthhealthy, "Hardware detected: CUDA"EXIT=0, native, CUDA available, with tiktoken, brotli, hf_transfer, grpc, xformers and sqlite_vec absent. Studio boots healthy with one degraded line,RAG unavailable: sqlite-vec could not be importedNo regressions:
tests/studio/installgives an identical failure set before and after, measured in the same venv, with nothing new and nothing masked.Split out of this PR
Three things that were in here are not about Windows on ARM, and are now separate PRs against main:
~/.unsloth/studiobeing deleted with no ownership check at all.[N/A]compute-apps listing means nvidia-smi cannot attribute memory, not that the card is idle.run_pwshnever set the writing end of the PowerShell pipe, so 5.1's OEM code page and pwsh 7's UTF-8 were both decoded with the ANSI one. This is whyparity (windows-latest)is red on main today, not just here.All three are reverted here, or were never in here, so this branch matches main byte for byte on those files. This PR went from 38 files and +11591 to 29 and +9897.
#10484 is worth calling out separately: it is not a Windows-on-ARM fix at all. It came out of running this branch's suite on a real Windows ARM64 box, where the pre-existing encoding mismatch stopped being a wrong answer and started being a silent
stdout is None. It fixes a gate that is red on main.Where the remaining 9897 lines are
Tests: 6794 lines producing 1525 test cases, 4.5 lines per case.
test_woa_torch_index_persistence.pytest_windows_arm64_wheelhouse_tags.pytest_windows_arm64_requirement_markers.pytest_woa_wheelhouse_guard_behaviour.pytest_llama_kind_gate_matches_selector.pytest_woa_wheelhouse_prefers_pypi.py48 percent of those lines are string literals, because a test that pins PowerShell behaviour has to carry the PowerShell it runs. 39 percent is Python, 11 percent blank, 2 percent comments.
Product: 2937 lines.
install.ps1install_python_stack.pysetup.ps1install_llama_prebuilt.pywindows-arm64-cudainstall kind and the upstream fallbackwindows-arm64-ci.ymlwindows-11-armCI legWhy the installer needs 32 new functions
They are wheel-tag parsing, abi3 compatibility, PEP 440 ordering, environment-marker evaluation, TOML parsing and requirement rebasing. Python's
packagingdoes all of it in a library.It cannot be used, because of where the decision has to happen:
The probe decides whether to install an ARM64 or an x64 Python, so it runs before any interpreter exists. Every packaging primitive it needs has to be written in PowerShell.
On the Python side the same primitives appear again in
install_python_stack.py, and there they are not duplication:_version_satisfiesand_marker_is_activetrypackagingfirst, thenpip._vendor.packaging, and only fall back to their own numeric comparison for a venv that has neither, which is the state that half of a bootstrap runs in.Why the tests are twice the code
Every one of those 32 functions is a parser with edge cases, and none of them can be imported: they are nested inside
Install-UnslothStudioin a script that is fetched and piped toInvoke-Expression. The suite lifts each function out of the source by name and runs it in a realpwsh, so a case costs a script string as well as its assertions. The 804 marker cases are the cheapest per line and the most valuable: they evaluate every requirement marker this PR touches against 31 environments, which is what shows that no row moves on any host that is not Windows on ARM.Two things on our side before this helps anyone
win_arm64wheel on PyPI and would otherwise need a compiler on the user's machine. The installer readsUNSLOTH_WOA_WHEELHOUSE, now defaulting tohttps://huggingface.co/danielhanchen/unsloth-blackwell-docker/resolve/main/windows-arm64-wheels(commit 46e706e). It holds the two wheels that matter: pyarrow 25.0.1 for cp311 through cp314, which gates the native path becausedatasetsneeds it, and sqlite-vec 0.1.9, which is not a gate but is what RAG imports. Both were built on GitHub's hostedwindows-11-armrunner from their release tags: pyarrow with GH-47195: [Python][CI] Add support for building PyArrow library on Windows ARM64 apache/arrow#48539's build script overlaid on theapache-arrow-25.0.1tag (about 45 minutes per interpreter, trimmed to whatdatasetsuses), sqlite-vec by compiling its DLL with MSVC for ARM64 and repacking the PyPI wheel under thewin_arm64tag (PyPI's ispy3-none-win_amd64, one DLL plus pure Python, notpy3-none-anyas I wrote earlier). Every wheel was smoke tested on that runner, every native image inside is ARM64 by PE header, and install.ps1 ran its native path against the published URL end to end on the same runner: pyarrow 25.0.1, torch 2.14.0+cu134 and sqlite_vec 0.1.9 all import in the win-arm64 venv. Moving the five files tounsloth/windows-arm64-wheelsis an upload plus one URL change. tiktoken, regex, brotli, hf_transfer and grpcio are not needed: nothing on the install path imports them, and an install without them is healthy.Upstream pyarrow is aware of this: apache/arrow#48539 builds win_arm64 and is finished, but it is on hold behind apache/arrow#50398, the abi3 transition, with no date. PyPI still publishes zero win_arm64 pyarrow files as of 2026-09-09. That plan sets an abi3 floor of 3.11, so the first upstream wheel will be named
cp311-abi3, which this PR already accepts, and our copy simply stops being used when it lands.2. Publish a
windows-arm64-cudallama.cpp artifact, or list the upstream arm64 asset hashes, so the unverified upstream fallback can be removed.One dependency outside this PR
Flex attention's backward pass does not compile on these parts, with or without this PR. The
shipped shared-memory gate in
unsloth_zoounder-estimates usage on every GPU whose onlyoffered config has
num_stages = 1, which is what sm_121 gets athead_dim >= 128, so thegate never fires and Triton is handed a config needing 114688 bytes against a 101376 byte
limit. Fixed in unslothai/unsloth-zoo#1165.
Reproduced cold on a clean install from this branch: fails with stock
unsloth_zoo, passeswith that fix, same environment. It is independent of the installer, so it is a separate PR,
but flex attention is broken on this hardware until it lands. Ordinary QLoRA is unaffected and
trains on a stock install.
Merge order matters
The script is fetched live from unsloth.ai while the package comes from PyPI, so the two halves ship separately. Shipping this script before the release is worse than shipping neither: the patched script installs a working +cu134 torch, then an older
setup.ps1reads that family as "not this host", reinstalls a cu130 that has nowin_arm64wheel at all, and leaves the environment with no torch. The capability check above turns that into a clear stop rather than a broken venv, but the clean fix is to release the wheel first or at the same time.Note on #5945
That PR routes Windows-on-ARM plus NVIDIA through WSL2. Its premise, that there is no native
win_arm64CUDA stack, was true when written and is not any more. Its dry-run probe does keep the native install "if awin_arm64CUDA wheel ever ships", but it resolves against the download.pytorch.org cu130 index, which has nowin_arm64wheels, so it would still choose WSL here.Worth knowing before we default anyone to WSL: I ran
curl -fsSL https://unsloth.ai/install.sh | shin WSL on this same machine and it works today, unpatched, endingEXIT=0with torch 2.11.0+cu130, triton 3.6.0, our ownlinux-arm64-cuda13llama.cpp asset, and LoRA training at 1.31 GB peak. But it caps you at the WSL VM's memory (29.31 GiB there against a 45.39 GiB native pool), needs a distro plus admin plus a reboot on a clean machine, and itswhisper.cppprebuilt install fails. WSL is a reasonable fallback, not a better default.The red aarch64 check is not from this branch
linux ubuntu2404-arm-rootis failing here, and it fails the same way onmainwith no PR involved: run 34255272305 at5177a5b1d, sole failing job, same error.NVIDIA retired
nvidia-npp-cu13on PyPI; its only release is an sdist stub whose build backend raises. It bites aarch64 only because torchcodec has no aarch64 wheel on the pytorch index, so the installer falls back to the generic CUDA 13 wheel and the NPP step then asks for the retired name. x86_64 never reaches that step.#10587 fixes it, and the fix is verified to turn that exact job green. Nothing in this branch touches it, so it is expected to stay red here until #10587 lands.
uv's inline index spelling was unreadable, and the doubt resolved to public PyPI
Found while reviewing this branch, fixed here.
Read-WoaUvTomlIndexKeysreturned$nullthe moment it saw anindexkey, soindex = [{ url = "https://mirror/simple", default = true }], which is valid and documented uv configuration, read as "cannot know".Get-WoaUvConfigIndexPolicyrecorded that asUnreadable, and the two consumers of that one flag then disagreed:Test-WoaResolveReachesPyPIhonoured it, with the comment "Doubt resolves to 'not PyPI': that answer keeps a wheel, the other loses the package".Get-WoaDependencyIndexArgsnever read it and fell through to itshttps://pypi.org/simpledefault.The second is the one that builds the install command, so a host with a corporate mirror written in that spelling had public PyPI appended as a dependency index under
--index-strategy unsafe-best-match, in place of the mirror its configuration named.Fixed at the root: the inline form is now parsed, conservatively. A single-line, brace-balanced array of flat inline tables is read; a multi-line array, a nested value, a bare entry beside a table, a missing
url, a non-booleandefaultor anexplicitindex all still return$nulland stayUnreadable, because guessing is the only outcome worse than not parsing.The consumers then agree, per call site, because the sites genuinely differ. With no environment default and a policy that is still unreadable, no dependency index is named rather than PyPI substituted.
install.ps1's trio step calls uv directly, so uv reads the file itself and that is strictly better than before: no substitution and no failure.studio/setup.ps1's runs underFast-Installwith--index-url, which setsUV_NO_CONFIGand scrubsUV_*, so uv cannot read it there and an empty answer would leave the trio index as the only source; that site stops with a message naming the file, the spelling, and both ways out.Reading the inline form changes
Test-WoaResolveReachesPyPIand therefore wheel pruning, so that was traced first: a mirror URL still answers false and still disables pruning, unmoved, and a genuinepypi.orgURL now answers true and enables it, which is correct and was previously being suppressed by a parse failure rather than by a decision.