Repository navigation
[inductor][test] Keep the Inductor cache dir off sys.path in subprocess tests - #205060
georgehong wants to merge 1 commit into
Conversation
…ss tests Summary: The subprocess tests in `test/inductor/test_gpu_cpp_wrapper.py` ran with their Inductor cache dir as the working directory, which Python puts first on `sys.path`, so a cache entry directory could shadow a real module. Depending on the generated code's hashes, an entry such as `z3/` can shadow the `z3` package, which made `test_lazy_compile_kernel_name_collision_across_modules` fail with pytorch#199309 in some environments. Keep the cache in an `inductor_cache/` subdirectory instead. Test-only change. Test Plan: CI Differential Revision: D132158104
PR Status: Approved 🚀Please fix all CI failures and trigger merge by commenting "@pytorchbot merge". ✅ AUTOMATED REVIEW - Ready for human review:
Findings (2): Reviewed commit: 🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/205060
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 5dc11ca with merge base 3886d18 ( 🟢 GREEN LIGHT - PR approved to be merged without human review:
reason: This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@georgehong has exported this pull request. If you are a Meta employee, you can view the originating Diff in D132158104. |
There was a problem hiding this comment.
Automated review of 5dc11ca: nothing blocking; ready for human review.
Three subprocess tests in test/inductor/test_gpu_cpp_wrapper.py now run from a temp directory and keep the Inductor cache in a <tmp>/inductor_cache subdirectory, so cache entries stay off the child's sys.path. Recommendation: Approve. The review calls the fix correct and complete, and both of its points are non-blocking: one on comment wording, one on style.
⚪ 2 non-blocking findings
pytorch/test/inductor/test_gpu_cpp_wrapper.py
Line 1067 in 5dc11ca
Non-blocking: the new comment and the PR description get the failure mechanism slightly wrong. The comment says a cache subdirectory such as z3/ "would shadow that module". Cache subdirs (codecache.py get_path, basename\[1:3\]) have no __init__.py, so Python can only treat them as namespace-package portions. The path finder picks a regular package anywhere on sys.path over a namespace portion, so an installed z3 still wins and nothing is shadowed. The real failure happens when z3 is not installed: import z3 returns an empty namespace package instead of raising ImportError. torch/fx/experimental/validator.py:30 then gets past its try: import z3 guard and raises AttributeError at line 66 on z3.ExprRef, which the except ImportError at line 651 doesn't catch. Suggested wording: "a cache subdir such as z3/ would import as an empty namespace package, defeating try: import z3 / except ImportError checks."
pytorch/test/inductor/test_gpu_cpp_wrapper.py
Line 1287 in 5dc11ca
Non-blocking: mixed path styles. cache_dir is built with os.path.join and the next line builds script_path with Path(tmp_dir) / .... Using one style for both lines would read more uniformly.
This review is AI-generated and advisory. Each new automated review replaces the previous one. Report a bad review
|
@pytorchbot merge (Initiating merge automatically since Phabricator Diff has merged) |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Summary: The subprocess tests in
test/inductor/test_gpu_cpp_wrapper.pyran with their Inductor cache dir as the working directory, which Python puts first onsys.path, so a cache entry directory could shadow a real module. Depending on the generated code's hashes, an entry such asz3/can shadow thez3package, which madetest_lazy_compile_kernel_name_collision_across_modulesfail with #199309 in some environments. Keep the cache in aninductor_cache/subdirectory instead. Test-only change.Test Plan: CI
Differential Revision: D132158104
cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben @jataylo