Repository navigation
Windows installer: fix DiskPart UAC mid-install, drive-root cache, and spurious unsloth.exe rename warning - #6296
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces changes to ignore virtual environment-internal hipInfo.exe files when detecting a HIP SDK on Windows, preventing amd-smi from triggering UAC prompts. It also updates PowerShell installation scripts to use a local cache directory under the user's home instead of the root of the C drive, and skips renaming unsloth.exe under certain conditions. The feedback highlights a potential issue on Windows where file path comparisons can fail due to case mismatches (e.g., drive letters). It is recommended to use os.path.normcase on both sides of the path comparison in _path_inside_venv across amd.py, install_llama_prebuilt.py, and install_python_stack.py to ensure robust path matching.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| try: | ||
| root = os.path.abspath(sys.prefix) | ||
| return os.path.commonpath([os.path.abspath(path), root]) == root | ||
| except (ValueError, OSError): | ||
| # Different drive / unresolvable -> treat as outside the venv. | ||
| return False |
There was a problem hiding this comment.
On Windows, file paths are case-insensitive, and drive letters or directory names can have mismatched casing (e.g., C:\ vs c:\). os.path.commonpath normalizes casing internally for comparison but returns the common path using the casing of the first path in the list. This means comparing the returned common path directly with root using == can fail due to case mismatches, incorrectly returning False even when the path is inside the virtual environment. To prevent this, wrap both sides of the comparison with os.path.normcase.
| try: | |
| root = os.path.abspath(sys.prefix) | |
| return os.path.commonpath([os.path.abspath(path), root]) == root | |
| except (ValueError, OSError): | |
| # Different drive / unresolvable -> treat as outside the venv. | |
| return False | |
| try: | |
| root = os.path.normcase(os.path.abspath(sys.prefix)) | |
| return os.path.normcase(os.path.commonpath([os.path.abspath(path), root])) == root | |
| except (ValueError, OSError): | |
| # Different drive / unresolvable -> treat as outside the venv. | |
| return False |
| try: | ||
| _root = os.path.abspath(sys.prefix) | ||
| return os.path.commonpath([os.path.abspath(path), _root]) == _root | ||
| except (ValueError, OSError): | ||
| # Different drive / unresolvable -> treat as outside the venv. | ||
| return False |
There was a problem hiding this comment.
On Windows, file paths are case-insensitive, and drive letters or directory names can have mismatched casing (e.g., C:\ vs c:\). os.path.commonpath normalizes casing internally for comparison but returns the common path using the casing of the first path in the list. This means comparing the returned common path directly with _root using == can fail due to case mismatches, incorrectly returning False even when the path is inside the virtual environment. To prevent this, wrap both sides of the comparison with os.path.normcase.
| try: | |
| _root = os.path.abspath(sys.prefix) | |
| return os.path.commonpath([os.path.abspath(path), _root]) == _root | |
| except (ValueError, OSError): | |
| # Different drive / unresolvable -> treat as outside the venv. | |
| return False | |
| try: | |
| _root = os.path.normcase(os.path.abspath(sys.prefix)) | |
| return os.path.normcase(os.path.commonpath([os.path.abspath(path), _root])) == _root | |
| except (ValueError, OSError): | |
| # Different drive / unresolvable -> treat as outside the venv. | |
| return False |
| try: | ||
| _root = os.path.abspath(sys.prefix) | ||
| return os.path.commonpath([os.path.abspath(path), _root]) == _root | ||
| except (ValueError, OSError): | ||
| # Different drive / unresolvable -> treat as outside the venv. | ||
| return False |
There was a problem hiding this comment.
On Windows, file paths are case-insensitive, and drive letters or directory names can have mismatched casing (e.g., C:\ vs c:\). os.path.commonpath normalizes casing internally for comparison but returns the common path using the casing of the first path in the list. This means comparing the returned common path directly with _root using == can fail due to case mismatches, incorrectly returning False even when the path is inside the virtual environment. To prevent this, wrap both sides of the comparison with os.path.normcase.
| try: | |
| _root = os.path.abspath(sys.prefix) | |
| return os.path.commonpath([os.path.abspath(path), _root]) == _root | |
| except (ValueError, OSError): | |
| # Different drive / unresolvable -> treat as outside the venv. | |
| return False | |
| try: | |
| _root = os.path.normcase(os.path.abspath(sys.prefix)) | |
| return os.path.normcase(os.path.commonpath([os.path.abspath(path), _root])) == _root | |
| except (ValueError, OSError): | |
| # Different drive / unresolvable -> treat as outside the venv. | |
| return False |
…e warning, CPU-base messaging
amd-smi gate (DiskPart UAC mid-install): the AMD torch wheel ships hipInfo.exe
inside the venv, and the bitsandbytes fix prepends that venv Scripts dir to PATH.
shutil.which("hipinfo") then found it and flipped _amd_smi_allowed() to True, so
the post-install AMD probe fell through to `amd-smi list` (the venv hipInfo failed
to report gcnArchName, which is why the arch came from the GPU-name table) and
amd-smi elevated, popping the DiskPart UAC. Fix: a hipinfo resolved inside the
active venv (sys.prefix) is the torch-wheel binary, not a HIP SDK, and must not
open the gate. Mirrored in install_python_stack.py, install_llama_prebuilt.py, and
backend utils/hardware/amd.py (the runtime VRAM poller had the same latent prompt).
TORCHINDUCTOR_CACHE_DIR: move from C:\tc to <StudioHome>\TORCHINDUCTOR_CACHE_DIR so
the inductor/Triton cache lives under the user's Studio home, not the system drive
root. Long paths are already enabled above so deep inductor paths still fit.
unsloth.exe rename: skip the rename (and its "pip may fail with WinError 32"
warning) when SKIP_STUDIO_BASE=1. In the install.ps1 flow base packages are not
reinstalled, so unsloth.exe is never rewritten; the self-rename only failed because
setup runs via unsloth.exe (the running launcher holds its own file). The
'studio update' flow still attempts it.
CPU PyTorch messaging: clarify that the CPU base is temporary and setup replaces it
with GPU ROCm wheels, and print an explicit "GPU ROCm PyTorch installed" line after
the AMD wheels land, so the log makes clear the final install is GPU-accelerated.
Adds two regression tests covering the venv-internal vs external hipInfo gate.
Verified end-to-end on a Strix Halo box (Radeon 8060S / gfx1151): install.ps1
--local from this branch completed exit 0 with no DiskPart prompt, no rename
warning, the cache under the Studio home, and "GPU ROCm PyTorch installed
(gfx1151)"; Studio then booted and detected "ROCm (HIP 7.13.99004) -- AMD Radeon
8060S Graphics".
5da5813 to
4f29a68
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4f29a686ab
ℹ️ 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".
| _hip = shutil.which("hipinfo") | ||
| if _hip and not _path_inside_venv(_hip): |
There was a problem hiding this comment.
Scan past venv hipInfo on PATH
When the venv Scripts directory is first on PATH but a real HIP SDK bin appears later (for example after the installer prepends Scripts, or in an activated Studio venv, with no HIP_PATH/ROCM_PATH set), shutil.which("hipinfo") returns only the venv-internal hipInfo.exe. This rejects that path and then falls through without checking the remaining PATH entries, so PATH-only HIP SDK installs are treated as unsafe and skip the amd-smi fallback/VRAM polling despite having a genuine SDK. Consider scanning all PATH hits for an external hipinfo before returning false; the same pattern is mirrored in the other _amd_smi_allowed copies.
Useful? React with 👍 / 👎.
| # under the user's Studio home (NOT the C:\ drive root) -- long paths are already | ||
| # enabled above, and Python opts into them, so deep inductor paths still fit | ||
| # without polluting the system drive. | ||
| $TorchCacheDir = Join-Path $StudioHome "TORCHINDUCTOR_CACHE_DIR" |
There was a problem hiding this comment.
Keep the cache short when long paths are unavailable
On Windows hosts where long paths are still disabled and the elevation prompt is declined or unavailable (the earlier long-path step only warns and continues), moving TORCHINDUCTOR_CACHE_DIR from C:\tc to $StudioHome\TORCHINDUCTOR_CACHE_DIR removes the short path that was protecting Triton/Inductor from MAX_PATH. Default or custom Studio roots can already be dozens of characters long, so generated compile paths can exceed 260 characters and break training/torch.compile in environments that previously worked. Please keep a short fallback when $LongPathsEnabled is false, or use a much shorter per-user directory.
Useful? React with 👍 / 👎.
…Error 32 warning setup.ps1 used to rename the running unsloth.exe out of the way before the base-package upgrade so pip could replace it. That rename never actually worked: setup runs *via* unsloth.exe, so renaming our own running uv-trampoline launcher failed with a sharing violation (WinError 32) and only printed a scary 'could not rename unsloth.exe; pip may fail with WinError 32' warning on every Windows install and update. It also was not needed. pip tolerates a running/locked console-script .exe: it moves the old one aside and writes the new one. The base upgrade routes through pip on Windows, so the upgrade succeeds (or, in the install.ps1 flow with SKIP_STUDIO_BASE=1, the base is not touched at all) and unsloth.exe is left intact either way. Removing the rename block and its failed-install restore block removes the false warning for all Windows devices in both the install and update flows.
…mi probe; harden venv path checks Follow-up to PR #6296. - install.ps1 and setup.ps1: ignore the AMD torch wheel hipInfo.exe that lives inside the Studio venv when probing for a HIP SDK, so amd-smi no longer reopens the DiskPart UAC during install/update. Mirrors _path_inside_venv in the Python installers, which already do this. - amd.py, install_llama_prebuilt.py, install_python_stack.py: normcase the venv containment check (Windows paths are case-insensitive) and run the HIP_PATH/ROCM_PATH candidate through it too. - setup.ps1: fall back to a short TORCHINDUCTOR cache dir when long paths are unavailable, and create the dir wildcard-safely. - tests: isolate sys.prefix in the gate helper, add HIP_PATH/ROCM_PATH cases, and assert the PowerShell venv exclusion.
|
Pushed a follow-up (a4a9811) addressing the review feedback:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 548dc9a29c
ℹ️ 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".
| if ($env:VIRTUAL_ENV) { $venvRoots += $env:VIRTUAL_ENV } | ||
| $vd = Get-Variable -Name VenvDir -ValueOnly -ErrorAction SilentlyContinue | ||
| if ($vd) { $venvRoots += $vd } |
There was a problem hiding this comment.
Initialize VenvDir before filtering hipInfo
In setup.ps1 this helper runs during GPU detection, but $VenvDir is not assigned until much later in the script, so non-activated update sessions only have $env:VIRTUAL_ENV to identify the Studio venv. On upgrades where an older installer left <StudioHome>\unsloth_studio\Scripts on PATH, Get-Command hipinfo can still resolve the AMD wheel's venv hipInfo.exe, $vd stays null, and the code marks $HipSdkInstalled true before falling through to amd-smi, reopening the DiskPart UAC prompt this change is meant to prevent. Resolve the Studio venv root before this probe, or derive it here, before trusting a hipinfo hit.
Useful? React with 👍 / 👎.
When the GPU arch is known (name-inferred from the GPU-name table) but ROCm could not be probe-verified (no HIP SDK, no amd-smi), the bootstrap installed a CPU PyTorch base that setup.ps1 then force-reinstalled as ROCm. The repo.amd.com wheels bundle their own runtime (no HIP SDK required), which setup.ps1 already relies on, so the CPU base was a pure wasted download/install. - Gate the ROCm index on a known arch, not only on probe-verified ROCm, so a mapped arch installs ROCm torch directly. Unmapped arches and no-GPU hosts still get CPU (unchanged). - Fall back to a CPU base if the ROCm-index install fails, so a transient repo.amd.com outage does not abort the install (setup.ps1 retries ROCm). - Correct the stale comment that claimed ROCm wheels need a confirmed HIP SDK. - Add a regression test for the arch-based gate.
|
Follow-up (d8a8272): install ROCm PyTorch directly for a known AMD arch, instead of laying down a CPU base that setup.ps1 immediately force-reinstalls as ROCm. On a fresh Strix Halo box (no HIP SDK, no amd-smi) ROCm cannot be probe-verified, so Change:
Verified with a decision-matrix simulation across {HasROCm} x {mapped/unmapped/no arch} x {ROCm ok/fail}: a mapped arch goes ROCm-direct with no CPU detour, an index-down case falls back to CPU, and all other paths are unchanged. install.ps1 parses clean and 28 install tests pass. Worth one real end-to-end install run on an AMD box to confirm, folding into the existing end-to-end verification. |
The comment claimed the base upgrade 'routes through pip on Windows' and that pip 'moves the old unsloth.exe aside, then writes the new one'. That is not what the code does. install_python_stack tries uv first; on a locked launcher uv aborts and falls back to pip, but the pip fallback strips --upgrade-package and base.txt lists only bare unsloth/unsloth-zoo, so pip finds them already satisfied and no-ops. The running unsloth.exe is left intact at its current version either way. Reword the comment to describe the real uv-first / pip-fallback-no-op behavior. No functional change.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7cac0d9965
ℹ️ 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 ($hipinfoExe -and (Test-HipinfoIsVenvInternal $hipinfoExe.Source)) { | ||
| $hipinfoExe = $null # venv-internal hipInfo.exe is not a HIP SDK |
There was a problem hiding this comment.
Filter env-root hipinfo before enabling amd-smi
This only applies the venv-internal check to the Get-Command result; if HIP_PATH or ROCM_PATH points at the venv runtime tree (for example <StudioHome>\unsloth_studio\_rocm_sdk_core, which also contains bin\hipinfo.exe) and no real HIP SDK is installed, the fallback below still accepts that hipinfo as a SDK, sets $HipSdkInstalled = $true, and re-opens the amd-smi path that can show the DiskPart UAC prompt. Please run Test-HipinfoIsVenvInternal on $hipinfoCandidate before assigning it; the same fallback exists in studio/setup.ps1.
Useful? React with 👍 / 👎.
| $ROCmIndexUrl = $null | ||
| $ROCmTorchFloor = $null | ||
| if ($HasROCm -and $TorchIndexUrl -like "*/cpu" -and -not $SkipTorch) { | ||
| if (($HasROCm -or $ROCmGfxArch) -and $TorchIndexUrl -like "*/cpu" -and -not $SkipTorch) { |
There was a problem hiding this comment.
Preserve the ROCm torch install before setup retries
For name-inferred AMD arches this now installs ROCm torch in install.ps1, but the installer then always invokes setup.ps1, whose dependency path recomputes $ROCmIndexUrl, runs Fast-Install ... --force-reinstall, and falls back to CPU torch if that second ROCm attempt fails. In the common installer flow, a transient failure or stricter resolver failure during the redundant setup retry can overwrite an already-working ROCm torch install with CPU torch; consider passing a marker or making setup skip/reuse an existing ROCm torch install before falling back.
Useful? React with 👍 / 👎.
| if ($LongPathsEnabled) { | ||
| $TorchCacheDir = Join-Path $StudioHome "TORCHINDUCTOR_CACHE_DIR" | ||
| } else { | ||
| $TorchCacheDir = "C:\tc" |
There was a problem hiding this comment.
Keep cache short until long paths are active
When this script has just enabled LongPathsEnabled via the UAC reg.exe call in the same PowerShell process, Windows may still use the per-process cached long-path setting because this process has already performed file-system calls before the registry flip. In that first-run path $LongPathsEnabled is set to $true, so the cache moves under $StudioHome even though the current process and child installs can still hit MAX_PATH; keep using C:\tc unless long paths were already enabled at process start, or restart before switching to the longer cache path.
Useful? React with 👍 / 👎.
|
@codex review |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request updates the installation and setup scripts to ignore virtual environment-internal hipInfo.exe binaries when probing for a HIP SDK, preventing unnecessary UAC elevation prompts on Windows. It also optimizes ROCm PyTorch installation for known AMD architectures, refactors the TORCHINDUCTOR_CACHE_DIR logic, and removes the non-functional unsloth.exe renaming code. The reviewer identified a critical issue where os.path.commonpath could fail on Windows due to case-sensitivity differences between sys.prefix and the resolved executable path, and provided suggestions to normcase both paths before comparison.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| try: | ||
| root = os.path.normcase(os.path.abspath(sys.prefix)) | ||
| return os.path.normcase(os.path.commonpath([os.path.abspath(path), root])) == root |
There was a problem hiding this comment.
On Windows, os.path.commonpath is case-sensitive for path segments. If the casing of any segment in sys.prefix (e.g., C:\Users\bob\venv) differs from the casing of the resolved executable path (e.g., C:\Users\Bob\venv\Scripts\hipinfo.exe), os.path.commonpath will fail to match them beyond the differing segment and return a parent directory (e.g., C:\Users). This causes _path_inside_venv to return False, mistaking the venv-internal hipinfo.exe for an external HIP SDK, which ultimately triggers amd-smi and pops the DiskPart UAC prompt.
To ensure robust case-insensitive comparison on Windows, both paths should be normcased before being passed to os.path.commonpath.
| try: | |
| root = os.path.normcase(os.path.abspath(sys.prefix)) | |
| return os.path.normcase(os.path.commonpath([os.path.abspath(path), root])) == root | |
| try: | |
| root = os.path.normcase(os.path.abspath(sys.prefix)) | |
| norm_path = os.path.normcase(os.path.abspath(path)) | |
| return os.path.commonpath([norm_path, root]) == root |
References
- Avoid coupling modules by importing installer script logic into backend utilities. If a utility needs similar functionality, implement it within the utility itself to maintain separation of concerns.
| try: | ||
| _root = os.path.normcase(os.path.abspath(sys.prefix)) | ||
| return os.path.normcase(os.path.commonpath([os.path.abspath(path), _root])) == _root |
There was a problem hiding this comment.
On Windows, os.path.commonpath is case-sensitive for path segments. If the casing of any segment in sys.prefix (e.g., C:\Users\bob\venv) differs from the casing of the resolved executable path (e.g., C:\Users\Bob\venv\Scripts\hipinfo.exe), os.path.commonpath will fail to match them beyond the differing segment and return a parent directory (e.g., C:\Users). This causes _path_inside_venv to return False, mistaking the venv-internal hipinfo.exe for an external HIP SDK, which ultimately triggers amd-smi and pops the DiskPart UAC prompt.
To ensure robust case-insensitive comparison on Windows, both paths should be normcased before being passed to os.path.commonpath.
| try: | |
| _root = os.path.normcase(os.path.abspath(sys.prefix)) | |
| return os.path.normcase(os.path.commonpath([os.path.abspath(path), _root])) == _root | |
| try: | |
| _root = os.path.normcase(os.path.abspath(sys.prefix)) | |
| _norm_path = os.path.normcase(os.path.abspath(path)) | |
| return os.path.commonpath([_norm_path, _root]) == _root |
| try: | ||
| _root = os.path.normcase(os.path.abspath(sys.prefix)) | ||
| return os.path.normcase(os.path.commonpath([os.path.abspath(path), _root])) == _root |
There was a problem hiding this comment.
On Windows, os.path.commonpath is case-sensitive for path segments. If the casing of any segment in sys.prefix (e.g., C:\Users\bob\venv) differs from the casing of the resolved executable path (e.g., C:\Users\Bob\venv\Scripts\hipinfo.exe), os.path.commonpath will fail to match them beyond the differing segment and return a parent directory (e.g., C:\Users). This causes _path_inside_venv to return False, mistaking the venv-internal hipinfo.exe for an external HIP SDK, which ultimately triggers amd-smi and pops the DiskPart UAC prompt.
To ensure robust case-insensitive comparison on Windows, both paths should be normcased before being passed to os.path.commonpath.
| try: | |
| _root = os.path.normcase(os.path.abspath(sys.prefix)) | |
| return os.path.normcase(os.path.commonpath([os.path.abspath(path), _root])) == _root | |
| try: | |
| _root = os.path.normcase(os.path.abspath(sys.prefix)) | |
| _norm_path = os.path.normcase(os.path.abspath(path)) | |
| return os.path.commonpath([_norm_path, _root]) == _root |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7cac0d9965
ℹ️ 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 ($hipinfoExe -and (Test-HipinfoIsVenvInternal $hipinfoExe.Source)) { | ||
| $hipinfoExe = $null # venv-internal hipInfo.exe is not a HIP SDK |
There was a problem hiding this comment.
Filter HIP_PATH candidate before enabling amd-smi
This filter is only applied to the Get-Command hipinfo result; if HIP_PATH or ROCM_PATH points at the AMD wheel's venv-internal _rocm_sdk_core, the fallback below still accepts <venv>/_rocm_sdk_core/bin/hipinfo.exe, sets $HipSdkInstalled = $true, and reopens the amd-smi probe. In that env-root case the DiskPart/UAC prompt this change is meant to suppress can still happen, so apply Test-HipinfoIsVenvInternal to $hipinfoCandidate before assigning $hipinfoExe (and mirror the same fix in install.ps1).
Useful? React with 👍 / 👎.
| hip = shutil.which("hipinfo") | ||
| if hip and not _path_inside_venv(hip): | ||
| return True |
There was a problem hiding this comment.
Continue scanning PATH after venv hipInfo
When the venv Scripts directory is prepended ahead of a real HIP SDK bin directory, shutil.which("hipinfo") returns the venv copy and this new check returns false without considering later PATH entries. On Windows hosts with both the AMD torch wheel and a PATH-only HIP SDK (no HIP_PATH/ROCM_PATH), _amd_smi_allowed() now disables the safe amd-smi path and loses VRAM polling / installer fallback behavior; scan all PATH matches and accept the first non-venv hipinfo before falling back to the env roots.
Useful? React with 👍 / 👎.
| $venvRoots = @() | ||
| if ($env:VIRTUAL_ENV) { $venvRoots += $env:VIRTUAL_ENV } | ||
| $vd = Get-Variable -Name VenvDir -ValueOnly -ErrorAction SilentlyContinue | ||
| if ($vd) { $venvRoots += $vd } |
There was a problem hiding this comment.
Seed the venv root before filtering hipInfo
In setup.ps1 this AMD probe runs long before $VenvDir is assigned, and the unsloth.exe/PowerShell launch path does not guarantee VIRTUAL_ENV is set. In that common update/install context $venvRoots is empty, so Test-HipinfoIsVenvInternal returns false for <StudioHome>\unsloth_studio\Scripts\hipInfo.exe found on PATH and the DiskPart-prone amd-smi gate is reopened; derive the root from UNSLOTH_SETUP_PYTHON or the resolved Studio home before this check.
Useful? React with 👍 / 👎.
| $ROCmIndexUrl = $null | ||
| $ROCmTorchFloor = $null | ||
| if ($HasROCm -and $TorchIndexUrl -like "*/cpu" -and -not $SkipTorch) { | ||
| if (($HasROCm -or $ROCmGfxArch) -and $TorchIndexUrl -like "*/cpu" -and -not $SkipTorch) { |
There was a problem hiding this comment.
Avoid reinstalling ROCm torch twice
For the newly added $ROCmGfxArch path, install.ps1 now downloads and installs the AMD ROCm torch wheels, but the same installer always invokes setup.ps1 with SKIP_STUDIO_BASE=1; there, $SkipPythonDeps remains false and the ROCm branch force-reinstalls the same wheels again. On name-inferred AMD machines this still burns a second multi-GB download/install instead of eliminating the wasted bootstrap torch work, so either pass a success flag to setup or leave ROCm torch for setup to install once.
Useful? React with 👍 / 👎.
Review follow-up. The amd-smi/DiskPart gate could still reopen in two cases: - setup.ps1 ran the HIP probe long before $VenvDir is assigned, so without VIRTUAL_ENV (the `unsloth studio update` path) $venvRoots was empty and the venv-internal hipInfo.exe was not recognized. Seed the venv root from UNSLOTH_SETUP_PYTHON and the default Studio home too (both installers). - The HIP_PATH/ROCM_PATH candidate was accepted without the venv filter, so an env var pointing into the venv (AMD wheel) still set $HipSdkInstalled. Run Test-HipinfoIsVenvInternal on the candidate as well (both installers). Extend the PS gate test to assert both. Both .ps1 parse clean; install tests pass (the venv-internal / HIP probe coverage at 359 passed).
|
Thanks, went through the Codex and Gemini findings. Pushed ee479c9 for the two that were genuine; the rest were already handled. Fixed (ee479c9):
Already addressed, no change needed:
Not changing:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ee479c9996
ℹ️ 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 ($env:UNSLOTH_SETUP_PYTHON) { | ||
| try { $venvRoots += (Split-Path -Parent (Split-Path -Parent $env:UNSLOTH_SETUP_PYTHON)) } catch {} | ||
| } | ||
| if ($env:USERPROFILE) { $venvRoots += (Join-Path $env:USERPROFILE ".unsloth\studio\unsloth_studio") } |
There was a problem hiding this comment.
Include custom Studio roots in hipInfo filter
When unsloth studio update runs from a custom UNSLOTH_STUDIO_HOME/STUDIO_HOME install without VIRTUAL_ENV or UNSLOTH_SETUP_PYTHON (the standalone update path), this helper still seeds only the default %USERPROFILE%\.unsloth\studio\unsloth_studio root, while the actual custom $StudioHome is resolved later. Fresh evidence after the earlier seed-root comment is that a custom <root>\unsloth_studio\Scripts\hipInfo.exe or <root>\unsloth_studio\_rocm_sdk_core\bin\hipinfo.exe left on PATH/HIP_PATH is therefore treated as an external HIP SDK, so $HipSdkInstalled can become true and reopen the amd-smi/DiskPart prompt this change is meant to suppress.
Useful? React with 👍 / 👎.
| # No unsloth.exe rename needed -- the rename never worked anyway. setup.ps1 runs | ||
| # *via* unsloth.exe, so renaming our own running uv-trampoline launcher always | ||
| # failed with a sharing violation (WinError 32) and only printed a scary warning. |
There was a problem hiding this comment.
Keep rollback for direct setup invocations
This assumption only holds when setup is launched through unsloth.exe; the script itself documents powershell -File .\studio\setup.ps1 as a supported path, and in that context the launcher is not the running process. Removing the rename/restore block means a direct update that fails after the package manager has removed or truncated Scripts\unsloth.exe no longer restores the previous launcher, leaving the CLI broken instead of preserving the stale-but-working executable.
Useful? React with 👍 / 👎.
…Cm wheels
After gating the ROCm index on a known arch, a mapped arch sets $ROCmIndexUrl
and installs ROCm directly, so it no longer reaches the "temporary CPU base"
branch. That branch is now reached only by a name-inferred arch with no ROCm
wheels (e.g. RDNA2 gfx103X), where setup.ps1 does NOT install ROCm. The old
text ("setup replaces it with GPU ROCm wheels ... the final install IS
GPU-accelerated") was therefore always wrong there. Say plainly that PyTorch
stays on CPU for this GPU.
… Studio home Test-HipinfoIsVenvInternal seeded the venv root from VIRTUAL_ENV, VenvDir, the setup python, and the default %USERPROFILE% path only. A standalone `unsloth studio update` with a custom UNSLOTH_STUDIO_HOME (or STUDIO_HOME alias) and none of those set would not recognize the venv hipInfo on PATH, reopening the amd-smi/DiskPart gate. Seed the custom home too, in both installers, and assert it in the gate test.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6ed365779b
ℹ️ 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".
| $studioHomeEnv = if (-not [string]::IsNullOrWhiteSpace($env:UNSLOTH_STUDIO_HOME)) { $env:UNSLOTH_STUDIO_HOME.Trim() } elseif (-not [string]::IsNullOrWhiteSpace($env:STUDIO_HOME)) { $env:STUDIO_HOME.Trim() } else { $null } | ||
| if ($studioHomeEnv) { $venvRoots += (Join-Path $studioHomeEnv "unsloth_studio") } |
There was a problem hiding this comment.
Expand custom Studio roots before filtering hipInfo
When a standalone unsloth studio update/setup is run with UNSLOTH_STUDIO_HOME or STUDIO_HOME set to a supported tilde form like ~\studio, this early probe seeds the venv root from the raw env var, while the actual Studio root is expanded later before $VenvDir is derived. In that context, with no VIRTUAL_ENV/UNSLOTH_SETUP_PYTHON, <expanded-home>\studio\unsloth_studio\Scripts\hipInfo.exe on PATH no longer matches the unexpanded ~\studio\unsloth_studio root, so it is treated as an external HIP SDK and can re-enable the DiskPart-prone amd-smi path. Fresh evidence beyond the earlier custom-root concern is that the current helper now reads the custom env var but still omits the same ~ expansion performed by the later root resolver.
Useful? React with 👍 / 👎.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request prevents the virtual environment's internal hipInfo.exe from being mistaken for a genuine HIP SDK, which avoids triggering unnecessary amd-smi UAC prompts on Windows. It introduces path-filtering helpers in both PowerShell and Python, optimizes ROCm PyTorch installation for known architectures, adjusts the TORCHINDUCTOR_CACHE_DIR pathing, and removes redundant self-rename logic. The review feedback recommends replacing os.path.abspath with os.path.realpath in the Python _path_inside_venv helpers to correctly resolve symlinks and junctions, ensuring robust virtual environment path detection.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| try: | ||
| root = os.path.normcase(os.path.abspath(sys.prefix)) | ||
| return os.path.normcase(os.path.commonpath([os.path.abspath(path), root])) == root |
There was a problem hiding this comment.
Using os.path.abspath does not resolve symlinks or junctions. If sys.prefix or the hipinfo path contains symlinks or junctions (which is common in virtual environments), the path comparison might fail, causing _path_inside_venv to return False and incorrectly allowing amd-smi to run, which triggers the DiskPart UAC prompt. Using os.path.realpath ensures that both paths are fully resolved to their physical locations on disk before comparison.
| try: | |
| root = os.path.normcase(os.path.abspath(sys.prefix)) | |
| return os.path.normcase(os.path.commonpath([os.path.abspath(path), root])) == root | |
| try: | |
| root = os.path.normcase(os.path.realpath(sys.prefix)) | |
| return os.path.normcase(os.path.commonpath([os.path.realpath(path), root])) == root |
| try: | ||
| _root = os.path.normcase(os.path.abspath(sys.prefix)) | ||
| return os.path.normcase(os.path.commonpath([os.path.abspath(path), _root])) == _root |
There was a problem hiding this comment.
Using os.path.abspath does not resolve symlinks or junctions. If sys.prefix or the hipinfo path contains symlinks or junctions (which is common in virtual environments), the path comparison might fail, causing _path_inside_venv to return False and incorrectly allowing amd-smi to run, which triggers the DiskPart UAC prompt. Using os.path.realpath ensures that both paths are fully resolved to their physical locations on disk before comparison.
| try: | |
| _root = os.path.normcase(os.path.abspath(sys.prefix)) | |
| return os.path.normcase(os.path.commonpath([os.path.abspath(path), _root])) == _root | |
| try: | |
| _root = os.path.normcase(os.path.realpath(sys.prefix)) | |
| return os.path.normcase(os.path.commonpath([os.path.realpath(path), _root])) == _root |
| try: | ||
| _root = os.path.normcase(os.path.abspath(sys.prefix)) | ||
| return os.path.normcase(os.path.commonpath([os.path.abspath(path), _root])) == _root |
There was a problem hiding this comment.
Using os.path.abspath does not resolve symlinks or junctions. If sys.prefix or the hipinfo path contains symlinks or junctions (which is common in virtual environments), the path comparison might fail, causing _path_inside_venv to return False and incorrectly allowing amd-smi to run, which triggers the DiskPart UAC prompt. Using os.path.realpath ensures that both paths are fully resolved to their physical locations on disk before comparison.
| try: | |
| _root = os.path.normcase(os.path.abspath(sys.prefix)) | |
| return os.path.normcase(os.path.commonpath([os.path.abspath(path), _root])) == _root | |
| try: | |
| _root = os.path.normcase(os.path.realpath(sys.prefix)) | |
| return os.path.normcase(os.path.commonpath([os.path.realpath(path), _root])) == _root |
…nv filter Two review points on the amd-smi/DiskPart UAC gate: 1. _path_inside_venv compared os.path.abspath of sys.prefix and the hipInfo path, which does not resolve symlinks, junctions, or 8.3 short names. A venv reached through an aliased path then fails the check, so its bundled hipInfo.exe is mistaken for an external HIP SDK and amd-smi runs (the DiskPart prompt this fix exists to suppress). Switch to os.path.realpath in all three copies (amd.py, install_llama_prebuilt.py, install_python_stack.py). 2. setup.ps1's early venv-internal hipInfo probe seeded the venv root from a custom Studio home (UNSLOTH_STUDIO_HOME / STUDIO_HOME) without expanding a leading ~, while the canonical resolver does. With a tilde form, [IO.Path]::GetFullPath kept the literal ~ relative to cwd, so the custom-home hipInfo escaped the filter and reopened the gate. Expand ~ in the probe the same way as the resolver. tests/studio/install/test_pr5940_followups.py: 30 passed (adds a symlink realpath case and a setup.ps1 tilde-expansion guard).
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c5ed7f1e63
ℹ️ 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".
| @@ -2065,8 +2102,14 @@ exit 0 | |||
| $torchSpec = if ($ROCmTorchFloor) { $ROCmTorchFloor } else { "torch" } | |||
| $torchInstallExit = Invoke-InstallCommandRetry -Label "install PyTorch (AMD ROCm)" { uv pip install --python $VenvPython --force-reinstall --index-url $ROCmIndexUrl $torchSpec torchvision torchaudio } | |||
There was a problem hiding this comment.
Constrain ROCm companion wheels in install.ps1
When the new $ROCmGfxArch-only path is taken for Strix/RDNA4 hosts, $torchSpec caps torch at <2.12, but this install still leaves torchvision and torchaudio bare on AMD's per-arch --index-url. The setup.ps1 path in this same change adds matching companion ranges for these gfx115x/gfx120x installs because AMD publishes the packages independently; without mirroring those specs here, the bootstrap ROCm install can resolve or fail against an incompatible companion set and fall back to CPU before setup retries.
Useful? React with 👍 / 👎.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fa367d938a
ℹ️ 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".
| # Transient AMD-index failure: fall back to a CPU base so the install | ||
| # still completes; Studio setup retries ROCm afterwards. | ||
| substep "ROCm PyTorch install failed (exit $torchInstallExit); using a CPU base, Studio setup retries ROCm." "Yellow" | ||
| $torchInstallExit = Invoke-InstallCommandRetry -Label "install PyTorch (CPU fallback)" { uv pip install --python $VenvPython "torch>=2.4,<2.11.0" torchvision torchaudio --index-url $TorchIndexUrl } |
There was a problem hiding this comment.
Force the CPU fallback to replace partial ROCm wheels
When the ROCm install fails after leaving an unpinned ROCm torch in the venv (for example gfx110X/gfx90a where $ROCmTorchFloor is null and torch can be 2.10.0+rocm), this fallback does not force a reinstall. The CPU requirement torch>=2.4,<2.11.0 can still be satisfied by that ROCm build, so uv may keep ROCm torch while installing CPU companions, then $ROCmIndexUrl is cleared and the flavor-repair block will not fix the mismatch. Use --force-reinstall or explicit reinstall-package flags for the CPU torch/vision/audio triplet before clearing the ROCm expectation.
Useful? React with 👍 / 👎.
| fi | ||
| # Forward the caller's options/env (custom package/python/home) so the rerouted | ||
| # install matches what was asked for, not a default install. | ||
| _rr_q() { printf "'%s'" "$(printf '%s' "$1" | sed "s/'/'\\\\''/g")"; } |
There was a problem hiding this comment.
Quote rerouted arguments with embedded apostrophes
When a forwarded value contains a single quote (for example a custom UNSLOTH_STUDIO_HOME under a Windows user like O'Brien), _rr_q emits a malformed single-quoted shell word such as 'O'''Brien'. The rerouted bash -lc command then fails to parse, so this Strix Halo reroute falls back to CPU in the original unsupported distro instead of continuing in Ubuntu-24.04; escape apostrophes with a POSIX-safe single-quote sequence before wrapping the value.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Checked this one and it is already correct, so leaving _rr_q as is.
_rr_q produces POSIX-safe single-quote escaping. For O'Brien it emits 'O'\''Brien' (not 'O'''Brien'), and it round-trips under both dash/sh and bash:
O'Brien -> 'O'\''Brien'
a'b'c -> 'a'\''b'\''c'
/home/o'brien/Studio -> '/home/o'\''brien/Studio'
The sed s/'/'\''/g rewrites each apostrophe to a close-quote, escaped-quote, reopen-quote sequence before wrapping, so a forwarded value such as UNSLOTH_STUDIO_HOME with an apostrophe parses correctly in the rerouted bash -lc (the parse round-trips back to the original string). No change needed here.
| if wsl.exe -d "$_rr_target" -- bash -lc "$_rr_exports; $_rr_cmd"; then | ||
| exit 0 | ||
| fi |
There was a problem hiding this comment.
Propagate Tauri elevation exits from the rerouted installer
When this reroute runs with --tauri and the Ubuntu-24.04 child is missing apt packages, _smart_apt_install emits [TAURI:NEED_SUDO] and exits 2 so the Rust side can show the elevation flow. This wrapper treats every nonzero child exit as a reroute failure, then continues CPU-only in the original unsupported distro and can eventually exit 0, so the desktop app never gets the elevation status for the target distro and the GPU install is skipped; propagate exit 2 instead of falling through here.
Useful? React with 👍 / 👎.
…UDO from reroute install.ps1/setup.ps1: when the AMD ROCm wheel install fails and we fall back to a CPU base, force-reinstall the torch/vision/audio triplet. A failed ROCm install can leave an unpinned ROCm torch (e.g. 2.10.0+rocm on gfx110X/gfx90a) that still satisfies the CPU torch>=2.4,<2.11.0 range, so without --force-reinstall uv keeps the ROCm build and only swaps the companions -- a mismatched venv the flavor-repair block won't fix. setup.ps1 scopes the forced reinstall to the ROCm-fallback path () so the genuine CPU-only install stays fast. install.sh: the Strix Halo WSL reroute treated every nonzero child exit as a reroute failure and fell back to CPU. In --tauri mode the child uses exit 2 ([TAURI:NEED_SUDO]) to ask the desktop app to elevate for the target distro; capture the child's exit code and propagate exit 2 in Tauri mode (the child already printed the NEED_SUDO line) instead of masking it. CLI mode still falls back to CPU on a generic failure. Tests: reroute Tauri exit-2 propagation (and non-Tauri CPU-fallback) cases; run_func now preserves the child exit code; force-reinstall assertions for both PowerShell installers. Note: codex's _rr_q apostrophe finding is a false positive -- the helper already emits POSIX-correct 'O'\''Brien' and round-trips under both sh and bash.
|
@codex review |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! 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". |
…-diskpart-cache-rename
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
An if-expression assignment ($cpuForce = if ($ROCmCpuFallback) { @("--force-reinstall") })
collapses the single-element array to a scalar string, so @cpuForce splatting enumerated
it character-by-character into broken single-letter args (- - f o r c e ...), which made
uv/pip reject the install and aborted the whole Studio setup on the AMD ROCm->CPU fallback
path. Build $cpuForce as a real array assigned outside the if-expression so the splat passes
a single --force-reinstall arg. Genuine CPU-only installs stay fast (empty array, no flag).
Test now asserts the array-build form and rejects the if-expression form.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
…-diskpart-cache-rename
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
The isolated Node.js runtime (install_node_prebuilt.py, added with the managed-Node change) installs to ~/.unsloth/node in default mode -- a sibling of studio, so deleting <studio> leaves it behind (~200MB orphaned after uninstall). Both uninstallers already remove the other default-mode siblings (llama.cpp/.cache/.staging); add node alongside them. uninstall.ps1 also adds it to the handle-lock sweep so a held node.exe can't block the delete. Env/custom mode nests node under the custom root, removed with that root.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ 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". |
|
@codex review |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
Codex Review: Didn't find any major issues. 🚀 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". |
An on-device install run on a Strix Halo box (Radeon 8060S / gfx1151, Ryzen AI Max+ PRO 395) surfaced four installer issues. All four are fixed here.
1. DiskPart UAC prompt mid-install
amd-smi on Windows ships no usable CLI from any AMD product, and when spawned without a registered HIP runtime it auto-elevates and pops a DiskPart UAC prompt. amd-smi is already gated behind "is a HIP SDK present" (hipinfo on PATH, or under HIP_PATH/ROCM_PATH). The bug: the AMD torch wheel ships hipInfo.exe inside the venv, and the bitsandbytes fix prepends that venv Scripts dir to PATH so bnb can find it. shutil.which("hipinfo") then resolved the venv-internal hipInfo, flipped the gate to True, and the post-install AMD probe fell through to
amd-smi list. The install log confirms it: the arch came from the GPU-name table because the venv hipInfo could not report gcnArchName, so the probe kept going until it reached amd-smi.Fix: a hipinfo resolved inside the active venv (sys.prefix) is the torch-wheel binary, not a HIP SDK, so it no longer opens the gate. A real HIP SDK (hipinfo outside the venv, or HIP_PATH/ROCM_PATH set) still does. The venv exclusion is mirrored everywhere the probe runs: the Python installers (install_python_stack.py, install_llama_prebuilt.py), the runtime backend utils/hardware/amd.py (same latent prompt in the VRAM poller), and the PowerShell amd-smi probes in install.ps1 and setup.ps1. The containment check is normcased (Windows paths are case-insensitive), and the HIP_PATH/ROCM_PATH candidate is run through it too so a HIP_PATH pointing inside the venv does not reopen the gate.
2. TORCHINDUCTOR_CACHE_DIR on the drive root
Moved off the bare C:\tc drive root. When long paths are enabled, the inductor/Triton cache lives under \TORCHINDUCTOR_CACHE_DIR (inside the user's .unsloth\studio home); when long paths are not available it falls back to a short C:\tc to keep MAX_PATH headroom for the deep inductor filenames. The directory is created wildcard-safely.
3. Spurious "could not rename unsloth.exe ... pip may fail with WinError 32"
setup.ps1 used to rename the running unsloth.exe out of the way before the base-package upgrade so the package manager could replace it. That rename never actually worked: setup runs via unsloth.exe, so renaming our own running uv-trampoline launcher fails with a sharing violation (WinError 32). It only printed the alarming warning on every Windows install and update, then carried on.
It was also unnecessary. install_python_stack upgrades unsloth via uv (--upgrade-package); if uv cannot replace the locked launcher it falls back to pip, but the pip fallback drops --upgrade-package and base.txt lists only bare unsloth/unsloth-zoo, so pip finds them already satisfied and no-ops. The running unsloth.exe is left intact at its current version either way. In the install.ps1 flow SKIP_STUDIO_BASE=1 means the base is not reinstalled at all, so there is nothing to replace.
Removed the rename block and its failed-install restore block. This clears the false warning for all Windows devices (CPU, NVIDIA, AMD) in both the install and update flows.
Note on in-place self-upgrade: bumping unsloth while unsloth.exe is the running process is not reliable on Windows. uv pip install --reinstall aborts ("Access is denied", os error 5) and pip install --upgrade over the locked exe can fail with WinError 32 and leave the package half-uninstalled. So this PR does not attempt an auto-upgrade of the running launcher; it keeps the safe behavior (the update flow no-ops rather than replacing the locked exe, and the install flow does not touch the base at all). The supported upgrade path remains the installer one-liner (irm https://unsloth.ai/install.ps1 | iex), which runs from PowerShell where unsloth.exe is not the live process.
4. "Installing CPU PyTorch" confusion
When ROCm cannot be probe-verified at bootstrap (rocminfo/amd-smi/hipInfo unavailable, arch only name-inferred), install.ps1 lays down a CPU torch base and setup.ps1's own detection then installs the GPU ROCm wheels. The final install is GPU-accelerated. Clarified the bootstrap message and added an explicit "GPU ROCm PyTorch installed" confirmation after the AMD wheels land. For a known AMD arch the installer now goes straight to the ROCm wheels, skipping the CPU base entirely.
Tests and verification
Regression tests cover the venv-internal vs external hipInfo gate (venv-internal stays closed, external/HIP-SDK still opens), the HIP_PATH/ROCM_PATH cases, sys.prefix isolation in the gate helper, and the PowerShell venv exclusion. The full amd-smi gate suite passes (27 tests). Both PowerShell files parse clean.
Verified end-to-end on the Strix Halo box: install.ps1 --local from this branch completed exit 0, with no DiskPart prompt, no rename warning, the cache created under the Studio home, and "GPU ROCm PyTorch installed (gfx1151)". torch reports 2.11.0+rocm7.13.0 with cuda_avail True on AMD Radeon 8060S. Studio then booted and detected "ROCm (HIP 7.13.99004) -- AMD Radeon 8060S Graphics" with no runtime DiskPart prompt. A live gate check with the venv hipInfo on PATH (and even HIP_PATH set to the venv) keeps amd-smi disabled. GGUF inference (diffusiongemma-26B-A4B-it Q4_K_M, 31/31 layers offloaded) and a LoRA fine-tune (weights on cuda:0, ~676 MB VRAM, loss decreasing, zero amd-smi/diskpart spawns) both ran on the GPU with no DiskPart prompt.