Skip to content

Studio tests: pin the torch probe invalidation contract to both installers - #8795

Merged
danielhanchen merged 3 commits into
mainfrom
studio-pin-torch-probe-invalidation
Aug 14, 2026
Merged

danielhanchen merged 3 commits into
mainfrom
studio-pin-torch-probe-invalidation

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

#8779 made pip_install_try() drop the memoized torch classification alongside pip_install(). It has to: it is what puts the Windows AMD ROCm trio on disk, so a memo it does not clear can answer for the build it just replaced.

That fix shipped without a test. Deleting the _invalidate_torch_runtime_probe() line from pip_install_try() leaves the whole suite green, which is the wrong state for a one-line invariant that nothing else enforces.

What this adds

Three tests, each of which fails with that line removed and passes with it:

  • test_pip_install_try_invalidates_the_cache, the mirror of the pip_install case that already existed
  • test_a_real_reinstall_is_really_reclassified, parametrised over both installers. Two real torch packages on disk, a real probe subprocess either side of a real call into the installer. The mocked version proves the memo was dropped; this proves the answer that replaces it comes from the venv as it is now. It also pins the half that must NOT change: while nothing has installed anything, swapping the package on PYTHONPATH does not move the answer.
  • test_every_installer_entry_point_invalidates, which reads the installer entry points out of the module with ast (the functions that call _build_pip_cmd / _build_uv_cmd) rather than listing them here. A third one cannot be added without either invalidating or failing this test, and the assertion says why.

Why the ast one is worth having

The memoization rests on "pip_install and pip_install_try are the only things here that change what is installed". That is true today and is not self-enforcing. Enumerating the entry points from the module means the test notices a new one instead of quietly not covering it.

Tests

tests/studio/install/ and tests/python/test_install_python_stack.py: 2606 passed. The three test_managed_node_runtime.py failures reproduce on main in this environment (they assume a particular UNSLOTH_STUDIO_HOME layout).

No production change in this PR.

danielhanchen and others added 3 commits August 14, 2026 08:19
…llers

#8779 made pip_install_try() drop the memoized torch classification, because it
installs the Windows AMD ROCm trio and a memo it does not clear can answer for
the build it just replaced. That fix shipped with no test: only pip_install()
was covered, so reverting the pip_install_try() line kept the suite green.

Three tests, each of which fails with that line removed:

- pip_install_try() drops the memo, mirroring the pip_install() case
- a real reinstall is really reclassified: two real torch packages on disk and a
  real probe subprocess either side of a real call into each installer, so the
  answer that replaces the memo is shown to come from the venv as it is now
  rather than from the mock that dropped it
- every function that builds a pip or uv install command invalidates. Read out
  of the module with ast rather than listed here, so a third installer helper
  cannot be added without either invalidating or failing this test

No production change.
Folds in the one test #8796 had that this branch did not. The other two
there duplicate what is already here, so #8796 closes in favour of this.

_select_torchao_spec reads _probe_installed_torch_version() between the
two repair points, which makes it the consumer that would actually read
a memo left over from before a reinstall, and pin torchao against the
torch that was just replaced. The existing cases assert on
_probe_torch_runtime directly; this one goes through the accessor that
the torchao path really calls.

Fails with the _invalidate_torch_runtime_probe() line removed from
pip_install_try, along with the three siblings, and passes with it.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: d5014c7c69

ℹ️ 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
danielhanchen merged commit cb07e02 into main Aug 14, 2026
20 of 28 checks passed
@danielhanchen
danielhanchen deleted the studio-pin-torch-probe-invalidation branch August 14, 2026 11:46
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.

1 participant