Repository navigation
[Testcase Refactoring] Split test_cudagraph_bisect_max into a CUDA-classified test class - #198360
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) - Changes requested:
Findings (3): Reviewed commit: 🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/198360
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 78146ef with merge base 921ec49 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
|
|
@pytorchbot label "module: tests/graph" |
|
Hi @fffrog — thanks for the detailed review! To frame it: this PR is one slice of the orthogonal split for #191435 and converts
Two class-level points, where the series design differs slightly from the literal suggestion — please sanity-check:
|
8c2487e to
16bd2c2
Compare
5f705a5 to
c01298e
Compare
…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 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. |
|
@pytorchbot rerun |
|
❌ 🤖 pytorchbot command failed: Try |
c284836 to
30a9331
Compare
There was a problem hiding this comment.
Automated review of 9e81acb: changes requested before human review.
The PR moves test_cudagraph_bisect_max into a new CUDA-only TestCompilerBisectorCuda class, marks TestCompilerBisector GENERIC without its HAS_GPU gate, switches the Triton gates to device-aware skipIf, and removes the file from the test-linter allowlist. Recommendation: Request Changes, because test_rng lost its PrivateUse1 skip and now fails on PrivateUse1 and HPU backends, and its comment is now false.
🔴 1 blocking finding is attached to the code below.
⚪ 2 non-blocking findings
pytorch/test/dynamo/test_compiler_bisector.py
Line 379 in 9e81acb
Non-blocking: the Triton gate on test_cudagraph_bisect_max lists an XPU entry that can never apply, and its check is less precise than the rest of the file. TestCompilerBisectorCuda is instantiated only_for="cuda", so "xpu" never matches, and listing it contradicts the comment saying XPU doesn't support cudagraphs. common_device_type.py:1737 says to prefer existing decorators over the device_type kwarg, so @ skipCUDAIf(not has_triton(), ...) is the idiomatic form. Also, has_triton() is true if any accelerator has Triton. The sibling class's per-device has_triton_for_device(self.device_type) is more precise.
Non-blocking: the Test Plan in the PR description doesn't describe HEAD. It reports "10 collected / 10 skipped: [6] requires GPU and Triton, [4] requires Triton" and says no test IDs move, but that skip string no longer exists at HEAD. The test ID also moves: TestCompilerBisector.test_cudagraph_bisect_max becomes TestCompilerBisectorCudaCUDA.test_cudagraph_bisect_max_cuda. With the HAS_GPU gate removed, the 3 TestCompilerBisector tests now run on CPU-only hosts instead of skipping. Nothing posted shows test_pre_grad, test_crossref and test_eager_backend passing on CPU, including the macOS and Windows CPU shards. Please update the plan with a run at HEAD.
Please address the findings and push; a new commit normally gets a fresh automated review.
Disagree with a finding? Reply with your reasoning, then comment @pytorchbot review to request a re-review. This review is AI-generated and advisory. Each new automated review replaces the previous one. Report a bad review
Withdrawn: this PR opted out of automated review.
…ssified class Summary test_cudagraph_bisect_max needs CUDA graphs, so it does not belong in the accelerator-wide TestCompilerBisector class. This moves it into a class of its own, classified for CUDA and instantiated through instantiate_device_type_tests. With the move (and pytorch#198354/pytorch#198355 having landed), TestCompilerBisector holds only device-agnostic tests, so it gains the GENERIC classification and drops the import-time HAS_GPU gate along with the now-unused GPU_TYPE/HAS_GPU and requires_cuda imports; the Triton gates that remain become accelerator-aware @skipIf(..., device_type=...) forms, and as the last PR touching this file the test-linter allowlist entry is removed. Review-round decisions on pytorch#198360. The automated review noted that test_rng, after losing @skipPRIVATEUSE1, now runs and fails on PrivateUse1/HPU and asked to restore a skip via a setUp gate; the human maintainer instructed the opposite on the same lines (discussion_r4533004167): expose the test to all out-of-tree accelerators and let a backend that does not support it skip it in its own instantiation rather than have upstream silently skip it. The maintainer instruction wins: no upstream gate is added for other backends, and the stale comment block claiming PrivateUse1 is "skipped explicitly" is removed with nothing replacing it, so no comment asserts a skip that does not happen. The measured consequence, stated plainly: on an Ascend 910B4 (torch_npu, triton-ascend installed) test_rng_npu now runs and fails because preserve_rng_state (torch/_dynamo/utils.py) saves/restores only CPU, CUDA and XPU RNG, so the eager and compiled draws diverge and do_bisect reports backend="eager". Coverage delta is skip -> fail on backends that do not preserve RNG state; the out-of-tree test suite is expected to opt out. Style: the Triton gate on test_cudagraph_bisect_max drops the "xpu" entry per the maintainer's suggestion (the class is instantiated only_for="cuda", so the entry can never match). only_for="cuda" itself is kept: Rule 4's only_for ban is scoped to ACCELERATOR classes, Rule 5 imposes no instantiation requirements on CUDA-classified classes, and the in-tree linter's OnlyForRule is registered for ACCELERATOR only (checked by running the linter plus a deliberate-violation probe to confirm the finding fires where it should). Test Plan torch 2.16.0.dev20261029; the "cpu" venv autoloads torch_npu (registers PrivateUse1), so CPU-only claims use TORCH_DEVICE_BACKEND_AUTOLOAD=0. All pytest runs from /tmp with absolute paths. CPU-only host, final state: TORCH_DEVICE_BACKEND_AUTOLOAD=0 python -m pytest -q -rs test/dynamo/test_compiler_bisector.py -> collected 3 (test_pre_grad, test_crossref, test_eager_backend), 3 passed so the 3 GENERIC tests run and pass on a GPU-less host now that the HAS_GPU gate is gone. (Linux only; the macOS/Windows CPU shards are left to CI.) Same file on a host with PrivateUse1 registered: collected 10 vs 11 for the stock file; the moved test is not instantiated where no CUDA device type exists (on CUDA builds it is TestCompilerBisectorCudaCUDA.test_cudagraph_bisect_max_cuda). Whole file: python -m pytest -q -rs <file> # final: 1 failed, 3 passed, 6 skipped python -m pytest -q -rs <stock> # base commit version: 11 skipped, 0 failed The one failure is TestCompilerBisectorRNGNPU.test_rng_npu with AssertionError: String comparison failed: 'eager' != 'inductor', i.e. the intended exposure above (stock skipped it via the class-level Triton gate on this no-triton venv and via @skipPRIVATEUSE1 on the NPU machine); the 6 skips are the pre-existing per-device "requires Triton on npu" gates. NPU machine (8x Ascend 910B4, triton-ascend installed), final state: python -m pytest -q -rs test/dynamo/test_compiler_bisector.py -k test_rng -> 1 failed, 9 deselected (the bisect leg diverges on RNG as above; the inductor leg additionally hits a pre-existing torch_npu wheel codegen crash, reproduced with a plain torch.compile of the same function and unrelated to this change). Pre-PR the same command skips with "test doesn't work on privateuse1 backend". Lint: python tools/linter/adapters/test_linter.py test/dynamo/test_compiler_bisector.py -> no findings (allowlist entry removed; a deliberate ACCELERATOR only_for violation makes it emit exactly the [only_for] finding) lintrunner test/dynamo/test_compiler_bisector.py tools/linter/adapters/test_linter_allowlist.json -> ok No lint issues. Not covered here: the CUDA legs (no NVIDIA hardware on this host); the upstream hardware shards run those.
9e81acb to
78146ef
Compare
|
@pytorchbot review |
|
The automated review only re-runs on PRs labeled |
|
Both requested changes are implemented in
Ready for re-review whenever convenient. If you would rather have torch_npu's CI opt this variant out through a companion change on that side, say the word and I will prepare it. One more thing this PR needs from someone with permission: the fork CI workflows on head |
|
Re-review request for the current head Both of @fffrog's comments are applied at this head: the Triton gate on Review re-requested — thanks! |
|
@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 |
… into its own CUDA-classified class First independent slice of the static-launcher split (per pytorch#198436 review: the unit class mixes device-gated tests with a GENERIC label; original monolith pytorch#198437 at 505 lines). Moves test_tensor_memory_autotuner_retries_without_pipelining (CUDAAutotuner + StaticallyLaunchedCudaKernel internals, Triton-gated and RoCm- skipped) into a new CUDA-classified class TestStaticTritonLauncherUnitCuda -- not instantiated, since running CUDA-internal mock behavior under XPU/PrivateUse1 class variants would produce meaningless duplicates (the shape flagged in pytorch#198359/pytorch#198360 review). Shared helpers stay on the unit class, delegated by reference (staticmethod-wrapped); nothing is copied.
…ified class Independent slice of the static-launcher split: moves test_global_scratch_allocation, test_fast_launcher_rejects_global_scratch (skipIfRocm) and test_rocm_rejects_global_scratch (ROCm-only) out of the unit class into TestStaticTritonLauncherUnitRoCm, classified CUDA and intentionally not instantiated (mock CUDA/ROCm-internal behavior duplicated across device classes would be meaningless -- the shape flagged in pytorch#198359/pytorch#198360 review). Scratch-kernel factory delegated by reference; nothing copied; no dependency on sibling slices.
…ified class Independent slice of the static-launcher split: moves test_global_scratch_allocation, test_fast_launcher_rejects_global_scratch (skipIfRocm) and test_rocm_rejects_global_scratch (ROCm-only) out of the unit class into TestStaticTritonLauncherUnitCUDA (renamed from a RoCm-specific name since the class is classified CUDA and its bodies exercise CUDA/ROCm launcher internals through mocks), intentionally not instantiated (mock CUDA/ROCm-internal behavior duplicated across device classes would be meaningless -- the shape flagged in pytorch#198359/pytorch#198360 review). Scratch-kernel factory delegated by reference; nothing copied; no dependency on sibling slices. Test Plan: ```bash python -m pytest test/inductor/test_static_triton_launcher.py --collect-only -q # 24/60 tests collected, renamed class present ```
…ified class Independent slice of the static-launcher split: moves test_global_scratch_allocation, test_fast_launcher_rejects_global_scratch (skipIfRocm) and test_rocm_rejects_global_scratch (ROCm-only) out of the unit class into TestStaticTritonLauncherUnitCUDA (renamed from a RoCm-specific name since the class is classified CUDA and its bodies exercise CUDA/ROCm launcher internals through mocks), intentionally not instantiated (mock CUDA/ROCm-internal behavior duplicated across device classes would be meaningless -- the shape flagged in pytorch#198359/pytorch#198360 review). Scratch-kernel factory delegated by reference; nothing copied; no dependency on sibling slices. Test Plan: ```bash python -m pytest test/inductor/test_static_triton_launcher.py --collect-only -q # 24/60 tests collected, renamed class present ``` Co-Authored-By: Claude Code <[email protected]>
Summary
test_cudagraph_bisect_maxneeds CUDA graphs, so it does not belong in theaccelerator-wide
TestCompilerBisectorclass, where it was reachable for anydevice the old aggregate gate accepted. This moves it into a class of its own,
classified for CUDA and instantiated through
instantiate_device_type_tests,Changes
TestCompilerBisectorCudawithhw_classification = CUDA, holdingtest_cudagraph_bisect_max, instantiated withinstantiate_device_type_tests(..., only_for="cuda")so the test takes theinjected
deviceparameter instead of naming one.@requires_cudais not kept on top of that: afteronly_for="cuda"theinstantiation already answers it, and a second gate would be a second,
independently rotting source of the same fact.
HAS_GPUformula is restored on the class that still needs a Triton kernel, expressed as
its own requirement rather than as part of an aggregate boolean.
test_rngno longer carries an upstream PrivateUse1 skip; per maintainerdirection out-of-tree accelerators are exposed rather than silently skipped,
and a backend that does not support it opts out in its own
instantiate_device_type_testsinstantiation.Test Plan
Host: torch 2.16.0.dev20261029; the "cpu" venv autoloads torch_npu and
therefore registers PrivateUse1, so CPU-only claims below run with
TORCH_DEVICE_BACKEND_AUTOLOAD=0. All pytest commands from a directoryoutside the source tree with the absolute file path.
CPU-only (no CUDA, no accelerator registered) at head 78146ef:
With the
HAS_GPUgate removed the three GENERIC tests now run on aGPU-less host and pass; that addresses the automated review's request for
HEAD numbers. The new head's macOS/Windows CPU test jobs have not reported yet, so those remain CI's to report.
Test-ID move: on a CUDA build
test_cudagraph_bisect_maxisTestCompilerBisectorCudaCUDA.test_cudagraph_bisect_max_cuda(class name =original +
device_type.upper(), method suffix_cuda, perinstantiate_device_type_tests). On a machine with no CUDA device typeregistered it is not collected at all (
only_for="cuda"matches nothing);collection here is 10 IDs with PrivateUse1 registered vs 11 pre-PR.
PrivateUse1-registered host (same wheel, torch_npu autoloaded):
The one failure is
TestCompilerBisectorRNGNPU.test_rng_npuwithString comparison failed: 'eager' != 'inductor'. This is the intendedcoverage change decided in review: per @fffrog's instruction the
@skipPRIVATEUSE1special case is not restored —test_rngis exposed toall out-of-tree accelerators and backends that do not support it skip it in
their own
instantiate_device_type_testsinstantiation. (preserve_rng_statecurrently preserves only CPU/CUDA/XPU RNG, so an out-of-tree backend without
RNG preservation must opt out.) The stock (pre-PR) file run with the same
command gives
11 skipped, 0 failed, isolating this as the deliberateskip-to-exposed delta, not a pre-existing failure.
NPU hardware (8x Ascend 910B4, triton-ascend installed):
The bisect diverges on the eager/aot legs (RNG, as above); the inductor leg
on this wheel additionally hits a pre-existing torch_npu codegen skew
(
NPUPythonWrapperCodeGen... 'tunable_dyn_dims_mask'), reproduced with aplain
torch.compileof the same function and unrelated to this change.Pre-PR the same command skipped with "test doesn't work on privateuse1
backend".
Lint:
Not covered here: the CUDA legs (
test_cudagraph_bisect_max_cuda, thecuda/xpu variants of the Triton-gated tests) — this host has no NVIDIA
hardware; the upstream hardware shards run those.
Signed-off-by: gavinwang269 [email protected]
TestCompilerBisectorgainshw_classification = HardwareClassification.GENERIC(review request), byte-identical to the declaration in [Testcase Refactoring] Make test_bad_decomp device-agnostic via instantiate_device_type_tests #198354/[Testcase Refactoring] Make test_joint_graph device-agnostic via instantiate_device_type_tests #198355 so the three slices converge in any merge order.hw_classification = HardwareClassification.GENERIConTestCompilerBisector(the only PR adding it). Once [Testcase Refactoring] Make test_bad_decomp device-agnostic via instantiate_device_type_tests #198354/[Testcase Refactoring] Make test_joint_graph device-agnostic via instantiate_device_type_tests #198355 have moved the remaining GPU_TYPE occupants, the import-timeHAS_GPUdecorator and theHAS_GPU/GPU_TYPEimports are retired here too, so the natural merge order lands the exact end state.Rebase note (2026-11-09): replayed onto current main after #198354/#198355 merged, and per review this now also removes the import-time HAS_GPU gate and the GPU_TYPE/HAS_GPU import (both have no users left in the file). The single GENERIC declaration here is the only one across the series.
Scope note: an earlier revision of this PR carried the dead-scaffolding cleanup from #198362; per the review discussion that cleanup is dropped, and this PR closes out the bisector series with the move and the classification only (+53/-53).
Final-cleanup note (2026-11-10): as the last PR touching test_compiler_bisector.py in this series, this also drops the file entry from tools/linter/adapters/test_linter_allowlist.json (TEST_LINTER runs clean on the file after the removal), and moves the Triton gates to accelerator-aware @skipIf(..., device_type=...) forms, narrowed per review on each class.
cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @kadeng @chauhang @amjames @jataylo @azahed98