Repository navigation
[Inductor] Filter unsupported transposed FP32 Blackwell configs - #196769
jananisriram wants to merge 8 commits into
Conversation
[ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/196769
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New Failure, 1 Cancelled Job, 5 Unrelated FailuresAs of commit 5d57444 with merge base eeafed4 ( 🟡 GREEN LIGHT - PR was reverted - re-landing requires human review:
Green Light will not review this PR again, on this or any later commit; re-landing it needs a human approval. NEW FAILURE - The following job has failed:
NEW FAILURES SUPPRESSED BY AI (non-blocking) - The following jobs failed, but the AI CI Advisor judged the failures not to be evidence against this change:
CANCELLED JOB - The following job was cancelled. Please retry:
FLAKY - The following jobs failed but were likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
[ghstack-poisoned]
Reject transposed FP32/TF32 Blackwell TMA candidates that current Triton cannot lower. PTX supports this only with 128-byte swizzling and 32-byte swizzle atomicity, which Triton does not yet represent for this path. Preserve legal BLOCK_M=32, non-TF32, BF16, and transposed-B configurations.
e8ea7f7 to
2e9ffb9
Compare
[ghstack-poisoned]
|
@jananisriram has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
[ghstack-poisoned]
…tic via instantiate_device_type_tests (#192435)" This reverts commit 38a2773. Reverted #192435 on behalf of https://github.com/georgehong due to 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 ([comment](#192435 (comment)))
…instantiate_device_type_tests (#192435) [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: - 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. Pull Request resolved: #192435 Approved by: https://github.com/lizhihai137, https://github.com/jansel
|
@pytorchbot revert -m "This is breaking test signals internally. Please see the internal change for details." -c ghfirst |
|
@pytorchbot successfully started a revert job. Check the current status here. |
…gs (#196769)" This reverts commit 56f2ee8. Reverted #196769 on behalf of https://github.com/georgehong due to This is breaking test signals internally. Please see the internal change for details. ([comment](#196769 (comment)))
|
@jananisriram your PR has been successfully reverted. |
|
@jananisriram has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
|
@pytorchbot merge -i |
Merge startedYour change will be merged while ignoring the following 7 checks: Lint / Test collect_env (older_python_version, linux.24_04.4x), Lint / Test collect_env (with_torch, linux.24_04.4x), pull / linux-jammy-py3.11-gcc11 / test (editable, 1, 1, lf-l-x86iavx512-8-64), Mac MPS / macos-py3-arm64-mps / test (test_mps, 1, 1, macos-m1-15), trunk / linux-jammy-cuda13.2-py3.11-gcc11 / test (default, 9, 14, lf-l-x86aavx2-11-41-l4), trunk / linux-jammy-cuda13.2-py3.11-gcc11 / test (default, 7, 14, lf-l-x86aavx2-11-41-l4), trunk / win-vs2022-cpu-py3 / test (default, 4, 12, windows.4xlarge.nonephemeral) Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Reject Blackwell TMA configurations that require transposed FP32 tcgen05 MMA operands before Triton compilation. PTX supports transposed TF32 only with 128-byte swizzling and 32-byte swizzle atomicity; Triton does not currently represent/lower that shared-memory form. Preserve legal BLOCK_M=32, non-TF32, BF16, and transposed-B configurations.
With local and remote caches disabled, a representative
(1024, 2048) @ (2048, 1024)cold compile using a bounded candidate set improves from 19.95s to 18.80s by removing one invalid candidate before codegen.cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben @jataylo @azahed98
Differential Revision: D132419570