Repository navigation
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0184f2c618
ℹ️ 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 "$VENV_DIR/bin/python" -c \ | ||
| 'import importlib.util,sys; sys.exit(0 if importlib.util.find_spec("torch") else 1)' \ | ||
| >/dev/null 2>&1; then |
There was a problem hiding this comment.
Skip the torch health probe in no-torch mode
When an AMD installation is converted to GGUF-only mode but retains a torch package from the prior installation, this existence check still runs the new health diagnostic. A stale CPU wheel then produces the kernel-driver/group-membership warning, while a usable ROCm wheel reports a healthy PyTorch GPU, even though UNSLOTH_NO_TORCH or the persisted manifest intentionally disables the training stack. Fresh evidence here is that the new summary probe ignores the same no-torch state now honored by reconciliation; gate this probe and its messaging on that recorded mode.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Declining this one. setup.sh has no notion of no-torch mode anywhere today, so this would mean introducing a manifest read into the shell purely to suppress a message, and only on an install that was converted to GGUF-only and still carries a wheel from before. Worth doing as its own change rather than inside this branch.
|
Thanks for this, and sorry for the long review. The two bugs you are fixing are both real and both worth fixing: the fast path really does keep a CPU or CUDA wheel on an AMD host indefinitely while printing I reviewed this on three fronts: the detection rewrite, the reinstall trigger, and the Windows manifest inference. There is no AMD hardware on any runner or on my box, so everything below is fixture-driven or driven against the real code with stubs, and I have said which is which. Nothing here is a claim about observed AMD behaviour. Ground truth used rather than recollection: Blockers1. An unimportable torch reads as "not ROCm", so the repair never converges
Driven against the real CLI with a stub torch package, a fake
Exit 0 sets The failure mode I care about more:
Suggestion: record the attempted plan (index, wheel state, timestamp) in the manifest and refuse to repeat an identical plan that did not help. 2. A deliberate CPU or CUDA wheel is overwritten, because the pin guards read environment variables that are gone by update timeThe only "the user chose otherwise" guards are Measured on a fake AMD host with a stub So the GGUF-only half of the PR description holds and is durable, because Suggestion: persist the resolved index URL and backend at install time and consult those here, the way 3.
|
|
Two corrections to my review above, both mine, and one of them is unfair to you. 1. The Windows manifest section describes code you had already removed. I fetched the diff while Measured at
No latch, nothing written back, nothing wired into the damaged-install hint. Please disregard that whole section. You had already reached the right answer on your own. 2. "
Separating the HSA clear (4) from the install (0), with 5 for both, is also exactly right, and it answers the coupling concern I raised. The abort risk did not vanish, it moved: once a repair is triggered, What I still think is live, all re-derived at Masked NVIDIA, That last one needs no env var at all, and it is the ordinary shape of a container. The early return concedes the host before the Torch that does not answer, "Did not answer" is being read as "is not ROCm". Nothing records that a repair was attempted, so where the reinstall does not take, this recurs on every update. The 90 second cell is its own cost on the path that exists to be fast. Unsupported arches, where the repair installs a wheel that cannot run:
Deliberate non-ROCm wheels. Worth narrowing what I said before: a ROCm pin is durable, because the installed wheel carries One new finding. The marketing-name fallback, which I can now give you the exact reachability path for rather than just the symptom. The
Also worth a line in the PR description, not a defect: And the part I would sign off on as-is: the Both bugs you set out to fix are real, and the name bug in particular was one nobody else had pinned down. I am taking the remaining items on directly rather than leaving them with you. |
The fast-path probe classifies a torch that segfaults, raises or hangs on import as a wrong wheel rather than a broken one, so the repair re-arms on every `studio update` and force-reinstalls several GB that cannot help. Under setup.sh's `set -euo pipefail` a repair that cannot reach download.pytorch.org turns a succeeding update into a guaranteed abort. - _probe_rocm_torch reports importability separately from the ROCm marker. - Record the attempted repair (index plus observed torch state, hashed) beside the no-torch marker, before running it, and refuse to repeat an identical one. The key covers the observed state, so a repair that changed anything is never blocked, and convergence clears the record. - Persist an explicit UNSLOTH_TORCH_INDEX_URL / _FAMILY pin in the install manifest and consult it, so a deliberate CPU or CUDA index on an AMD host survives an update that does not re-export the variable. The autodetected UNSLOTH_TORCH_BACKEND is deliberately not persisted. - Split NVIDIA presence from NVIDIA visibility: a CUDA_VISIBLE_DEVICES mask no longer authorises replacing a working CUDA torch on a host that owns an NVIDIA card. The mask's routing role from unslothai#6183 is unchanged. - rocminfo lists the CPU agent first, so the marketing-name fallback preferred the processor even when a GPU agent was present (unslothai#7307). Classify the agent before latching, and read field values past the first colon so a name containing ": " is not truncated. Both copies stay byte identical. - Seed HSA_ENABLE_DXG_DETECTION and the /opt/rocm/bin PATH append above the probe, so the repairing half and the reporting half judge the same hardware.
|
I pushed the fixes for the four blockers directly to your branch rather than leaving you a list to work through, since Your two diagnoses were both right and both worth the PR. The fast path really does keep a CPU or CUDA wheel on an AMD host indefinitely while printing Corrections to my own review firstBlocker 3 was not your bug and I should not have filed it against this PR. The What your PR does change is the blast radius: detection now runs before the fast path, so that policy can force-reinstall on every update instead of only during a dependency pass. So I fixed the destructive half only. NVIDIA presence and NVIDIA visibility are now separate probes, and a mask no longer authorises replacing a working CUDA torch on a host that owns an NVIDIA card. The routing behaviour from #6183 is untouched: a CPU wheel, a ROCm wheel or a broken torch on that same host is still repaired exactly as before. Blocker 2, I persisted less than I proposed. I suggested recording the resolved index URL and the backend. Recording the backend turns out to be unsafe: What changed1. An unimportable torch no longer re-arms the repair forever. This also closes the 2. A deliberate CPU or CUDA pin survives an update. 3. The marketing-name fallback can no longer name the CPU. This was your headline bug and the fix still contained it. While in there I also took the 4. The repair half and the reporting half now see the same machine. Verification23 new tests, all in your Counts, run serially:
Because a test that cannot fail is not coverage, I mutated the source to revert each claimed behaviour and confirmed the tests caught it, both directions on every guard. 24 mutations, 24 killed, 0 survivors. Two survived the first pass and both were informative: one showed an importability term in the CUDA guard was redundant, since a CUDA local tag is only readable from a torch that imported, so I removed it rather than keep an untestable condition; the other was a malformed mutation of mine, not a weak test. The awk helper was also run under gawk, mawk and busybox awk, since arm order and function support are the kind of thing that only breaks on the shell nobody develops on. Left alone deliberatelyThe unsupported-iGPU allowlist (gfx1103, gfx90c, gfx1036, gfx803 all still return rc=0), the amd-smi ordinal mismatch, and the Windows manifest inference. The first two want their own change with their own tests, and the third protects a population small enough that I would rather discuss it than quietly rewrite it in your branch. None of them are regressions from this PR. Everything I listed as clean in the review is still clean and I did not touch any of it: the anchored gfx regex, rocminfo ordinal alignment, the Please do look over the diff, especially the repair-ledger semantics, since that is the piece that decides when Studio stops trying. If you would rather own any of it differently, say so and I will back it out. As I mentioned, I will cut #8620 down to its Windows half so the two do not both emit the same warning. |
A suppressed repeat repair was reported as a satisfied wheel, so _ensure_rocm_torch cleared the repair ledger and the next update re-armed the same multi-gigabyte reinstall, and a confirmed HSA override was removed even though the per-architecture wheel it stands in for was never installed. Both now travel as an explicit blocked plan. Also carry the recorded torch index pin across the dependency pass that drops the manifest, store it without index credentials, and apply the confirmed HSA override clear in the setup shell after a forced pass, not only on the fast path.
main gained the shared torch classification (unslothai#8779). It rewrote the same Linux ROCm block this branch moved into _linux_rocm_torch_plan(), so the two conflict textually while wanting the same thing. Kept this branch's plan structure and carried unslothai#8779 into it rather than either side wholesale: - _probe_rocm_torch() reads _probe_torch_runtime() instead of spawning its own interpreter. Its four values are a subset of the shared five, and a private probe would restore both the extra "import torch" and the extra independent 90s timeout on exactly the wedged-driver host this path exists to rescue. - The classification parity guard from unslothai#8779 fired on the move, which is what it is for. Re-checked the equivalence against the same reference implementation and retargeted it at _probe_rocm_torch, where the derivation now lives, rather than assuming it across the rename. - The fast-path source guard now asserts the bounded import where it moved to, and additionally fails if the fast path ever spawns its own subprocess again. - Probe mocks feed the shared marked line and drop the memo first. tests/studio/install: 2687 passed, 2 skipped. Both retargeted guards were mutation-tested: breaking the marker derivation fails 4 parity cases, and reintroducing a private subprocess fails 3 reconciliation cases.
|
Merged main and resolved the conflict, pushed as The conflict is with #8779, which landed the shared torch classification. It rewrote the same Linux ROCm block this branch moved into I kept this branch's plan structure and carried #8779 into it, rather than taking either side wholesale. The part worth flagging: #8779's classification parity guard fired on the move, which is what it is for. I re-checked the equivalence against the same reference implementation it cites and retargeted it at
|
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b3142a91ae
ℹ️ 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".
| _repaired_is_rocm, _, _, _ = _probe_rocm_torch() | ||
| if _repaired_is_rocm: | ||
| install_manifest.clear_rocm_repair_attempt() | ||
| rocm_torch_ready = True |
There was a problem hiding this comment.
Keep a non-ROCm repair result marked unready
When pip_install exits successfully but the selected index or mirror supplies a non-HIP torch wheel, the new re-probe correctly leaves the repair ledger in place, but this assignment still marks the environment ROCm-ready. The branches below then install AMD bitsandbytes—or perform the gfx906 bitsandbytes cleanup—against the CPU/CUDA wheel that the probe just rejected. Set readiness from _repaired_is_rocm so a semantically failed repair does not trigger ROCm-only package changes.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not taking this one.
That assignment is main's behavior, not something this branch introduces. On origin/main (cb8e206) install_python_stack.py sets rocm_torch_ready = True unconditionally at the end of the generic install (line 3245), and the gfx906 bitsandbytes cleanup (:3251) and the AMD bitsandbytes install (:3273) read that same flag. What this PR adds after pip_install is the re-probe, and only to settle the repair ledger.
The change would also lose a case the repair exists for. _probe_rocm_torch reports has_rocm False both for a wrong wheel and for a torch that cannot be imported at all, and a wedged HIP runtime is the host this path was written to rescue. Reading readiness off _repaired_is_rocm there would skip the AMD bitsandbytes install on a venv that just received the correct ROCm wheels.
That leaves the case you name: a leaf _is_pip_rocm_family_leaf accepts, served by a mirror that publishes non-HIP wheels. Pairing the AMD bitsandbytes wheel with an already-wrong torch there is not worth a branch that breaks the unimportable-torch host.
| @pytest.fixture(autouse = True) | ||
| def _isolate_torch_routing_env(monkeypatch): | ||
| """Run every install test against an unset routing environment. |
There was a problem hiding this comment.
Clear no-torch mode before test-module import
When the test runner exports UNSLOTH_NO_TORCH=1, install_python_stack.py computes its module-level NO_TORCH while test modules are collected, before this autouse fixture can sanitize the environment. The new _linux_rocm_torch_plan then returns immediately in existing direct _ensure_rocm_torch tests; in this environment the targeted install suite regresses from passing at the parent commit to 26 failures. Clear this variable before test-module imports or explicitly reset the imported modules' NO_TORCH state in the fixture.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in a43dda9. tests/studio/install/conftest.py now pops UNSLOTH_NO_TORCH at module scope and recomputes install_python_stack.NO_TORCH, since a whole-tree run can already have imported the module from another directory before this conftest loads. The per-test fixture cannot reach it, exactly as you describe: NO_TORCH is read once during collection.
install_python_stack reads the variable once at module scope into NO_TORCH, so for a test module the value is frozen during collection, before any fixture can run. A shell that exports it (install.sh does) then returns every routing plan early and the suite fails on the environment rather than on the code: 45 failures against 3 on Ubuntu 24.04. Popped in the conftest rather than added to _ROUTING_ENV_VARS, because a per-test fixture cannot undo an import-time read. The constant is recomputed as well, since a whole-tree run collects other directories first and may already have imported it.
|
Merged main, and took the conftest finding.
Measured on Ubuntu 24.04, Diffing the failure sets rather than the counts: 42 eliminated, 0 introduced. The 3 survivors are I did not take the Main merge is 181 commits, 737 files, no conflicts. Also worth knowing for merge order: this branch and the Windows one don't conflict, so a merge won't flag anything, but the merged @oobabooga @danielhanchen probably best if you both review the findings above before this goes anywhere, particularly the one I declined. |
|
@codex review |
|
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". |
|
Confirmed the first Marketing Name from rocminfo is still the CPU agent in install.sh, and nothing on the update path checks the venv torch against the GPU it just announced, so this is worth fixing. The direction is right, but the branch also narrows the ROCm index leaf test to a fixed family allowlist and adds the reinstall fingerprint, so could you split those out? @LeoBorcherding could you take a look at this one? |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2106bae141
ℹ️ 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".
| _ROUTING_ENV_VARS = ( | ||
| "UNSLOTH_ROCM_GFX_ARCH", | ||
| "HSA_OVERRIDE_GFX_VERSION", | ||
| "HIP_VISIBLE_DEVICES", | ||
| "CUDA_VISIBLE_DEVICES", | ||
| "UNSLOTH_ROCM_TORCH_INSTALLED", | ||
| "ROCM_PATH", | ||
| # install.sh exports this, so a suite run from an installer shell would assert the | ||
| # fresh-install branch of the recorded-pin guards instead of the update one. | ||
| "UNSLOTH_INSTALLER_RESOLVED_TORCH_INDEX", | ||
| ) |
There was a problem hiding this comment.
Clear the module-level torch backend before collection
When UNSLOTH_TORCH_BACKEND=cpu, cuda, or xpu is exported in the test environment, install_python_stack.py captures it in _TORCH_BACKEND during collection, before this autouse fixture runs, and this routing-variable list neither clears the environment value nor recomputes the module constant. I verified that UNSLOTH_TORCH_BACKEND=cpu python -m pytest -q tests/studio/install/test_rocm_support.py tests/studio/install/test_cuda_repair.py tests/studio/install/test_gpu_detection_followups.py produces 28 routing failures because the ROCm helpers return early. Sanitize this module-level variable before test imports and reset _TORCH_BACKEND, as is already done for NO_TORCH above.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Reproduced. Before the fix, UNSLOTH_TORCH_BACKEND=cpu took tests/studio/install/test_rocm_support.py, test_cuda_repair.py and test_gpu_detection_followups.py from 617 passed to 28 failed. The sensitivity is not introduced here (the merge base fdf83cb fails 27 of them the same way), but the isolation fixture this branch adds is what is meant to cover this class, and install.sh exports the variable next to UNSLOTH_NO_TORCH.
Fixed in b324496. The derivation moved into _infer_torch_backend() so the conftest can recompute the constant the way it already does for NO_TORCH, rather than forcing it to "": UNSLOTH_TORCH_INDEX_URL and UNSLOTH_TORCH_INDEX_FAMILY still feed it and those are deliberately left set. Those three files now give 618 passed, 16 skipped under cpu, cuda and xpu alike, and a regression test asserts both module constants match a recompute from the sanitized environment.
The same commit points TestTorchBackendDerivationFromPin at _infer_torch_backend() instead of its own copy of the derivation, which had already drifted: the copy was missing the xpu arm.
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Hooray! 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". |
Summary
On Linux AMD systems, Studio could report a healthy ROCm GPU while its venv contained a CPU or CUDA build of PyTorch. The dependency fast path then kept that wheel indefinitely, leaving training unavailable even though setup printed
dependencies up to date.The GPU name could also be wrong because
rocminfolists the CPU first and the installer used the firstMarketing Nameit found.Changes
torch.cuda.is_available()is false. The probe is bounded so a broken HIP runtime cannot hang setup.Before:
After, when PyTorch cannot use the GPU:
Chat and GGUF inference continue to work through llama.cpp. This PR does not change the Live monitor wording or persist the detected gfx architecture.
Testing
tests/studio/install/,tests/python/test_cross_platform_parity.py,tests/python/test_windows_no_torch_setup.pyandtests/studio/test_cli_hsa_spoof_launch_7331.py.tests/sh/pass.UNSLOTH_TORCH_BACKENDset tocpu,cudaorxpuand withUNSLOTH_NO_TORCH=1, which is what an installer shell exports.bash -n install.shbash -n studio/setup.shgit diff --checkRelated: #8473, #7307, #7275, #7485.