Repository navigation
[Testcase Refactoring] Make _test_compiler_bisector_run_helper.py device-agnostic - #198353
gavinwang269 wants to merge 1 commit into
Conversation
PR Status: Approved 🚀Please fix all CI failures and trigger merge by commenting "@pytorchbot merge". ✅ AUTOMATED REVIEW - OUTDATED (earlier commit) - Ready for human review:
Findings (1): Reviewed commit: 🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/198353
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit d510cba with merge base efe07ed ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
|
|
@pytorchbot label "module: tests/graph" |
c1d6072 to
83e9a48
Compare
…tantiate_device_type_tests (#198358) ## Summary Move `test_bad_lowering` from the `HAS_GPU`-guarded `TestCompilerBisector` into the existing device-instantiated `TestCompilerBisectorDevice` in `test/dynamo/test_compiler_bisector.py`, so it runs on out-of-tree accelerators instead of being skipped. Split from #191435 (refactoring this file for out-of-tree accelerator support). ## Changes `test/dynamo/test_compiler_bisector.py` (+19 -18): - `test_bad_lowering` moves verbatim (body unchanged) into `TestCompilerBisectorDevice`, which `#198361` already set up and `instantiate_device_type_tests(..., except_for="cpu", allow_xpu=True)` instantiates; the hardcoded `device=GPU_TYPE` becomes the injected `device` argument. ## Motivation The class guard `@unittest.skipIf(not HAS_GPU, ...)` treats `HAS_GPU = HAS_CUDA_AND_TRITON or HAS_XPU_AND_TRITON or HAS_MTIA_AND_TRITON`, so out-of-tree accelerators registered via `PrivateUse1` (e.g., Ascend NPU) skip the whole class even though this test only needs a generic accelerator. `instantiate_device_type_tests` with `except_for="cpu"` covers all registered non-CPU device types, and `hw_classification` metadata enables `--hw-classification` filtering. ## Notes The shared scaffold (new class + instantiation) is already on `main` via #198361, so this PR is a pure single-method move. Triton gating keeps the existing device-blind `@unittest.skipIf(not has_triton(), ...)` convention already used by `test_bisect_run_debuginfo` on `main`; a fully device-aware gate needs a Triton `Capability` in the registry (follow-up). ## Test Plan - CPU (`torch-2.15-cpu`, pytest --collect-only): 9 tests collected, identical to `main` baseline; `pytest -q` -> 9 skipped (guard unchanged on CPU). - NPU real hardware (Ascend 910B4, CANN 9.1.0, `torch-2.15-npu`, triton-ascend): `pytest -k test_bad_lowering_npu` -> **1 passed** (previously this test never executed on NPU). - `pycodestyle --select E3` clean; `ruff format --diff` shows no findings in the touched region. ## Dependencies Part of the #191435 split series (#198353 ~ #198362); independent of its siblings, each moves one test method. Pull Request resolved: #198358 Approved by: https://github.com/guilhermeleobas
…tantiate_device_type_tests (pytorch#198358) ## Summary Move `test_bad_lowering` from the `HAS_GPU`-guarded `TestCompilerBisector` into the existing device-instantiated `TestCompilerBisectorDevice` in `test/dynamo/test_compiler_bisector.py`, so it runs on out-of-tree accelerators instead of being skipped. Split from pytorch#191435 (refactoring this file for out-of-tree accelerator support). ## Changes `test/dynamo/test_compiler_bisector.py` (+19 -18): - `test_bad_lowering` moves verbatim (body unchanged) into `TestCompilerBisectorDevice`, which `pytorch#198361` already set up and `instantiate_device_type_tests(..., except_for="cpu", allow_xpu=True)` instantiates; the hardcoded `device=GPU_TYPE` becomes the injected `device` argument. ## Motivation The class guard `@unittest.skipIf(not HAS_GPU, ...)` treats `HAS_GPU = HAS_CUDA_AND_TRITON or HAS_XPU_AND_TRITON or HAS_MTIA_AND_TRITON`, so out-of-tree accelerators registered via `PrivateUse1` (e.g., Ascend NPU) skip the whole class even though this test only needs a generic accelerator. `instantiate_device_type_tests` with `except_for="cpu"` covers all registered non-CPU device types, and `hw_classification` metadata enables `--hw-classification` filtering. ## Notes The shared scaffold (new class + instantiation) is already on `main` via pytorch#198361, so this PR is a pure single-method move. Triton gating keeps the existing device-blind `@unittest.skipIf(not has_triton(), ...)` convention already used by `test_bisect_run_debuginfo` on `main`; a fully device-aware gate needs a Triton `Capability` in the registry (follow-up). ## Test Plan - CPU (`torch-2.15-cpu`, pytest --collect-only): 9 tests collected, identical to `main` baseline; `pytest -q` -> 9 skipped (guard unchanged on CPU). - NPU real hardware (Ascend 910B4, CANN 9.1.0, `torch-2.15-npu`, triton-ascend): `pytest -k test_bad_lowering_npu` -> **1 passed** (previously this test never executed on NPU). - `pycodestyle --select E3` clean; `ruff format --diff` shows no findings in the touched region. ## Dependencies Part of the pytorch#191435 split series (pytorch#198353 ~ pytorch#198362); independent of its siblings, each moves one test method. Pull Request resolved: pytorch#198358 Approved by: https://github.com/guilhermeleobas
83e9a48 to
c68a193
Compare
|
@pytorchbot label "ciflow/trunk" |
|
The ciflow label(s) ciflow/trunk will be added, but CI won't be triggered until the workflows are approved (scroll to the bottom of this page). Please ping one of the reviewers if you do not have access to approve and run workflows. |
There was a problem hiding this comment.
Automated review of dfeb275: nothing blocking; ready for human review.
The PR makes test/dynamo/_test_compiler_bisector_run_helper.py device-agnostic: the parent test now passes its device on the subprocess command line, and the helper's test_fn(device) uses it in place of GPU_TYPE. Recommendation: Approve. One non-blocking cleanup remains, and every maintainer request has been addressed at HEAD.
⚪ 1 non-blocking finding
pytorch/test/dynamo/test_compiler_bisector.py
Line 217 in dfeb275
Non-blocking: an env var is set but never read. The patch.dict at line 206 still sets "TORCH_BISECT_TEST_DEVICE": device, but nothing in the tree reads that variable. The helper now gets the device from sys.argv\[1\], and torch/_inductor/compiler_bisector.py only reads TORCH_BISECT_BACKEND, TORCH_BISECT_SUBSYSTEM and TORCH_BISECT_MAX. # 198361 added the variable for the env-var design of this helper, and this PR dropped that design. Line 206 is unchanged code, but this PR is what makes it permanently dead. If it stays, the device has two channels and only one of them works, and a reader may assume the helper still uses the env var. That is the kind of implicit state fffrog asked to avoid, and the PR description says the PR removes it. Fix: delete line 206 and keep only TORCH_BISECT_BACKEND in the patch.dict.
This review is AI-generated and advisory. Each new automated review replaces the previous one. Report a bad review
|
@fffrog could you take another look? Your requested changes were against
The PR is now +5/-4 across the two files (helper 4/4, bisector 1/0), and each of your four inline threads has been answered there and resolved since the head moved past them. One thing this PR also needs from someone with permission: the CI workflows for this fork head have been sitting at |
|
Re-review request for the current head All four points from @fffrog's review are implemented in Review re-requested — thanks! |
…-agnostic via an explicit device argument Summary The run_debuginfo bisector test spawns this helper in a subprocess, and the helper picked its device from the module-level GPU_TYPE global. Per review, the device now arrives as an explicit argument: the instantiated test passes its device on the subprocess command line, the helper reads sys.argv[1], and the GPU_TYPE import is gone with its last user. The helper's own revision history (a module-level probe) is fully reverted in favor of this shape, keeping accelerator state out of globals. Test Plan - python test/dynamo/_test_compiler_bisector_run_helper.py cpu: exits 1 (nan detected through the bad decomposition) exactly as the in-process equivalent; the subprocess leg itself runs on the device shards. - pytest --collect-only test/dynamo/test_compiler_bisector.py: 11 tests, unchanged; lintrunner clean on both files.
dfeb275 to
d510cba
Compare
NoteThe recent consistently-failing CI job is not caused by this PR's changes; the PR diff is exactly what was reviewed.
|
|
@pytorchbot merge |
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 |
Merge failedReason: 3 mandatory check(s) failed. The first few are: Dig deeper by viewing the failures on hud |
|
@pytorchbot merge |
|
@pytorchbot merege |
|
❌ 🤖 pytorchbot command failed: Try |
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
Make
test/dynamo/_test_compiler_bisector_run_helper.pydevice-agnostic by passing the device in explicitly: the parent test appends its instantiateddeviceto the subprocess command line, the helper'stest_fn(device)uses it for the tensor allocation, and theGPU_TYPEimport is gone with its last user.Split from #191435 (refactoring the compiler-bisector tests for out-of-tree accelerator support).
Changes (+5 -4, two files)
test/dynamo/_test_compiler_bisector_run_helper.py:test_fn()takes adeviceparameter,device=GPU_TYPEbecomesdevice=device,__main__passessys.argv[1], and theGPU_TYPEimport is removed.test/dynamo/test_compiler_bisector.py: thetest_bisect_run_debuginfosubprocess call passesdeviceas the final command-line argument (one added line, per review).Earlier revisions of the helper (an env-var + accelerator-probe design) were reverted entirely per review: keeping accelerator selection out of module globals and out of implicit environment state.
Test Plan
python test/dynamo/_test_compiler_bisector_run_helper.py cpuexits 1 (the bad decomposition still produces NaN through the compiled path), matching the in-process equivalent; the subprocess leg runs on the device shards.pytest --collect-only test/dynamo/test_compiler_bisector.py: 11 tests, unchanged.cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @kadeng @chauhang @amjames @jataylo @azahed98 @ipiszy @muchulee8 @aakhundov @coconutruben