Repository navigation
[Testcase Refactoring] Make test_bad_lowering device-agnostic via instantiate_device_type_tests - #198358
[Testcase Refactoring] Make test_bad_lowering device-agnostic via instantiate_device_type_tests#198358gavinwang269 wants to merge 1 commit into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/198358
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (4 Unrelated Failures)As of commit 1243bfc with merge base be43976 ( FLAKY - The following jobs failed but were likely due to flakiness present on trunk:
UNSTABLE - The following jobs are marked as unstable, possibly due to flakiness on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
|
|
@pytorchbot label "module: tests/graph" |
5a50a79 to
753ab4d
Compare
|
|
@claude review these changes |
|
Claude finished @jansel's task in 59s —— View job This PR moves Full reviewPR Review: #198358SummaryThe PR moves Code Quality
Testing
RecommendationRequest Changes. Fix the whitespace so lint passes, and update the PR description to match the commit. |
Rebased onto latest main: the Device-class scaffold already exists (merged via pytorch#198361), so this piece is a pure method move. Signed-off-by: gavinwang269 <[email protected]> Signed-off-by: gavinwang269 <[email protected]>
753ab4d to
1243bfc
Compare
|
Fixed the blank-line findings (E301 + extra blank before instantiate). Body updated: it now describes the actual diff — a pure method move with the scaffold already on |
…device migrations Rebased onto latest main (scaffold + migrated debuginfo from pytorch#198361 are kept). Drops the seven methods whose device versions arrive in the parallel move pieces pytorch#198354 (test_bad_decomp), pytorch#198355 (test_joint_graph), pytorch#198356 (test_rng), pytorch#198357 (test_emulate_precision_casts), pytorch#198358 (test_bad_lowering), pytorch#198359 (test_bisect_pre_grad_graph) and pytorch#198360 (test_cudagraph_bisect_max); keeps test_pre_grad, test_crossref and test_eager_backend. Marks the remaining class GENERIC, renames test_ns to bisector_ns (a class attribute named test_* would otherwise be collected by instantiate_device_type_tests), slims tearDown and removes get_lib. Must merge LAST in the series, only after every sibling move above has landed; otherwise the deleted GPU tests lose their replacements. Also fixes the lint failures on the previous revision: removes imports that are unused at this point in the series (contextmanager, import_module, _prims_common, preserve_rng_state, module-level config) and normalizes the blank-line runs left by the method removals. These imports are intentionally not kept for the siblings; each move piece brings back exactly what it uses. Signed-off-by: gavinwang269 <[email protected]>
|
@pytorchbot merge -i |
Merge startedYour change will be merged while ignoring the following 2 checks: inductor / unit-test / inductor-cpu-test / test (inductor_aoti_fallback, 1, 2, mt-l-x86iamx-8-64, unstable), inductor / unit-test / inductor-cpu-test / test (inductor_aoti_fallback, 2, 2, mt-l-x86iamx-8-64, unstable) Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
…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
…isector class Re-derived on top of merged reality. The original revision of this PR also dropped seven methods (bad_decomp, joint_graph, rng, emulate_precision_casts, bad_lowering, bisect_pre_grad_graph, cudagraph_bisect_max) whose device-agnostic replacements arrive in sibling PRs, and declared the remaining class GENERIC. Since then only pytorch#198358 (test_bad_lowering) and pytorch#198361 (test_bisect_run_debuginfo) have landed: deleting the still-present six methods now would remove their only coverage before their replacements merge, and labeling the class GENERIC would be wrong while six GPU-bound tests remain under its HAS_GPU gate. Those parts are therefore obsolete-after-merge / premature and were dropped from this PR. What remains valid independently of the sibling series: - Rename the class attribute test_ns -> bisector_ns. An attribute whose name starts with the "test" prefix is a latent test-collection footgun (it would be picked up by instantiate_device_type_tests or prefix-based loaders). - Remove get_lib(), which is dead code after pytorch#198358 (no callers left), together with the Library import and the self.lib teardown it required. Authored with an AI assistant. Signed-off-by: gavinwang269 <[email protected]>
…isector class Re-derived on top of merged reality. The original revision of this PR also dropped seven methods (bad_decomp, joint_graph, rng, emulate_precision_casts, bad_lowering, bisect_pre_grad_graph, cudagraph_bisect_max) whose device-agnostic replacements arrive in sibling PRs, and declared the remaining class GENERIC. Since then only pytorch#198358 (test_bad_lowering) and pytorch#198361 (test_bisect_run_debuginfo) have landed: deleting the still-present six methods now would remove their only coverage before their replacements merge, and labeling the class GENERIC would be wrong while six GPU-bound tests remain under its HAS_GPU gate. Those parts are therefore obsolete-after-merge / premature and were dropped from this PR. What remains valid independently of the sibling series: - Rename the class attribute test_ns -> bisector_ns. An attribute whose name starts with the "test" prefix is a latent test-collection footgun (it would be picked up by instantiate_device_type_tests or prefix-based loaders). - Remove get_lib(), which is dead code after pytorch#198358 (no callers left), together with the Library import and the self.lib teardown it required. Authored with an AI assistant. Signed-off-by: gavinwang269 <[email protected]>
…antiate_device_type_tests (#198355) ## Summary Move `test_joint_graph` 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` (+36 -38): - `test_joint_graph` moves verbatim (body unchanged) into `TestCompilerBisectorDevice`, which `instantiate_device_type_tests(..., except_for="cpu", allow_xpu=True)` instantiates; the hardcoded `device=GPU_TYPE` becomes the injected `device` argument. - Drop the now-redundant in-method `from torch._inductor import config` (the module is imported at file scope). - Update the `CustomPostPass.uuid()` string to name `TestCompilerBisectorDevice` after the move (keeps the pass identity meaningful and unique). - The method-level `@unittest.skipIf(not has_triton(), ...)` on the moved test was removed as a duplicate of the class-level decorator of `TestCompilerBisectorDevice`. - The base class itself is untouched here; the GENERIC declaration belongs to #198360 alone (review note). ## 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` 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`, so this PR is a pure single-method move. Triton gating for `TestCompilerBisectorDevice` lives on the class-level `@unittest.skipIf(not has_triton(), ...)` decorator, the convention already used on `main`; a fully device-aware gate needs a Triton `Capability` in the registry (follow-up). ## Test Plan - CPU (`env-pytorch-2.16-20261029-cpu` venv, `pytest --collect-only`): 11 tests collected on the rebased branch; the moved test now instantiates only for accelerator devices. Re-measured after the follow-up edits: still 11. - NPU real hardware (Ascend 910B4, CANN 9.2.0 GA, `env-pytorch-2.16-20261029-npu` venv with torch_npu 737bb43 + triton-ascend 3.6.0): `pytest -k test_joint_graph_npu` -> **1 passed (32.2s, re-measured after this round's edits)**; previously this test never executed on NPU. - `lintrunner` (includes in-tree TEST_LINTER): no issues, re-run after this round's edits. Rebased onto latest main after #198358 landed; the class-level Triton gate arrives with #198357 and this PR will inherit it on the next rebase. ## Dependencies Part of the #191435 split series (#198353 ~ #198362); independent of its siblings, each moves one test method. Pull Request resolved: #198355 Approved by: https://github.com/lizhihai137, https://github.com/jansel
…antiate_device_type_tests (pytorch#198355) ## Summary Move `test_joint_graph` 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` (+36 -38): - `test_joint_graph` moves verbatim (body unchanged) into `TestCompilerBisectorDevice`, which `instantiate_device_type_tests(..., except_for="cpu", allow_xpu=True)` instantiates; the hardcoded `device=GPU_TYPE` becomes the injected `device` argument. - Drop the now-redundant in-method `from torch._inductor import config` (the module is imported at file scope). - Update the `CustomPostPass.uuid()` string to name `TestCompilerBisectorDevice` after the move (keeps the pass identity meaningful and unique). - The method-level `@unittest.skipIf(not has_triton(), ...)` on the moved test was removed as a duplicate of the class-level decorator of `TestCompilerBisectorDevice`. - The base class itself is untouched here; the GENERIC declaration belongs to pytorch#198360 alone (review note). ## 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` 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`, so this PR is a pure single-method move. Triton gating for `TestCompilerBisectorDevice` lives on the class-level `@unittest.skipIf(not has_triton(), ...)` decorator, the convention already used on `main`; a fully device-aware gate needs a Triton `Capability` in the registry (follow-up). ## Test Plan - CPU (`env-pytorch-2.16-20261029-cpu` venv, `pytest --collect-only`): 11 tests collected on the rebased branch; the moved test now instantiates only for accelerator devices. Re-measured after the follow-up edits: still 11. - NPU real hardware (Ascend 910B4, CANN 9.2.0 GA, `env-pytorch-2.16-20261029-npu` venv with torch_npu 737bb43 + triton-ascend 3.6.0): `pytest -k test_joint_graph_npu` -> **1 passed (32.2s, re-measured after this round's edits)**; previously this test never executed on NPU. - `lintrunner` (includes in-tree TEST_LINTER): no issues, re-run after this round's edits. Rebased onto latest main after pytorch#198358 landed; the class-level Triton gate arrives with pytorch#198357 and this PR will inherit it on the next rebase. ## 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#198355 Approved by: https://github.com/lizhihai137, https://github.com/jansel
Summary
Move
test_bad_loweringfrom theHAS_GPU-guardedTestCompilerBisectorinto the existing device-instantiatedTestCompilerBisectorDeviceintest/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_loweringmoves verbatim (body unchanged) intoTestCompilerBisectorDevice, which#198361already set up andinstantiate_device_type_tests(..., except_for="cpu", allow_xpu=True)instantiates; the hardcodeddevice=GPU_TYPEbecomes the injecteddeviceargument.Motivation
The class guard
@unittest.skipIf(not HAS_GPU, ...)treatsHAS_GPU = HAS_CUDA_AND_TRITON or HAS_XPU_AND_TRITON or HAS_MTIA_AND_TRITON, so out-of-tree accelerators registered viaPrivateUse1(e.g., Ascend NPU) skip the whole class even though this test only needs a generic accelerator.instantiate_device_type_testswithexcept_for="cpu"covers all registered non-CPU device types, andhw_classificationmetadata enables--hw-classificationfiltering.Notes
The shared scaffold (new class + instantiation) is already on
mainvia #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 bytest_bisect_run_debuginfoonmain; a fully device-aware gate needs a TritonCapabilityin the registry (follow-up).Test Plan
torch-2.15-cpu, pytest --collect-only): 9 tests collected, identical tomainbaseline;pytest -q-> 9 skipped (guard unchanged on CPU).torch-2.15-npu, triton-ascend):pytest -k test_bad_lowering_npu-> 1 passed (previously this test never executed on NPU).pycodestyle --select E3clean;ruff format --diffshows no findings in the touched region.Dependencies
Part of the #191435 split series (#198353 ~ #198362); independent of its siblings, each moves one test method.
cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @kadeng @chauhang @amjames @jataylo @azahed98 @FFrog