Repository navigation
[Testcase Refactoring] Make test_subgraph_choice device-agnostic via instantiate_device_type_tests - #192435
[Testcase Refactoring] Make test_subgraph_choice device-agnostic via instantiate_device_type_tests#192435gavinwang269 wants to merge 1 commit into
Conversation
✅ AUTOMATED REVIEW - OUTDATED (earlier commit) - Ready for human review:
Findings (4): Reviewed commit: 🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/192435
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit ca5dd7e with merge base 1e562ee ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
|
|
@pytorchbot label "module: tests/inductor" |
|
Didn't find following labels among repository labels: module: tests/inductor |
9b8ee8e to
c27b613
Compare
dfa422c to
2084857
Compare
|
@claude review this please and put the review inside a GitHub collapsible section |
|
Claude finished @zou3519's task in 21m 35s —— View job Reviewed — the conversion is mechanically fine, but Claude's PR Review — click to expandPR Review: #192435SummaryConverts Testing1.
Those tests cannot pass. The decompose-k path calls # torch/_inductor/kernel/mm.py:337-340
torch._check(
mat1.get_device().type in ("cuda", "xpu"),
lambda: "out_dtype is only supported for CUDA or XPU",
)
This is a behavior regression, not a neutral change. Before this PR, on an NPU-only machine Use the gate the sibling GPU-only inductor test uses ( instantiate_device_type_tests(
TestSubgraphChoice, globals(), only_for=("cuda", "xpu"), allow_xpu=True
)2. XPU coverage is silently dropped. (
Before this PR, 3. The Triton requirement was dropped along with the
Consequence: on a CUDA machine without Triton, these Code Quality4. Per the enum docstring ( 5.
6. The injected RecommendationRequest Changes Findings #1 and #2 are behavioral regressions rather than stylistic issues: the PR turns a zero-test no-op into a hard failure on out-of-tree accelerators, and turns real XPU coverage into a silent zero-test pass. Both are addressed by |
a3d411b to
2e46789
Compare
|
Thanks for the review! All points addressed in the latest push (2e46789): 1. except_for="cpu" vs only_for=("cuda", "xpu"): Keeping 2. XPU coverage: Fixed. Added 3. Triton gating: Added 4. NPU verification — Updated (08-12): All tests now pass on NPU (Ascend 910B4).
The 5. hw_classification: Keeping |
This PR was reopened (likely due to being reverted), so your approval was removed. Please request another review.
|
Ready for human review: single-file migration of |
There was a problem hiding this comment.
Automated review of b8d321a: nothing blocking; ready for human review.
The PR moves test/inductor/test_subgraph_choice.py onto instantiate_device_type_tests, using an ACCELERATOR class (except_for="cpu", allow_xpu=True) and a CUDA-only class for the Blackwell tests, and removes the file from the test-linter allowlist. Recommendation: Approve. Every earlier blocking finding is fixed or answered at HEAD, and the remaining points are all non-blocking.
⚪ 4 non-blocking findings
pytorch/test/inductor/test_subgraph_choice.py
Line 246 in b8d321a
Non-blocking: the custom-device gap is documented in a comment rather than closed. get_desired_device_type_test_bases applies only_for at common_device_type.py:1153, then adds bases named by PYTORCH_TESTING_DEVICE_FOR_CUSTOM from the unfiltered list (:1180-1190). On a Blackwell host with a custom backend and that variable set (the documented out-of-tree workflow), the PrivateUse1 copies of all three methods pass requires_blackwell_tma, since the probe only looks at torch.cuda, and then run Blackwell Triton lowering on the wrong device. The linter's DecoratorRule is registered only for ACCELERATOR (test_linter.py:688), so @ onlyCUDA is allowed on this HardwareClassification.CUDA class, and onlyOn("cuda") skips when self.device_type is the custom backend (common_device_type.py:2015-2025). Fix: add @ onlyCUDA to the three methods and replace the "Known limitation" paragraph with it, so the probe is only consulted where it applies to the instantiated device.
pytorch/test/inductor/test_subgraph_choice.py
Line 230 in b8d321a
Non-blocking: no pre-merge job runs the XPU variants. allow_xpu=True creates new TestSubgraphChoiceXPU ids, but .github/workflows/xpu.yml:4-14 only runs on ciflow/xpu/* tags, pushes to viable/strict, or its schedule. Neither ciflow/trunk nor ciflow/inductor runs XPU tests, and the author has no XPU hardware. The base did run this file on XPU (GPU_TYPE resolved to xpu). Add ciflow/xpu so the migrated XPU path runs before landing instead of first running on viable/strict.
pytorch/test/inductor/test_subgraph_choice.py
Line 159 in b8d321a
Non-blocking: test_subgraph_freeze_layout depends on global padding config instead of setting it (the gate/comment lines changed; the dependency is pre-existing). The mat1.layout.stride == mat1_stride check at :201 holds only if config.comprehensive_padding is on, which reads TORCHINDUCTOR_COMPREHENSIVE_PADDING (config.py:1775-1777). _pad_strides (ir.py:4777-4853) is device-independent; the only device-based switch-off is compile_fx.py:920-926. So the is_gpu gate is not enough alone: the PR's own NPU run passes the gate and fails at this bare AssertionError. Wrapping both torch.compile and the call in config.patch(comprehensive_padding=True, disable_padding_cpu=False) would make the test check what it claims on every instantiated device and remove the need for the is_gpu skip. Turning the bare raise AssertionErrors into self.assert* calls would make such failures readable.
pytorch/test/inductor/test_subgraph_choice.py
Line 229 in b8d321a
Non-blocking: MTIA loses this file entirely (:229-231, :345). The old guard reached MTIA hosts: HAS_GPU includes HAS_MTIA_AND_TRITON (inductor_utils.py:82), and GPU_TYPE could be mtia. get_device_type_test_bases has no MTIA base, and in fbcode it also drops the CUDA base on MTIA hosts (common_device_type.py:1031-1037). The description raises this for maintainers, but nobody has acknowledged it. An inductor/MTIA owner should confirm the loss is acceptable before landing.
This review is AI-generated and advisory. Each new automated review replaces the previous one. Report a bad review
|
cc @jansel - small one to pick up while you are in this area: @lizhihai137 approved, CI is green, it just needs a maintainer to land it. It removes the CUDA-only assumption from the subgraph-choice test helper so out-of-tree backends can run it (+199/-179 across the test file and the test-linter allowlist entry it deletes, per the series convention of removing allowlist lines when a file gets converted). Correction to my earlier draft: the diff is the size stated here, not "34 lines". |
|
@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 |
…duate it from the test linter
Rewrite the gating in test/inductor/test_subgraph_choice.py so every device decision
is a capability answer about the instantiated device, then drop the file from the
test-linter migration ledger now that it satisfies the ACCELERATOR rules.
Three upstream layers touch this feature, and they are not the same question:
- native_functions.yaml registers aten bmm.dtype / bmm.dtype_out for CUDA and XPU,
but an out-of-tree backend may register its own lowering for the same op;
- Inductor's generic aten.bmm lowering raises "out_dtype is only supported for CUDA
or XPU" (torch/_inductor/kernel/bmm.py:361-363) for whatever reaches it;
- the decompose-K heuristic template ships real heuristics for cuda and xpu with an
empty opt-out class and a TODO to widen
(torch/_inductor/heuristics/template/decompose_k.py:30-49).
Measured here on an Ascend 910B4 host with torch_npu registered, the aten variants
do reach lowering and fail inside torch_npu's own registration:
LoweringException: TypeError: _register_npu_inductor_bmm.<locals>.tuned_bmm()
takes 2 positional arguments but 3 were given
-- torch._inductor.kernel.bmm's "CUDA or XPU" assertion is never evaluated on that
path. So mirroring bmm.py's device list in the test would be wrong twice over: it
would restate an upstream name list inside a device-agnostic test, and it would keep
permanently skipped a backend that does implement out_dtype (here, one that merely
implements it incorrectly today). The support question is therefore not encoded at
all in this file: the tests run wherever their real requirements hold, and the
torch_npu defect is left to fail visibly rather than hidden behind a skip.
Changes:
- Removed the module-level GPU_TYPE: the base was one
@instantiate_parametrized_tests class that built every tensor on GPU_TYPE;
tensors are now built on the device the instantiated variant is bound to. The
file's Blackwell gates are import-time
@unittest.skipUnless(has_datacenter_blackwell_tma_device(), ...) decorators
answering one process-wide question, defined once at module level as
requires_blackwell_tma and applied only to the CUDA-only class below; the
accelerator class needs no Blackwell gate because it runs no Triton
decompose-K code.
- Moved every Blackwell-only Triton test into a dedicated TestSubgraphChoiceCUDAOnly
class (hw_classification=CUDA, instantiate_device_type_tests(..., only_for="cuda")):
test_decompose_k_partial_freezes_producer_layout, test_decompose_k_bmm_backends, and
the Triton half of test_subgraph_decompose_k, now named
test_subgraph_decompose_k_triton there. The base carried these three tests in
its single class: the two siblings already had the import-time
@unittest.skipUnless decorators, and the Triton half of
test_subgraph_decompose_k was gated by an in-body self.skipTest that the class
split replaces. All three now carry the single module-level requires_blackwell_tma
gate; the probe is process-wide, so on a class instantiated only_for="cuda" it
normally answers for CUDA's own hardware, with the PYTORCH_TESTING_DEVICE_FOR_CUSTOM
caveat stated in the class comment instead of papered over. The split is what
removes the Blackwell
exposure from the accelerator class: the class instantiated for XPU and out-of-tree
backends no longer generates any Triton decompose-K variant, and no longer generates
the meta_ws / config_index combinations that only ever meant something to the Triton
backend. The base always collected -- and skipped in-body -- six aten ids
built from that cross product (two dtypes x three skipped combos); those
variants are gone entirely, so no skipped id of that shape survives on XPU or
out-of-tree.
test_subgraph_decompose_k is therefore split by backend into
test_subgraph_decompose_k_aten on the accelerator class (a single variant
per dtype) and test_subgraph_decompose_k_triton on the CUDA-only class (its
meta_ws and config_index parametrizes and its MetaWS skip), so the ids name
the backend again the way the base's backend_aten / backend_triton
parametrization did. The shared
computation lives in a module-level _run_decompose_k_case(self, ...) helper -- a plain
function that takes the TestCase instance, not a TestCase subclass alias, so pytest
still collects exactly one accelerator and one CUDA-only class rather than a second
copy of every id. The helper appends its one choice through the subgraph
template exactly as the base's inline body did
(DecomposeKSubgraphTemplate().maybe_append_choice, autotune_select_algorithm,
run_and_get_code(torch.compile(fn), ...)) and, like the base body, passes
k_split, bmm_backend and bmm_config_index explicitly: SubgraphTemplate keeps
the base KernelTemplate.maybe_append_choice, which calls generate() directly,
so the registered template heuristics are not consulted on this path. The
CUDA-only class holds 13 ids on a
CUDA host (8 Triton decompose-K variants: meta_ws x config_index x two dtypes; 1
partial producer-layout; 4 bmm-backends). Each instantiated accelerator class holds
3 ids: the aten decompose-K case in bf16 and fp32, and freeze-layout.
- @requires_triton() (family rule, and this file's Triton variants need a Triton
backend) plus an in-body check for what remains in the accelerator class:
test_subgraph_freeze_layout gates on is_gpu(self.device_type), the predicate
compile_fx.maybe_disable_comprehensive_padding uses to switch comprehensive padding
off for graphs with no GPU-class input (config.disable_padding_cpu); the stride
assertions below need that padding, which is on by default. is_gpu is
derived from the registered accelerator types (which cover cuda, mps, mtia, npu and
xpu on this host), so it answers True here and the test runs, rather than being
skipped by a name list.
- @dtypes(torch.bfloat16, torch.float32) instead of @parametrize("dtype", ...), which
replaces the `dtype_bfloat16` id segment with the dtypes-generated `bfloat16` suffix.
- No xfail machinery is carried. Upstream keeps no marker for the torch_npu defect:
the three PrivateUse1 ids fail visibly, and a backend excludes them through
PrivateUse1TestBase.set_test_configs(test_exclusions=...)
(torch/testing/_internal/common_device_type.py:419, :502; set_test_configs itself
:625), the form documented
in docs/source/accelerator/testing.md. An upstream expectedFailure naming the
measured ids would be a backend's own exclusion list written into the
device-agnostic tree -- the ids carry that backend's device suffix, so the table
is a name list wearing a marker -- and exactly the coupling this file is being
migrated away from. Failing visibly instead lets each backend decide how to
suppress its own known-broken lowering without upstream naming it.
- Runner guard now uses `if has_triton(): run_tests(needs="filelock")`, matching the
convention in the sister file test/inductor/test_mem_estimation.py:364. That single
has_triton() guard is what replaces the removed HAS_GPU / HAS_CPU gate: the file's
accelerator variants still run wherever a Triton toolchain exists, and the whole
module simply does nothing under the bare runner when Triton is absent.
Per-device answers, and what is not a per-device answer:
The accelerator class (TestSubgraphChoice, hw_classification=ACCELERATOR,
instantiate_device_type_tests(..., except_for="cpu", allow_xpu=True)) answers per-device
through three things only: the instantiation scope itself (a variant exists only for a
registered accelerator base), is_gpu(self.device_type) in test_subgraph_freeze_layout,
and -- inside the separate CUDA-only class -- has_datacenter_blackwell_tma_device().
@requires_triton() is not one of them: it is a process-wide toolchain-existence check
for whether Triton can be imported at all, not a question about which accelerator the
instantiated variant runs on. The CUDA-only class (TestSubgraphChoiceCUDAOnly,
instantiate_device_type_tests(..., only_for="cuda")) is instantiated only where CUDA is
registered, so the Blackwell probe it consults is normally a probe of that class's own
device; the exception is PYTORCH_TESTING_DEVICE_FOR_CUSTOM, which appends matching
device bases after the only_for filter, and the class comment states that limitation.
Which jobs run this file:
The accelerator tests run on CUDA default shards (test_python_shard discovery), on ROCm
default shards, and on XPU default shards. Only the Blackwell-gated ids have no trunk
job, because no Blackwell hardware exists in trunk CI. The refactored Triton half --
the whole CUDA-only class -- has therefore not been exercised on CUDA, Blackwell or
XPU hardware at this head: the host used for the measurements below has neither a
CUDA nor an XPU device. One scope change is worth flagging
for maintainer attention: the old __main__ path gated on HAS_GPU and HAS_CPU (tensors
built on GPU_TYPE) and could reach MTIA hosts -- HAS_GPU includes HAS_MTIA_AND_TRITON
(inductor_utils.py:82) -- whereas get_device_type_test_bases has no MTIA base, so
after this change the file contributes no tests to MTIA-labeled runs.
Test Plan
Measured on an Ascend 910B4 host (no CUDA, no XPU hardware) against installed
torch + torch_npu nightlies. pytest is pointed at the test file inside this
checkout from a directory that is not the repo root, so the installed package is
imported (running from the repo root of a source build is equivalent). The NPU
venv sources the CANN set_env.sh first; the lintrunner line needs lintrunner on
PATH.
```
python -m pytest test/inductor/test_subgraph_choice.py --collect-only -q
# NPU venv: 3 tests collected, all under TestSubgraphChoicePRIVATEUSE1:
# TestSubgraphChoicePRIVATEUSE1::test_subgraph_decompose_k_aten_npu_bfloat16
# TestSubgraphChoicePRIVATEUSE1::test_subgraph_decompose_k_aten_npu_float32
# TestSubgraphChoicePRIVATEUSE1::test_subgraph_freeze_layout_npu
# No *_npu ids of the CUDA-only class (only_for="cuda", and no CUDA on this host).
python -m pytest -q -rs test/inductor/test_subgraph_choice.py
# NPU venv: 3 failed, 0 skipped. Each fails visibly, no marker. The two
# test_subgraph_decompose_k_aten ids fail inside torch_npu's own bmm registration:
# LoweringException: TypeError: _register_npu_inductor_bmm.<locals>.tuned_bmm()
# takes 2 positional arguments but 3 were given
# test_subgraph_freeze_layout_npu trips the file's own stride-equality check:
# LoweringException: AssertionError:
# target: mylib.matmul_decompose_padding.default
TORCH_DEVICE_BACKEND_AUTOLOAD=0 python -m pytest test/inductor/test_subgraph_choice.py --collect-only -q
# no tests collected (rc 5) in a venv where the guard is effective (in the NPU venv a
# sitecustomize force-imports torch_npu regardless of the guard): the accelerator
# instantiation (except_for="cpu") has no accelerator base to bind to and the
# CUDA-only instantiation (only_for="cuda") has no CUDA present.
python3 tools/linter/adapters/test_linter.py test/inductor/test_subgraph_choice.py
# 0 findings from the repo root.
lintrunner -a test/inductor/test_subgraph_choice.py
# ok No lint issues. rc=0
```
The out-of-tree value is that no capability question is answered by a device-name list:
the only Blackwell answer lives inside the class instantiated only_for="cuda" (whose
PYTORCH_TESTING_DEVICE_FOR_CUSTOM caveat is stated in-file), the only GPU-class answer
is is_gpu(self.device_type), and the torch_npu
defect is left for the backend to suppress with its own exclusions rather than named
upstream.
|
@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 |
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 |
|
@pytorchbot revert -m "Reverting only to unblock a clean revert of #196769, which breaks internal tests. This PR refactored test_subgraph_choice.py on top of it. Can reland upon rebasing, although merge conflicts may need to be addressed" -c ghfirst |
|
@pytorchbot successfully started a revert job. Check the current status here. |
|
@gavinwang269 your PR has been successfully reverted. |
[inductor][test] Make test_subgraph_choice.py device-agnostic and graduate it from the test linter
Rewrite the gating in test/inductor/test_subgraph_choice.py so every device decision
is a capability answer about the instantiated device, then drop the file from the
test-linter migration ledger now that it satisfies the ACCELERATOR rules.
Three upstream layers touch this feature, and they are not the same question:
but an out-of-tree backend may register its own lowering for the same op;
or XPU" (torch/_inductor/kernel/bmm.py:361-363) for whatever reaches it;
empty opt-out class and a TODO to widen
(torch/_inductor/heuristics/template/decompose_k.py:30-49).
Measured here on an Ascend 910B4 host with torch_npu registered, the aten variants
do reach lowering and fail inside torch_npu's own registration:
-- torch._inductor.kernel.bmm's "CUDA or XPU" assertion is never evaluated on that
path. So mirroring bmm.py's device list in the test would be wrong twice over: it
would restate an upstream name list inside a device-agnostic test, and it would keep
permanently skipped a backend that does implement out_dtype (here, one that merely
implements it incorrectly today). The support question is therefore not encoded at
all in this file: the tests run wherever their real requirements hold, and the
torch_npu defect is left to fail visibly rather than hidden behind a skip.
Changes:
@instantiate_parametrized_tests class that built every tensor on GPU_TYPE;
tensors are now built on the device the instantiated variant is bound to. The
file's Blackwell gates are import-time
@unittest.skipUnless(has_datacenter_blackwell_tma_device(), ...) decorators
answering one process-wide question, defined once at module level as
requires_blackwell_tma and applied only to the CUDA-only class below; the
accelerator class needs no Blackwell gate because it runs no Triton
decompose-K code.
class (hw_classification=CUDA, instantiate_device_type_tests(..., only_for="cuda")):
test_decompose_k_partial_freezes_producer_layout, test_decompose_k_bmm_backends, and
the Triton half of test_subgraph_decompose_k, now named
test_subgraph_decompose_k_triton there. The base carried these three tests in
its single class: the two siblings already had the import-time
@unittest.skipUnless decorators, and the Triton half of
test_subgraph_decompose_k was gated by an in-body self.skipTest that the class
split replaces. All three now carry the single module-level requires_blackwell_tma
gate; the probe is process-wide, so on a class instantiated only_for="cuda" it
normally answers for CUDA's own hardware, with the PYTORCH_TESTING_DEVICE_FOR_CUSTOM
caveat stated in the class comment instead of papered over. The split is what
removes the Blackwell
exposure from the accelerator class: the class instantiated for XPU and out-of-tree
backends no longer generates any Triton decompose-K variant, and no longer generates
the meta_ws / config_index combinations that only ever meant something to the Triton
backend. The base always collected -- and skipped in-body -- six aten ids
built from that cross product (two dtypes x three skipped combos); those
variants are gone entirely, so no skipped id of that shape survives on XPU or
out-of-tree.
test_subgraph_decompose_k is therefore split by backend into
test_subgraph_decompose_k_aten on the accelerator class (a single variant
per dtype) and test_subgraph_decompose_k_triton on the CUDA-only class (its
meta_ws and config_index parametrizes and its MetaWS skip), so the ids name
the backend again the way the base's backend_aten / backend_triton
parametrization did. The shared
computation lives in a module-level _run_decompose_k_case(self, ...) helper -- a plain
function that takes the TestCase instance, not a TestCase subclass alias, so pytest
still collects exactly one accelerator and one CUDA-only class rather than a second
copy of every id. The helper appends its one choice through the subgraph
template exactly as the base's inline body did
(DecomposeKSubgraphTemplate().maybe_append_choice, autotune_select_algorithm,
run_and_get_code(torch.compile(fn), ...)) and, like the base body, passes
k_split, bmm_backend and bmm_config_index explicitly: SubgraphTemplate keeps
the base KernelTemplate.maybe_append_choice, which calls generate() directly,
so the registered template heuristics are not consulted on this path. The
CUDA-only class holds 13 ids on a
CUDA host (8 Triton decompose-K variants: meta_ws x config_index x two dtypes; 1
partial producer-layout; 4 bmm-backends). Each instantiated accelerator class holds
3 ids: the aten decompose-K case in bf16 and fp32, and freeze-layout.
backend) plus an in-body check for what remains in the accelerator class:
test_subgraph_freeze_layout gates on is_gpu(self.device_type), the predicate
compile_fx.maybe_disable_comprehensive_padding uses to switch comprehensive padding
off for graphs with no GPU-class input (config.disable_padding_cpu); the stride
assertions below need that padding, which is on by default. is_gpu is
derived from the registered accelerator types (which cover cuda, mps, mtia, npu and
xpu on this host), so it answers True here and the test runs, rather than being
skipped by a name list.
replaces the
dtype_bfloat16id segment with the dtypes-generatedbfloat16suffix.the three PrivateUse1 ids fail visibly, and a backend excludes them through
PrivateUse1TestBase.set_test_configs(test_exclusions=...)
(torch/testing/_internal/common_device_type.py:419, :502; set_test_configs itself
:625), the form documented
in docs/source/accelerator/testing.md. An upstream expectedFailure naming the
measured ids would be a backend's own exclusion list written into the
device-agnostic tree -- the ids carry that backend's device suffix, so the table
is a name list wearing a marker -- and exactly the coupling this file is being
migrated away from. Failing visibly instead lets each backend decide how to
suppress its own known-broken lowering without upstream naming it.
if has_triton(): run_tests(needs="filelock"), matching theconvention in the sister file test/inductor/test_mem_estimation.py:364. That single
has_triton() guard is what replaces the removed HAS_GPU / HAS_CPU gate: the file's
accelerator variants still run wherever a Triton toolchain exists, and the whole
module simply does nothing under the bare runner when Triton is absent.
Per-device answers, and what is not a per-device answer:
The accelerator class (TestSubgraphChoice, hw_classification=ACCELERATOR,
instantiate_device_type_tests(..., except_for="cpu", allow_xpu=True)) answers per-device
through three things only: the instantiation scope itself (a variant exists only for a
registered accelerator base), is_gpu(self.device_type) in test_subgraph_freeze_layout,
and -- inside the separate CUDA-only class -- has_datacenter_blackwell_tma_device().
@requires_triton() is not one of them: it is a process-wide toolchain-existence check
for whether Triton can be imported at all, not a question about which accelerator the
instantiated variant runs on. The CUDA-only class (TestSubgraphChoiceCUDAOnly,
instantiate_device_type_tests(..., only_for="cuda")) is instantiated only where CUDA is
registered, so the Blackwell probe it consults is normally a probe of that class's own
device; the exception is PYTORCH_TESTING_DEVICE_FOR_CUSTOM, which appends matching
device bases after the only_for filter, and the class comment states that limitation.
Which jobs run this file:
The accelerator tests run on CUDA default shards (test_python_shard discovery), on ROCm
default shards, and on XPU default shards. Only the Blackwell-gated ids have no trunk
job, because no Blackwell hardware exists in trunk CI. The refactored Triton half --
the whole CUDA-only class -- has therefore not been exercised on CUDA, Blackwell or
XPU hardware at this head: the host used for the measurements below has neither a
CUDA nor an XPU device. One scope change is worth flagging
for maintainer attention: the old main path gated on HAS_GPU and HAS_CPU (tensors
built on GPU_TYPE) and could reach MTIA hosts -- HAS_GPU includes HAS_MTIA_AND_TRITON
(inductor_utils.py:82) -- whereas get_device_type_test_bases has no MTIA base, so
after this change the file contributes no tests to MTIA-labeled runs.
Test Plan
Measured on an Ascend 910B4 host (no CUDA, no XPU hardware) against installed
torch + torch_npu nightlies. pytest is pointed at the test file inside this
checkout from a directory that is not the repo root, so the installed package is
imported (running from the repo root of a source build is equivalent). The NPU
venv sources the CANN set_env.sh first; the lintrunner line needs lintrunner on
PATH.
The out-of-tree value is that no capability question is answered by a device-name list:
the only Blackwell answer lives inside the class instantiated only_for="cuda" (whose
PYTORCH_TESTING_DEVICE_FOR_CUSTOM caveat is stated in-file), the only GPU-class answer
is is_gpu(self.device_type), and the torch_npu
defect is left for the backend to suppress with its own exclusions rather than named
upstream.
cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben @jataylo