Skip to content

Add Intel Arc GPU detection and XPU PyTorch install to Windows installer - #7706

Merged
danielhanchen merged 52 commits into
unslothai:mainfrom
legobele:add-intel-arc-xpu-detection
Aug 4, 2026
Merged

danielhanchen merged 52 commits into
unslothai:mainfrom
legobele:add-intel-arc-xpu-detection

Conversation

@legobele

Copy link
Copy Markdown
Contributor

Fixes the installer's GPU detection chain which currently only checks for NVIDIA (CUDA) and AMD (ROCm), causing Intel Arc GPUs to fall into the cpu-only Torch path.

What changed

  • WMI-based Intel GPU detection (Arc, Iris, UHD, HD Graphics) before the final fallback
  • Torch XPU availability check for migrated/upgraded environments
  • XPU PyTorch install path using download.pytorch.org/whl/xpu index
  • CPU fallback with pointer to the Intel oneAPI docs
  • Updated messaging from "NVIDIA or AMD ROCm" to include Intel Arc

Why it works

PyTorch publishes XPU (SYCL) wheels at download.pytorch.org/whl/xpu that bundle their own oneAPI runtime (intel-sycl-rt, intel-cmplr-lib-rt, etc.), so no Intel oneAPI Base Toolkit installation is required for GPU training.

Tested on

Windows 11, Intel Arc 140V GPU (8GB), PyTorch 2.9.0+xpu, Qwen3.5-0.8B loaded on xpu:0

Related

legobele and others added 2 commits July 31, 2026 14:27
The installer's GPU detection chain (NVIDIA -> AMD ROCm -> else)
has no Intel Arc/SYCL/XPU branch, so Intel Arc GPUs fall into the
"none (chat-only / GGUF)" branch and get CPU PyTorch despite
PyTorch publishing XPU wheels at download.pytorch.org/whl/xpu.

This adds:
- WMI-based Intel GPU detection (Arc, Iris, UHD, HD Graphics)
- Torch XPU availability check for migrated/upgraded environments
- An XPU PyTorch install path with the whl/xpu index
- CPU fallback with a pointer to the Intel oneAPI docs when XPU
  isn't available
- Updated messaging from "NVIDIA or AMD ROCm" to include Intel Arc

The XPU wheels ship their own oneAPI runtime (intel-sycl-rt et al.)
so no Intel oneAPI Base Toolkit is required for GPU training.

Tested on: Windows 11, Intel Arc 140V GPU (8GB), PyTorch 2.9.0+xpu

Co-authored-by: CommandCodeBot <[email protected]>
The XPU index selected during GPU detection was overwritten by
Get-TorchIndexUrl before the install branch read it, so Intel hosts still
got CPU PyTorch while being told XPU wheels were being installed.

- Move the XPU reroute after Get-TorchIndexUrl, and let an explicit pin win
- Detect via Get-CimInstance (Get-WmiObject is absent in PowerShell 7)
- Match only Arc / Data Center GPU, so UHD / HD / Iris Xe are not promised XPU
- Split Intel GPU present from XPU-capable so the CPU fallback hint works
- Bound the XPU torch trio like every other index (bare names resolved
  torch 2.13.0 + torchaudio 2.11.0 and pulled unsloth back to an old release)
- Clear the XPU state after a CPU fallback, mirroring the ROCm path
- Teach the index family, GPU branch and torch flavor helpers about xpu
@danielhanchen

Copy link
Copy Markdown
Member

Thanks for this, Intel Arc support in the Windows installer is something we want. The direction is right, and unsloth/device_type.py already treats xpu as a first class device, so the runtime side is ready for it.

I pushed a commit to your branch to fix a few things that stopped the feature from actually engaging. Details below so nothing is a surprise.

The main issue

install.ps1 set the XPU index during GPU detection, but $TorchIndexUrl = Get-TorchIndexUrl further down overwrote it unconditionally before the install branch ever read it. On an Intel only host Get-TorchIndexUrl returns the CPU index, so the guard on the XPU branch was never true.

The visible result on an Arc box was the installer printing "Intel GPU detected" and "PyTorch XPU (SYCL) wheels will be installed from ...", then printing "No NVIDIA GPU detected." and installing CPU PyTorch. The XPU branch only ran if UNSLOTH_TORCH_INDEX_FAMILY=xpu was already set, which is probably how the Arc 140V run in the description worked.

Simulating both revisions across 34 Windows scenarios, before and after your commit were identical on every path except the messaging.

What the commit changes

  • Moves the XPU reroute to after Get-TorchIndexUrl, so it survives. An explicit UNSLOTH_TORCH_INDEX_URL / _FAMILY pin still wins, matching how the AMD ROCm reroute behaves.
  • Switches detection to Get-CimInstance. Get-WmiObject does not exist in PowerShell 7, and the catch {} swallowed the error, so the whole feature silently no-opped for anyone running the installer under pwsh.
  • Narrows the adapter match to Arc and Data Center GPU. Intel.*Graphics matched every Intel iGPU ever shipped, including UHD 620 and HD 4000, which PyTorch XPU does not support. It also made the Iris, UHD and HD Graphics alternatives redundant while still missing Data Center GPU Max, which the comment claimed to cover.
  • Separates "an Intel GPU is present" ($HasIntelGpu) from "XPU wheels are appropriate" ($script:IsIntelXpu). Previously the first implied the second, which made the "Intel GPU detected but XPU not available" hint unreachable. Legacy iGPU users now get an accurate message instead of a promise of GPU wheels.
  • Bounds the torch trio like every other index. This one matters: unpinned resolved to torch 2.13.0+xpu with torchaudio 2.11.0+xpu, and since unsloth requires torch<2.12.0 that silently pulled unsloth back to an older release. Bounded resolves to a clean torch 2.10.0+xpu set.
unpinned:  torch==2.13.0+xpu  torchvision==0.28.0+xpu  torchaudio==2.11.0+xpu  ->  unsloth==2026.3.11
bounded:   torch==2.10.0+xpu  torchvision==0.25.0+xpu  torchaudio==2.10.0+xpu  ->  unsloth==2026.7.6
  • Clears the XPU state after a CPU fallback, mirroring what the ROCm path does, so the flavor repair block does not retry the index that just failed.
  • Teaches Get-TauriTorchIndexFamily, Get-TauriGpuBranch, ConvertTo-TorchFlavorTag and Get-ExpectedTorchFlavorTag about xpu. Without this an XPU install reported gpu_branch=unknown to diagnostics and a 2.9.0+xpu wheel was classified as cpu.

Verification

Arc A770 / B580 / 140V now select the XPU index and take the XPU install branch. Iris Xe, UHD 620 and HD 4000 correctly stay on CPU with the accurate hint. NVIDIA, AMD ROCm, CPU only and hybrid Intel plus NVIDIA scenarios are byte for byte identical to main, as is install.sh. install.ps1 and studio/setup.ps1 both parse clean, and tests/studio/test_torch_flavor.ps1, test_node_decision.ps1, test_node_probe_guard.ps1, test_install_rollback_lifecycle.ps1, test_torch_index_pin_hardening.ps1, test_setup_pin_stale.ps1 plus tests/python/test_cross_platform_parity.py all pass.

Two follow ups, happy to take these separately

  1. studio/setup.ps1 runs its own torch resolution and does not know about xpu, so a later Studio setup with a changed pin can still reinstall over an XPU venv.
  2. pyproject.toml already ships curated intel-gpu-torch* extras that pin torch, pytorch_triton_xpu and an Intel capable bitsandbytes wheel. Selecting the matching extra would be better than a bare torch install, since the current path never installs that bitsandbytes build. Also worth noting our Windows Intel docs ask for oneAPI plus Level Zero, which the header comment says is unnecessary. That is true for stock PyTorch but not for the full Unsloth stack on Windows.

Also worth rebasing on latest main when you get a chance, the branch predates #7692.

install.ps1 now classifies an /xpu index leaf as family xpu / branch xpu, so
mirror the same two cases in _tauri_torch_index_family and _tauri_gpu_branch.
These feed the [TAURI:DIAG] line only, and a Linux user can already reach the
xpu index via UNSLOTH_TORCH_INDEX_FAMILY, where it previously reported
auto/unknown. Linux Intel auto-detection is not added here.
@danielhanchen

Copy link
Copy Markdown
Member

Checked whether this needs an install.sh counterpart. Short answer: one small parity item, which I have pushed, and Linux auto-detection is a genuine gap but belongs in its own PR.

What I changed (7d45c78)

My previous commit taught install.ps1 to classify an /xpu index leaf as family xpu / branch xpu. Those helpers are documented as mirroring install.sh, so leaving it would have created a silent divergence. Added the matching two cases to _tauri_torch_index_family and _tauri_gpu_branch.

This matters today even without Linux detection, because a Linux user can already reach the XPU index by hand:

UNSLOTH_TORCH_INDEX_FAMILY=xpu   -> https://download.pytorch.org/whl/xpu
UNSLOTH_TORCH_INDEX_URL=.../xpu  -> https://download.pytorch.org/whl/xpu

Before, that install reported gpu_branch=unknown torch_index_family=auto in diagnostics. Now both installers agree:

leaf      install.sh              install.ps1
xpu       family=xpu   branch=xpu family=xpu   branch=xpu
cpu       family=cpu   branch=cpu family=cpu   branch=cpu
cu128     family=cu128 branch=cuda family=cu128 branch=cuda
rocm7.2   family=rocm7.2 branch=rocm family=rocm7.2 branch=rocm

These feed the [TAURI:DIAG] line only, and the Tauri side records the marker as an opaque string rather than matching on it, so there is no behavioural risk. bash -n and sh -n pass, the 12 scenario Linux/WSL/macOS index matrix is byte identical to main, and 120 installer tests pass.

What I did not add, and why

Auto-detecting an Intel GPU on Linux and rerouting to the XPU index is a real gap, but it is a feature rather than a fix for this PR:

  • The pieces are there. install.sh already enumerates PCI vendors via /sys/bus/pci/devices/*/vendor for AMD, so an 0x8086 check would slot in beside it, and the XPU index publishes linux_x86_64 wheels alongside win_amd64.
  • Bounds are already safe. install.sh applies TORCH_CONSTRAINT globally rather than per branch, so a Linux XPU path would inherit torch>=2.4,<2.11.0 automatically and would not hit the unpinned resolution problem the Windows branch had.
  • The runtime story is different enough to want its own testing. Linux XPU needs the compute runtime and Level Zero from the distro rather than the bundled Windows driver path, and pyproject.toml carries separate Linux pytorch_triton_xpu pins.

Since neither of us can test on an Arc box under Linux in this PR, I would rather land the Windows path here and do Linux detection separately where it can be exercised properly.

studio/setup.ps1 and studio/install_python_stack.py are deliberately untouched. install_python_stack.py treats an unrecognised leaf as unknown and leaves torch alone, which is the safe behaviour for an XPU venv, so teaching it xpu without the rest of the plumbing would make things worse rather than better. That is still the follow up I mentioned above.

@danielhanchen

Copy link
Copy Markdown
Member

Ran a regression sweep across every vendor we support, since this touches the shared index and diagnostics helpers. No regressions found.

Staging CI, including macOS

Replicated onto a staging repo rather than loading the org queue. All green at 7d45c78:

pr-7706-ci         success  Mac Studio UI CI
pr-7706-ci         success  Clean machine install
pr-7706-ci         success  Interrupted install recovery
pr-7706-ci         success  Startup profile
pr-7706-xplat-ci   success  staging-7706 macos-14
pr-7706-xplat-ci   success  staging-7706 ubuntu-latest
pr-7706-xplat-ci   success  staging-7706 windows-latest
pr-7706-xplat-ci   success  Mac Studio UI CI, Clean machine install,
                            Interrupted install recovery, Startup profile

Four runs show as cancelled at 10:41:29. Those were superseded three seconds later by the 10:41:32 runs on the same branch, which all passed, so it is concurrency group cancellation rather than failure. Every workflow has a green terminal run. Staging PRs closed, not merged.

Vendor spoofing in an isolated venv

Built a clean uv venv (torch 2.10.0+cpu, structlog, pytest) and ran the existing spoof suites against main and this branch:

suite covers main this branch
test_hardware_dispatch_matrix.py CUDA / ROCm / XPU / MLX / CPU profiles 23 passed 23 passed
test_is_mlx_dispatch_gate.py MLX gating 5 passed, 1 skipped 5 passed, 1 skipped
test_xpu_spoof_pipeline.py fake torch.xpu pipeline, Arc B580 / Lunar Lake mem_get_info 29 passed 29 passed

Also spoofed each vendor in its own venv to check installer side leaf classification, identical on both branches:

nvidia  leaf=cu128    cuda_family=true   rocm_family=false
amd     leaf=gfx1201  cuda_family=false  rocm_family=true
intel   leaf=xpu      cuda_family=false  rocm_family=false
cpu     leaf=cpu      cuda_family=false  rocm_family=false

Real NVIDIA

4x B200, driver 590.48.01, torch 2.9.1+cu128:

main          DEVICE_TYPE=cuda  torch_dev=cuda  count=4  is_hip=False
this branch   DEVICE_TYPE=cuda  torch_dev=cuda  count=4  is_hip=False

Installer matrices

The tests that actually exercise the change: 34 Windows scenarios and 12 Linux/WSL/macOS scenarios, run against main, the original commit and the current branch. NVIDIA (cu126/cu128/cu130), AMD ROCm, CPU only, hybrid Intel plus NVIDIA and hybrid Intel plus AMD are byte identical to main. Arc A770, B580 and 140V now select the XPU index and take the XPU install branch. Iris Xe, UHD 620 and HD 4000 correctly stay on CPU with the accurate message rather than being promised XPU wheels.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 2, 2026
Comment and whitespace only, no code change.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

- Run the Intel scan before the GPU report chain instead of inside its final
  else. A WMI-named-only AMD adapter set ROCmGpuLabel and took that chain, so a
  discrete Arc card next to an AMD CPU's integrated Radeon was never detected.
  The scan is gated on no usable NVIDIA or AMD, and the Intel branch ranks above
  the two AMD-present-but-unusable branches, so a usable AMD host is unaffected.
- Let a migrated env's torch veto the hardware match only when it is itself an
  XPU build. A CPU build reports torch.xpu.is_available() False for lacking XPU
  support, not for unsuitable hardware, and was blocking the CPU to XPU upgrade.
- Detect Intel in studio/setup.ps1 too. It only knew NVIDIA and AMD, so every
  successful Intel install printed none (chat-only / GGUF) right after
  install.ps1 reported a usable Arc GPU. Self-contained so studio update works.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

- Reset $script:IsIntelXpu at the start of each invocation. Under the documented
  irm | iex path $script: is the caller's session scope, so a second run in the
  same session inherited a stale true, skipped the scan on a now-NVIDIA host and
  still rerouted to the xpu index. Reproduced in pwsh before fixing.
- Gate the Intel scan on whether AMD actually gets a wheel, not on whether an AMD
  arch was seen. An arch missing from the family map has no ROCm wheels and lands
  on CPU torch, so it must not outrank a usable Arc card. The map is hoisted above
  the scan and consumed unchanged by the AMD reroute.
- Select the XPU index in studio/setup.ps1, not just report it. Previously setup
  printed Intel GPU detected and then installed CPU torch, so studio update never
  migrated an Arc box off CPU. Adds a bounded XPU install with a CPU fallback,
  teaches the stale-venv check about +xpu, and mirrors the wheel-aware AMD gate so
  the two files agree instead of wiping the venv on every update.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

- Force the dependency pass on an Arc host whose torch is not XPU-capable, the
  Intel counterpart of the existing AMD escape. Without it the fast up-to-date
  path skipped the install block, so the xpu index selection was never reached
  and a CPU venv never migrated.
- Confirm a working XPU runtime before treating an xpu venv as stale. If CIM is
  unavailable or returns an Intel name outside the Arc match, the expected tag
  fell through to cpu and a valid XPU environment was rebuilt and lost.
- Force-reinstall the XPU trio only when the installed wheel is not already
  +xpu, or the pin changed. It was unconditional, so a fresh install re-fetched
  multiple GB immediately and again on every update.
- Warn when torch.xpu.is_available() is false after installing XPU torch, naming
  the Intel driver floor. Otherwise the installer promised GPU training while
  unsloth raised NotImplementedError at import on a stale driver.
- Stop the detection probe vetoing the hardware match. Its cpu fallback could not
  displace the installed +xpu wheel, so it only mislabelled a capable GPU as
  unusable; the driver warning covers that case honestly, and setup.ps1 agrees.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

…dbytes on the Intel path

install.sh: teach _torch_flavor_tag, _expected_torch_flavor_tag and
_torch_index_repairable about the xpu leaf. The diagnostic already reported
gpu_branch=xpu, but an xpu pin fell to the custom arm so a migrated env kept
its CPU wheel. The +xpu flavor arm is required alongside, otherwise a correct
2.10.0+xpu wheel reads as cpu and gets force-reinstalled every run.

install.ps1 / studio/setup.ps1: route every torch probe through a new bounded
Invoke-BoundedPythonProbe (ProcessStartInfo, both streams drained async,
WaitForExit, kill on timeout). A hanging Intel driver init is exactly what
these probes detect, and an unbounded one would hang the installer instead of
reaching the warning. Timeouts read as not-available. Get-InstalledTorchTag
now shares the helper rather than carrying a second copy of the pattern.

install.ps1: install bitsandbytes>=0.50.0 on the XPU path. unsloth's floor is
>=0.45.5, so a migrated venv keeps a pre-0.49 wheel with no XPU library and
4-bit QLoRA silently turns off. Same floor the AMD paths use, since <=0.49.2
NaNs at 4-bit decode and an Arc card can sit next to a Radeon.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

… pin

studio/setup.ps1: `unsloth studio update` migrating a CPU venv to XPU replaced
only the torch trio. install_python_stack.py then upgrades unsloth and
unsloth-zoo alone, so an installed bitsandbytes 0.45.x kept satisfying the base
floor while carrying no Windows XPU kernels, and 4-bit QLoRA silently turned
off. Adds the same bitsandbytes>=0.50.0 --no-deps pass install.ps1 got, placed
after the stack so it is the last word, gated on $XpuIndexUrl (the CPU fallback
clears it, no-torch never sets it) and still inside the -not $SkipPythonDeps
block so the up-to-date escape does not reach it.

install.ps1: key the bitsandbytes pass off the index leaf instead of
$script:IsIntelXpu. An explicit UNSLOTH_TORCH_INDEX_FAMILY=xpu pin on a
non-Intel host skips the XPU branch but still installs the trio from the xpu
index, so torch is +xpu and needs the same floor. The CPU fallback rewrites
$TorchIndexUrl, so a failed XPU install reads as cpu and stays quiet.
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 2, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 2, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 2, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 2, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 2, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 2, 2026
install.sh's _torch_index_url_leaf, setup.ps1's Get-TorchIndexLeaf and
install_python_stack's _torch_index_leaf all lowercase before classifying. This copy did
not, so UNSLOTH_TORCH_INDEX_FAMILY=XPU (or a URL ending in /XPU) left the leaf uppercase,
the equality test against "xpu" failed, and the fast path stayed on. Those same classifiers
call that pin XPU once they are reached, so the wheel was never migrated and the update
silently repaired nothing. The comment above the line already claimed to match the shared
parsers; now it does.

Three cases added to tests/sh/test_setup_xpu_fastpath_escape.sh (FAMILY=XPU, FAMILY=Xpu,
a URL ending /XPU), plus one that lowercasing must not widen the match: a custom leaf like
PRIVATE-XPU stays an unknown family. All three fail against the previous line and pass now.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: 0fe42aa97a

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

The unavailable-runtime arm said training and GPU inference run on CPU until the driver is
fixed. They do not: with neither CUDA nor XPU available, get_device_type() in
unsloth/device_type.py raises NotImplementedError, so importing unsloth fails outright
rather than falling back. llama.cpp is unaffected, which is what chat and GGUF actually run
on, so say that instead.

The drift guard added with it needed two passes to be worth anything. Anchoring the arm on
the flag name alone matched the bitsandbytes block instead, whose own "4-bit QLoRA may be
unavailable" warning made both assertions pass on any wording; and the arm's explanatory
comment quotes the phrase it must not use, so comment lines have to go before the grep.
Restoring the old message now fails both checks.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 298569e603

ℹ️ 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 and others added 2 commits August 4, 2026 05:59
Two halves of the same gap: asking for CUDA/ROCm/CPU on a host already running +xpu did
nothing.

setup.sh: the fast-path escape fired only when the pin itself was xpu, or when a stale
generic triton shadowed the build. With an up-to-date install, a +xpu wheel and the pin
switched to another family, neither arm matched, install_python_stack never ran, and the
authoritative pin was ignored. Added an arm for that case, digit-gated like the shared
classifiers so a custom verbatim leaf (rocm-current, cu-private) stays UNKNOWN and does not
force a pass that repairs nothing.

install_python_stack: _ensure_cpu_torch classifies the installed build and returns early on
"already a CPU build". Its probe tested hip, rocm, cuda and +cu<digits>; an XPU wheel sets
neither torch.version.cuda nor .hip, so it read as CPU and an explicit CPU pin over it did
nothing at all. Keyed on the +xpu local label, since torch.version.xpu is None on some
builds. Additive: +cu128 and +rocm still read gpu, +cpu and untagged still read cpu.

The escape suite's extractor stopped after the second _SKIP_PYTHON_DEPS assignment, so
adding a third arm truncated the block and the new cases failed while the old ones passed.
It now stops at the next outer arm and asserts exactly three arms extract, so a future arm
fails loudly instead of disappearing.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

danielhanchen and others added 2 commits August 4, 2026 06:36
Both of these are fallout from making the CPU repair XPU-aware: it now has to classify an
XPU wheel, and every route to that classification went through `import torch`, which loads
the SYCL runtime and blocks on the exact host these paths exist to rescue.

install_python_stack: the classifier probe times out after 90s and the except branch
returned, so an explicit CPU pin over a wedged +xpu venv stayed a no-op. Classify off disk
on timeout via _installed_torch_label_on_disk (find_spec, no interpreter) and fall through
to the repair. Gated on a GPU label so a slow but healthy CPU-only host does not
force-reinstall torch every update.

install.sh: the rollback preservation probe read torch.__version__ through the interpreter
at venv-replacement time, ahead of every bounded probe in setup.sh, so a hang there took the
whole installer with it. It now reads torch/version.py, the same source
_installed_torch_version_for_tag already uses for this reason. The interpreter stays as the
fallback for a layout without one, where torch is absent and the import fails fast.

The install.sh test executes the block against a fake venv whose stub interpreter records
being called, so "read off disk" is proven by the interpreter never running rather than by
reading the source.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

…e wheel

studio/setup.sh classified a pin as a known non-XPU family with prefix globs
(cu[0-9]*, rocm[0-9]*), so cu128-private, cu128rc1, cu128.1, rocm7.2-private,
rocm7. and rocm7.2.1 all read as known while install_python_stack calls every
one of them UNKNOWN and runs no repair: the fast path was cleared and the
dependency pass that followed applied nothing, every update. It now matches
exact families like install.sh _is_pip_rocm_family_leaf and
install_python_stack _is_cuda_family_leaf: cpu, cu<digits>,
rocm<digits>[.<digits>], gfx<digit>... (gfx stays a prefix on all three sides,
since gfx120x-all is a real Radeon index leaf).

studio/setup.ps1 keyed the same escape on torch.xpu.is_available(), which is
also false for a supported +xpu wheel on an old or wedged compute driver. No
dependency pass can repair a driver, and the pass force-reinstalls nothing when
the flavour already matches, so each studio update repeated the bounded probes
and a full resolution just to reach the warning Assert-XpuRuntimeReady already
prints. The escape now asks Test-VenvTorchIsXpuSupported, which reads
torch/version.py off disk and applies the same 2.6 <= v < 2.11 window, matching
what setup.sh does on POSIX and removing the last import torch from a path an
Arc host with a stalled driver is most likely to hit. Its only caller gone,
Test-TorchXpuVersionSupported is removed.

Tests: the escape test now also asks install_python_stack itself about a
28-leaf corpus and asserts the shell predicate agrees leaf for leaf, so the two
cannot drift again (75 checks; 11 fail against the previous globs). The
pre-report test covers the new helper and asserts the fast-path escape names no
readiness probe and launches no interpreter.
@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 4b795cfbd2

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

A Windows checkout returns CRLF, so the fast-path escape pattern, which is
anchored on a literal \n, matched nothing on windows-latest: the region came
back empty, "the escape was found" failed, and the two -not checks inside it
reported PASS with nothing to look at. Cross-platform parity caught it on
windows-latest with 3 failures.

$setupText is now normalised to LF once at the read, which covers both literal
newline patterns in the file, and a new check asserts the raw CRLF form does
NOT match the same pattern, so it is the normalisation rather than luck that
makes this work. Verified against a CRLF copy of setup.ps1: the previous test
fails there with exactly those 3 checks and the new one passes.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

_ensure_xpu_triton keys off the installed +xpu label when no explicit XPU pin
is set, and it ran ahead of _ensure_cpu_torch. So an existing +xpu venv updated
with an explicit CPU pin had generic triton removed and XPU triton installed,
and only then did _ensure_cpu_torch replace torch with the CPU build: a CPU
environment whose top-level triton package is the XPU implementation, with the
generic triton its own dependency set declares now gone.

The CUDA and ROCm repairs already ran ahead of the swap, so their pins left the
label correct by the time it read it; CPU was the one migration that did not.
Moving the swap to the end of both repair blocks fixes it for every family at
once and removes the ordering assumption entirely.

The new test asserts the order on the AST at both call sites, so a reflow
cannot fake it; against the previous order it fails on the first assertion.
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@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: 611dc85e30

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread studio/setup.ps1
}
$env:PIP_CONFIG_FILE = 'nul'
try {
& python -m pip download @Args_ 2>&1

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 Bootstrap pip before the XPU Triton download

On the normal Windows path the venv is created by uv venv ... without --seed (uv venv --help makes pip a seed package installed only with --seed), so fresh Studio venvs do not have python -m pip. When an XPU install reaches the Triton swap, this pip download call fails with No module named pip, takes the warning path, and leaves triton-windows shadowing torch's XPU Triton, so torch.compile remains broken on fresh XPU installs. Bootstrap pip here before downloading, as the POSIX _ensure_venv_pip() helper does.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The premise about uv venv is right, but pip is already bootstrapped before this line is reachable.

setup.ps1 runs install_python_stack.py at line 3945 and the Triton swap at 4012, and both sit inside the same if (-not $SkipPythonDeps) block that opens at 3565, in that order. Step 2 of install_python_stack() is the pip bootstrap, at the top of the function and reached before anything else can return: uv pip install --python sys.executable pip when uv is available, python -m ensurepip --upgrade otherwise. It runs through run(), which calls sys.exit(returncode) on failure, and the swap is additionally gated on $stackExit -eq 0. So either pip exists by the time Fast-Download is called, or install_python_stack.py exited non-zero and the swap never runs.

The only return in install_python_stack() ahead of that bootstrap is return 1, which closes the same gate.

_ensure_venv_pip() on the POSIX side is not the counterpart this is missing: _ensure_xpu_triton is called from inside install_python_stack() itself, so it re-checks cheaply rather than relying on the earlier step, and both of its callers are downstream of the same bootstrap.

macOS ships no GNU timeout (Homebrew coreutils installs it as gtimeout), so on
the macOS parity leg the `timeout 30 python3 ...` line exited 127 the instant it
was called. The test reads only the exit code, and 127 is non-zero with an
elapsed time of 0, so both assertions passed without python ever starting: the
alarm behaviour they exist to prove was never exercised on macOS.

Replaced with the script's own background watchdog, which behaves the same on
every platform, and added a lower bound on the elapsed time. The alarm is 2s, so
a run that returns instantly did not execute the probe, which is precisely how
the missing-timeout case looked.

Verified by shimming `timeout` to exit 127: the previous test still reports 37
passed, and by shimming python3 to return instantly: the previous test still
reports 37 passed while this one fails on the deadline check.
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 131adf37c7

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

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 8b70bf81b1

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants