Fix ARM test listing failures caused by torch import at collection time (#20284)#20284
Fix ARM test listing failures caused by torch import at collection time (#20284)#20284Gasoonjia wants to merge 1 commit into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/20284
Note: Links to docs will display an error until the docs builds have been completed. ❌ 3 New FailuresAs of commit 93b32b3 with merge base e257a71 ( NEW FAILURES - The following jobs have failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@Gasoonjia has exported this pull request. If you are a Meta employee, you can view the originating Diff in D108630941. |
This PR needs a
|
…me (#20284) Summary: The `_set_random_seed()` call added to `pytest_configure()` in D108449705 imports torch during test collection, which triggers the `torch._dynamo` init chain. In `fbcode//mode/opt`, this crashes with `AttributeError: module 'torch' has no attribute '_utils'`, causing all ~180 ARM test listings to fail. Guard the early seed call with try/except. The per-test `set_random_seed` fixture still seeds before each test execution, so determinism is preserved. Differential Revision: D108630941
af2bd61 to
75040de
Compare
…me (#20284) Summary: The `_set_random_seed()` call added to `pytest_configure()` in D108449705 imports torch during test collection, which triggers the `torch._dynamo` init chain. In `fbcode//mode/opt`, this crashes with `AttributeError: module 'torch' has no attribute '_utils'`, causing all ~180 ARM test listings to fail. Guard the early seed call with try/except. The per-test `set_random_seed` fixture still seeds before each test execution, so determinism is preserved. Differential Revision: D108630941
75040de to
29611df
Compare
…me (#20284) Summary: The `_set_random_seed()` call added to `pytest_configure()` in D108449705 imports torch during test collection, which triggers the `torch._dynamo` init chain. In `fbcode//mode/opt`, this crashes with `AttributeError: module 'torch' has no attribute '_utils'`, causing all ~180 ARM test listings to fail. Guard the early seed call with try/except. The per-test `set_random_seed` fixture still seeds before each test execution, so determinism is preserved. Differential Revision: D108630941
29611df to
835d3e7
Compare
…me (#20284) Summary: The ~180 ARM test listings fail in `fbcode//mode/opt` during pytest collection with `AttributeError: module 'torch' has no attribute '_utils'`. Root cause: `torch._utils` is importable but is not bound as an attribute on the `torch` module, so importing `torch._dynamo` (pulled in via `executorch.exir` / `torchao` when a test module is collected) reads `torch._utils` directly and crashes the whole listing. This is independent of the seed call and of CinderX lazy imports (already disabled for these targets, verified at runtime). The previous version guarded the early seed with try/except, which neither set the seed internally nor actually fixed the listings (the crash originates in test-module collection, not the seed call). Fix: bind `torch._utils` explicitly in `_set_random_seed()`, which runs in `pytest_configure` before collection, and drop the try/except so the collection-time seeding from D108449705 is restored. The change is identical for OSS and internal (a no-op where `torch._utils` is already bound), which also addresses the reviewer ask to seed the same way for both. Verified in `fbcode//mode/opt`: fixes ~170/180 listings and re-enables the collection-time seed. Known follow-up (T275980003): ~10 targets that import `torchao.prototype.mx_formats` still fail on `torch.device` unbound during torchao's import-time device probing — a separate torch/torchao issue. Reviewed By: shoumikhin Differential Revision: D108630941
835d3e7 to
5419b2c
Compare
…me (#20284) Summary: The ~180 ARM test listings fail in `fbcode//mode/opt` during pytest collection with `AttributeError: module 'torch' has no attribute '_utils'`. Root cause: `torch._utils` is importable but is not bound as an attribute on the `torch` module, so importing `torch._dynamo` (pulled in via `executorch.exir` / `torchao` when a test module is collected) reads `torch._utils` directly and crashes the whole listing. This is independent of the seed call and of CinderX lazy imports (already disabled for these targets, verified at runtime). The previous version guarded the early seed with try/except, which neither set the seed internally nor actually fixed the listings (the crash originates in test-module collection, not the seed call). Fix: bind `torch._utils` explicitly in `_set_random_seed()`, which runs in `pytest_configure` before collection, and drop the try/except so the collection-time seeding from D108449705 is restored. The change is identical for OSS and internal (a no-op where `torch._utils` is already bound), which also addresses the reviewer ask to seed the same way for both. Verified in `fbcode//mode/opt`: fixes ~170/180 listings and re-enables the collection-time seed. Known follow-up (T275980003): ~10 targets that import `torchao.prototype.mx_formats` still fail on `torch.device` unbound during torchao's import-time device probing — a separate torch/torchao issue. Reviewed By: shoumikhin Differential Revision: D108630941
5419b2c to
93b32b3
Compare
Summary:
The ~180 ARM test listings fail in
fbcode//mode/optduring pytestcollection with
AttributeError: module 'torch' has no attribute '_utils'.Root cause:
torch._utilsis importable but is not bound as an attribute onthe
torchmodule, so importingtorch._dynamo(pulled in viaexecutorch.exir/torchaowhen a test module is collected) readstorch._utilsdirectly and crashes the whole listing. This is independent ofthe seed call and of CinderX lazy imports (already disabled for these targets,
verified at runtime).
The previous version guarded the early seed with try/except, which neither set
the seed internally nor actually fixed the listings (the crash originates in
test-module collection, not the seed call).
Fix: bind
torch._utilsexplicitly in_set_random_seed(), which runs inpytest_configurebefore collection, and drop the try/except so thecollection-time seeding from D108449705 is restored. The change is identical
for OSS and internal (a no-op where
torch._utilsis already bound), whichalso addresses the reviewer ask to seed the same way for both.
Verified in
fbcode//mode/opt: fixes ~170/180 listings and re-enables thecollection-time seed.
Known follow-up (T275980003): ~10 targets that import
torchao.prototype.mx_formatsstill fail ontorch.deviceunbound duringtorchao's import-time device probing — a separate torch/torchao issue.
Reviewed By: shoumikhin
Differential Revision: D108630941