Skip to content

Studio tests: the dynamo knob reset must not read the cache_size_limit alias (teardown errors since #18080) - #18097

Merged
danielhanchen merged 1 commit into
mainfrom
ci-dynamo-knob-fixture-no-imports
Nov 17, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
ci-dynamo-knob-fixture-no-imports

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Since #18080 the Studio CPU shards (rest, g-l, m-r) error at teardown on any worker that imported torch._dynamo earlier. Seen on the staging runs of #18003, #18080 and #18090, e.g.:

ERROR at teardown of test_torchao_export_rejected_early_when_stubbed[torchao_fp8]
  torch/overrides.py:1778: has_torch_function = _add_docstr(
  RuntimeError: function '_has_torch_function' already has a docstring
ERROR at teardown of test_versions_are_checked_before_imports
  AssertionError: imported a package the version check already rejected
ERROR at teardown of test_a_broken_torch_import_is_retried_once_per_detection_epoch
  OSError: libcudart.so.12: cannot open shared object file

Cause

The _restore_dynamo_process_knobs fixture from #18080 snapshots and restores cache_size_limit. On torch 2.6+ that entry is an alias of recompile_limit, and torch resolves an alias read with importlib.import_module("torch._dynamo.config"). Several tests take torch out of sys.modules and block imports to exercise the no-torch paths (test_torchao_select.py, test_mlx_stack_blockers.py, test_polled_probe_costs.py, test_warm_window_review_fixes.py, test_hub_download_transport_auto.py, test_mlx_repair.py). The fixture teardown runs before their monkeypatches are undone, so the alias read re-imported torch under the blocker.

Those tests are correct, and the reset itself is still wanted; only the alias read was wrong.

Fix

_dynamo_own_knobs(cfg) keeps only the config's own entries (_config[k].alias is None). Restoring recompile_limit already covers cache_size_limit on new torch, and on older torch, where cache_size_limit is a real entry, it is still restored. Reading an own entry never imports.

New test_conftest_teardown_imports_nothing.py imports torch._dynamo, takes torch out of sys.modules and makes importlib.import_module fail for torch, so any conftest teardown that imports torch errors.

Verification

Run locally with torch._dynamo already imported on the worker, as in CI:

  • main conftest: 14 teardown errors across test_torchao_select.py, test_mlx_stack_blockers.py, test_polled_probe_costs.py, test_warm_window_review_fixes.py, test_hub_download_transport_auto.py and test_mlx_repair.py (the CI ones), and the new test errors too.
  • this branch: all pass (196 and 188 passed in the two runs).
  • test_process_state_reset_between_tests.py still passes, so the knob reset still works.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 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-17T07:04:17.976754Z 1f717c7 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 1f717c78c3

ℹ️ 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 387b150 into main Nov 17, 2026
@danielhanchen
danielhanchen deleted the ci-dynamo-knob-fixture-no-imports branch November 17, 2026 07:05
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