Repository navigation
Stop the torchao ROCm test from depending on the host's GPU - #10099
Conversation
test_skips_torchao_on_windows_rocm described a machine that cannot exist: a Windows host with ROCm torch installed AND a usable NVIDIA GPU. The NVIDIA claim is the input _expected_torch_flavor_tag uses to decide whether a CUDA expectation exists at all, so the test asked for a cu* build on a box it had just called ROCm. That was inert until #9857 added the Windows torch flavor invariant, which is the first step in install_python_stack to read the real installed torch. With a CUDA expectation manufactured by the test and the CPU-only torch that studio-backend-ci.yml installs, the invariant correctly refused the install and returned 1, so a test about torchao selection failed on an assertion about the whole installer. It passed on a CUDA workstation and failed on CI, on the same code. The invariant is right and stays as it is: on a real Windows ROCm host _has_usable_nvidia_gpu is False, the expected tag is empty, and the step returns early, so no ROCm user is affected. It is the fixture that was wrong. The host is now coherent (no NVIDIA GPU), and the installed torch is pinned through _probe_torch_runtime and _RECORDED_TORCH_TAG so the verdict no longer depends on whatever torch the developer happens to have. #9857's invariant keeps its own coverage in tests/studio/install/test_windows_torch_flavor_invariant.py. Also adds the (True, True) case. Both signals agreeing is the ordinary Windows ROCm state and the parametrization only covered the two mixed ones.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f2c79361b9
ℹ️ 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".
| # Checked BEFORE the install so a regression names its cause here rather than as | ||
| # an opaque `assert 1 == 0` on the line below, which is how this surfaced: the run | ||
| # returned 1 on a CPU-only runner and 0 on a CUDA workstation, on identical code. | ||
| assert mod._expected_torch_flavor_tag() == "", ( |
There was a problem hiding this comment.
Clear ambient torch-selection variables before asserting
When the suite is run with a supported torch selection variable already exported, this assertion remains environment-dependent: _expected_torch_flavor_tag() checks UNSLOTH_EXPECTED_TORCH_TAG, UNSLOTH_TORCH_INDEX_URL, and UNSLOTH_TORCH_INDEX_FAMILY before the newly patched GPU/manifest inputs. In particular, setup.ps1 exports UNSLOTH_EXPECTED_TORCH_TAG=rocm for its normal Windows ROCm handoff, while a developer may run tests with an explicit family such as cu128; either makes this assertion fail despite identical code. Delete or explicitly set these variables in the fixture (or model the ROCm handoff) so the test is actually isolated from its host environment.
Useful? React with 👍 / 👎.
fastmcp 4.0.0 released today and dropped FastMCP._call_tool_mcp, so this test started failing with AttributeError on every CI run that resolved the dependency fresh. The pin is an open fastmcp>=3.0.2, so nothing held CI on 3.x. Nothing in the product is affected: every fastmcp import the backend actually makes still resolves on 4.0.0, and the whole backend suite is green there apart from this one test. So the pin is fine and only the test needs to change. Switch to get_tool/call_tool, which are public and carry the same signatures on 3.0.2 (the floor) and on 4.0.0, and drop the server._mask_error_details assertion. That flag was a stand-in for "the 409 detail reaches the caller", which the two message assertions below it already prove directly, so the check cost a private attribute and bought nothing. Verified against real installs of both 3.0.2 and 4.0.0.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ccdd0a9258
ℹ️ 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".
| monkeypatch.setattr(mod, "_RECORDED_TORCH_TAG", "") | ||
| monkeypatch.setattr( | ||
| mod, "_probe_torch_runtime", lambda *args, **kwargs: (True, True, "2.9.1+cpu", "", "") | ||
| ) |
There was a problem hiding this comment.
Stub the final core-payload gate in this installer test
On a clean backend test runner where the unsloth distribution is not installed, these new stubs still do not isolate the test from ambient package state. Since SKIP_STUDIO_BASE=1 prevents the core package from being installed, the final install_python_stack() call reaches _repair_damaged_core_payload(..., require_present=True), returns false for the absent distribution, and still produces the failing assert 1 == 0. Stub _repair_damaged_core_payload to return true here, as with the other unrelated installer side effects.
Useful? React with 👍 / 👎.
test_skips_torchao_on_windows_rocmis failing on main. It fails on CI and passes on a CUDA workstation, on identical code.Why
The fixture describes a machine that cannot exist: a Windows host with ROCm torch installed and a usable NVIDIA GPU.
That second flag is exactly the input
_expected_torch_flavor_taguses to decide whether a CUDA expectation exists at all:So the test asked for a
cu*build on a box it had just called ROCm.That was inert until #9857 added the Windows torch flavor invariant (step 13w), the first step in
install_python_stackthat reads the real installed torch. Combined with the CPU-only torchstudio-backend-ci.ymlinstalls, the invariant correctly refused the install and returned 1, so a test about torchao selection failed on an assertion about the whole installer:Reproduced by pinning the probe to the CPU torch CI installs: with the NVIDIA flag
Truethe installer emits "PyTorch is CPU-only but a cu126 GPU build was expected for this machine" and returns 1; with itFalseit returns 0 and the torchao assertions hold.#9857 is correct and is unchanged
On a real Windows ROCm host
_has_usable_nvidia_gpu()is False, so the expected tag is empty and the invariant returns early. No ROCm user is affected, and a Windows box that expected a GPU build but holds CPU-only torch should fail the install rather than report success. The fixture was wrong, not the code.What changed
_probe_torch_runtimeand_RECORDED_TORCH_TAG, so the verdict no longer depends on whichever torch the developer happens to have. This is what made it green locally and red on CI._expected_torch_flavor_tag() == ""runs before the install, so the next time a later step reaches back into real hardware the failure names its cause instead of surfacing asassert 1 == 0.(True, True)case. Both signals agreeing is the ordinary Windows ROCm state and the parametrization only covered the two mixed ones.No coverage is lost: #9857's invariant keeps its own tests in
tests/studio/install/test_windows_torch_flavor_invariant.py.Verification
studio/backend/tests/test_torchao_select.py: 30 passed (29 before, plus the new case).CUDA_VISIBLE_DEVICES="", where it used to be host-dependent.tests/studio/install/+tests/python/test_install_python_stack.py: 3460 passed, 3 skipped._has_usable_nvidia_gpu -> Truereproduces the original CI failure, and the new precondition reports it with the reason.