Repository navigation
torchao alias tests: stop leaving a fake diffusers in sys.modules - #13336
Conversation
test_torchao_fqn_alias.py (from #13308) imports a fake diffusers package from tmp_path. monkeypatch.delitem records only entries that existed, so in an xdist worker where the real diffusers had not been imported yet, the fake one stayed in sys.modules and every later test in that worker saw a diffusers without AutoencoderKLWan or its pipelines: test_video_vae_bf16_decode_rocm, test_video_backend and test_train_precision_scheme_contract fail on main and on unrelated PRs (#13315). An autouse fixture now restores the diffusers/torchao entries of sys.modules exactly after every test. Also apply the ruff-format-with-kwargs hook to the two files #13308 added, which test_formatter_fixed_point flags on main.
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. |
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. |
|
@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". |
Problem
Two reds on main since #13308 landed. They show up on unrelated PRs, for example #13315 (rope scaling) and #13313 (packed documents):
(Python 3.13, rest):Repo tests (CPU, rest):test_formatter_fixed_pointflagsstudio/backend/core/_torchao_stub.pyandstudio/backend/tests/test_torchao_fqn_alias.py.The product change in #13308 is fine. The failure is a test leak in the new
test_torchao_fqn_alias.py. Two of its tests import a fakediffuserspackage fromtmp_path, after clearingdiffusers/torchaoentries withmonkeypatch.delitem.delitemonly records entries that existed. So in an xdist worker where the real diffusers had not been imported yet, nothing was recorded, and the fake package stayed insys.modulesafter the test. Every later test in that worker then imported that emptydiffusers.Reproduced on main by running the file ahead of the video tests in one process:
Fix
test_torchao_fqn_alias.pysnapshots everydiffusers*/torchao*entry insys.modulesbefore each test and restores it exactly afterwards. Entries added during the test are removed, and replaced or deleted ones come back.ruff-format-with-kwargshook on the two files Studio: fix image and video loads on torchao 0.14 (FqnToConfig import error with diffusers 0.41) #13308 added._torchao_stub.pychanges only in formatting (thefind_specsignature).Verification
scripts/run_ruff_format.py(ruff 0.6.9) leaves both files unchanged after this PR.