Skip to content

Warm-window tests: reset the cached torch import failure around every test (order-dependent red) - #18867

Merged
danielhanchen merged 1 commit into
mainfrom
fix/warm-window-torch-import-state
Nov 22, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
fix/warm-window-torch-import-state

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

studio/backend/tests/test_warm_window_review_fixes.py::test_an_absent_torch_is_still_just_absent fails whenever torch has not been imported earlier in the process. It failed on the staging cross-platform leg for #18727 (ubuntu-latest), and it fails on main when the file runs on its own:

AssertionError: a --no-torch install would be reported as a detection failure
assert 'stale' is None
 +  where 'stale' = <module 'utils.hardware.hardware'>.TORCH_IMPORT_ERROR

_has_torch() (since #14595) remembers a failed import for the current detection epoch: while TORCH_IMPORT_ERROR is set, _TORCH_IMPORT_FAILED_EPOCH == DETECTION_EPOCH and torch is not in sys.modules, it returns False without trying again. The code is right. The tests are wrong: test_a_broken_torch_install_is_not_reported_as_a_host_without_a_gpu, just above, records a failure (setting both globals) and then restores only TORCH_IMPORT_ERROR. The epoch it leaves behind makes the next _has_torch() short-circuit, so the absent-torch test never reaches the import it checks. In the full CI run some earlier test has usually imported torch, which disables the short-circuit, so this has been order dependent rather than always red.

Fix

An autouse fixture in that file sets TORCH_IMPORT_ERROR and _TORCH_IMPORT_FAILED_EPOCH to None through monkeypatch, so every test starts with no cached failure and both are restored afterwards. No production code changes.

Testing

  • studio/backend/tests/test_warm_window_review_fixes.py on its own: 100 passed (main: 1 failed, the test above).

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-22T09:37:15.129866Z 16885c9 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 16885c92f7

ℹ️ 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 3a719a5 into main Nov 22, 2026
@danielhanchen
danielhanchen deleted the fix/warm-window-torch-import-state branch November 22, 2026 11:26
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