Skip to content

torchao alias tests: stop leaving a fake diffusers in sys.modules - #13336

Merged
danielhanchen merged 1 commit into
mainfrom
ci-torchao-alias-test-leak
Oct 11, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
ci-torchao-alias-test-leak

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Problem

Two reds on main since #13308 landed. They show up on unrelated PRs, for example #13315 (rope scaling) and #13313 (packed documents):

  1. Backend CI (Python 3.13, rest):
    ERROR tests/test_video_vae_bf16_decode_rocm.py::test_default_casts_only_the_decode_half_and_matches_fp32[auto]
    E   AttributeError: module 'diffusers' has no attribute 'AutoencoderKLWan'
    FAILED tests/test_video_backend.py::test_validate_gates_base_repo_and_local_paths
    
  2. Repo tests (CPU, rest): test_formatter_fixed_point flags studio/backend/core/_torchao_stub.py and studio/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 fake diffusers package from tmp_path, after clearing diffusers / torchao entries with monkeypatch.delitem. delitem only 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 in sys.modules after the test. Every later test in that worker then imported that empty diffusers.

Reproduced on main by running the file ahead of the video tests in one process:

pytest tests/test_torchao_fqn_alias.py tests/test_video_vae_bf16_decode_rocm.py tests/test_video_backend.py tests/test_train_precision_scheme_contract.py
8 failed, 514 passed, 1 skipped, 8 errors

Fix

Verification

Same order, one process main this PR
alias tests, then the video / precision tests 8 failed, 8 errors 530 passed, 1 skipped

scripts/run_ruff_format.py (ruff 0.6.9) leaves both files unchanged after this PR.

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.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-11T20:28:57.597400Z 182aa85 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 Summary

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

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-11T20:26:58.570706Z 182aa85 PR opened
ℹ️ 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. Keep them coming!

Reviewed commit: 182aa85470

ℹ️ 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".

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