Repository navigation
[Testcase Refactoring] Make test_static_triton_launcher device-agnostic via instantiate_device_type_tests - #192893
gavinwang269 wants to merge 5 commits into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/192893
Note: Links to docs will display an error until the docs builds have been completed.
|
|
The following ciflow label(s) have been added but CI has not been triggered yet because the workflows are awaiting approval:
Once a maintainer approves the workflows (scroll to the bottom of the PR page), the corresponding CI jobs will be triggered automatically. Please ping one of the reviewers if you do not have access to approve and run workflows. |
|
@pytorchbot label "module: inductor" "topic: not user facing" |
6bc5c84 to
f12c948
Compare
|
@pytorchbot label "module: tests/graph" |
5292a59 to
bbe0446
Compare
rogerchen838
left a comment
There was a problem hiding this comment.
Reviewed the current head against RFC #191471. The static Triton launcher tests are device-type instantiated and safely exclude unsupported devices; no blocking issue was found. The latest lint/build checks are passing, while the broader test matrix is still in progress.
rogerchen838
left a comment
There was a problem hiding this comment.
Reviewed the current head against RFC #191471. The static Triton launcher tests are device-type instantiated and safely exclude unsupported devices; no blocking issue was found. The latest lint/build checks are passing, while the broader test matrix is still in progress.
bbe0446 to
f560b6f
Compare
rogerchen838
left a comment
There was a problem hiding this comment.
The current head has a CI-backed formatting failure, so I cannot keep the earlier approval until it is fixed.
| fast(1, 1, 1, stream, new_arg0, 5) | ||
| self.assertEqual( | ||
| new_arg0, torch.tensor([5], dtype=torch.int32, device=GPU_TYPE) | ||
| new_arg0, torch.tensor([5], dtype=torch.int32, device=device) |
This comment was marked as low quality.
This comment was marked as low quality.
Sorry, something went wrong.
There was a problem hiding this comment.
Thanks for catching this! Fixed. Ran lintrunner -a — the assertion has been collapsed to a single line and the trailing newline is now present. Also rebased onto latest main.
f560b6f to
04a3026
Compare
a64e594 to
a13e705
Compare
rogerchen838
left a comment
There was a problem hiding this comment.
I verified this against each PR’s current head and confirmed that the imported capability API is not present in common_device_type.py; this blocks test collection.
| from torch.testing._internal.inductor_utils import GPU_TYPE, HAS_XPU_AND_TRITON | ||
| from torch.testing._internal.triton_utils import requires_gpu_and_triton | ||
| from torch.testing._internal.common_device_type import ( | ||
| Capability, |
This comment was marked as low quality.
This comment was marked as low quality.
Sorry, something went wrong.
There was a problem hiding this comment.
Thanks for the detailed analysis! This has been fixed in commit 9709a7e (the latest head).
To clarify what changed:
Capabilityandrequires_capabilitiesimports have been removed entirely — there is no longer any import fromcommon_device_type.pybesidesinstantiate_device_type_tests.- Triton gating now uses
@unittest.skipIf(not has_triton(), "requires triton")withhas_tritonimported fromtorch.utils._triton— no dependency on the capability interface ([Test] Add capability-based test skip mechanism #190846/[Testcase Refactoring] Add distributed test capability gates #191919) is needed. has_triton_tma_deviceis also imported fromtorch.utils._tritonfor the TMA device test.
Verified: grep -r "Capability" test/inductor/test_static_triton_launcher.py returns 0 matches. Could you please re-review the latest head (9709a7e)?
There was a problem hiding this comment.
@rogerchen838 thanks for the careful review. On the collection-blocking concern at the current heads: the Capability / requires_capabilities imports are already gone. At 9709a7e7 (the head your last review referenced) and at the current head 62adaa0a, test/inductor/test_static_triton_launcher.py:33 imports only instantiate_device_type_tests from common_device_type, and the Triton gating uses the existing @unittest.skipIf(not has_triton(), "requires Triton") (e.g. lines 327/360 at 9709a7e7). Could you double-check and dismiss the request-changes if that matches what you see? Note: I'm also superseding this PR with a per-class split (#198436 ~ #198440), so the discussion may continue there.
rogerchen838
left a comment
There was a problem hiding this comment.
I checked the current head and the target import. This is collection-blocking because the imported symbols must exist before any test can run.
AI-assisted analysis: this PR imports
Capabilityandrequires_capabilitiesfromtorch.testing._internal.common_device_type, but neither API exists at this PR head. Please remove this dependency or first rebase onto the change that introduces those APIs.
|
@rogerchen838 Following up on your latest review — the |
|
Hi @rogerchen838, sorry for the slow follow-up on this. The branch has been rebased onto the latest main (the merge previously showed as dirty). To summarize the current state of your review points:
The unit-test portion passes locally (9/9 on CPU, one expected ROCm-only skip). CI is running on the new head. Could you take another look when convenient? Thanks! |
…ic via instantiate_device_type_tests
- Replace all GPU_TYPE references with torch.device(device).type in test methods
(upstream standard pattern, see test_fp8.py, test_flex_attention.py)
- Keep self.device_type in setUp/tearDown only (no device param available,
upstream precedent: test_flex_decoding.py)
- Replace @requires_gpu_and_triton with hw_classification declarations
- TestStaticTritonLauncherUnit: GENERIC (pure unit tests)
- TestFastCudaLauncher: only_for=("cuda",) — CUDA-only C extension
- TestFastCudaLauncherCompileResult: only_for=("cuda", "xpu")
- Add npubin binary key for NPU in write_cubin_to_tmp
- Replace @config.patch class decorators with setUp/tearDown context managers
- Rebased onto latest upstream/main to incorporate new _global_scratch_kernel
and test_device_tma_gemm_falls_back_from_fast_launcher additions
…t methods TestStaticTritonLauncher and TestStaticTritonCompileResult use instantiate_device_type_tests with except_for="cpu", allow_xpu=True. All 19 test methods with device parameter use triton.jit/torch.compile and require Capability.lib.triton to be registered. Restored @skipIfRocm on TestFastCudaLauncher and TestFastCudaLauncherCompileResult (ROCm presents as CUDA, only_for does not exclude it). Restored @skipIfXpu on test_too_high_shared_mem (TestStaticTritonLauncher uses allow_xpu=True, XPU runs and would fail on CUDA OOM test).
TestFastCudaLauncherCompileResult was labeled HardwareClassification.CUDA but
was instantiated with only_for=("cuda", "xpu"), and mixed two CUDA-only tests
(test_basic_compile, test_device_tma_gemm_falls_back_from_fast_launcher) with a
device-generic fallback smoke test (test_disable_fast_launcher). The mismatch
forced redundant @skipIfXpu guards and an unreachable XPU assertion branch in
test_basic_compile.
Split the class so hw_classification matches the instantiation scope: shared
setUp/tearDown/tracker move into _FastLauncherCompileMixin (not a TestCase); the
device-generic test_disable_fast_launcher moves into a new
TestFastLauncherFallbackCompileResult (ACCELERATOR, cuda+xpu); the two CUDA-only
tests stay in TestFastCudaLauncherCompileResult (only_for=cuda). This lets both
@skipIfXpu decorators and the dead XPU branch in test_basic_compile be removed.
Test Plan:
- AST parse and instantiate_device_type_tests attribution verified via ast
introspection (mixin has no TestCase base; ACCELERATOR class holds only
test_disable_fast_launcher; CUDA class holds the two CUDA-only tests with no
@skipIfXpu).
- pytest --collect-only: baseline and post-change both collect identically; the
_FastCudaLauncher wheel symbol is absent on this CPU host so the device-generic
classes generate no variants, unchanged from baseline.
- ruff check / ruff format --check and lintrunner -a: no issues.
|
Revisit of the classification mismatch: instead of dropping the XPU instantiation (which would remove |
|
Closing in favor of a per-class split — this single-file diff (+259 -168, 427 lines in one file) was hard to review in one go. The same changes are split into five PRs, one class per PR, each kept small:
All review feedback on this PR (lint fix, and dropping the not-yet-landed |
Summary
Refactor
test/inductor/test_static_triton_launcher.pyto use the device-agnostic test framework (instantiate_device_type_tests+HardwareClassification) instead of hardcodedGPU_TYPE/@requires_gpu_and_triton.Changes
GPU_TYPEreferences withtorch.device(device).type(upstream standard pattern, seetest_fp8.py,test_flex_attention.py)@requires_gpu_and_tritondecorators with@unittest.skipIf(not has_triton(), "requires triton")for Triton gating andhw_classificationclass declarations for hardware-based test dispatchrequires_gpu_and_tritonimport withhas_tritonandhas_triton_tma_devicefromtorch.utils._triton; addinstantiate_device_type_testsfromcommon_device_typeandHardwareClassificationfromcommon_utils; removeGPU_TYPEfrominductor_utilsimportdeviceparameter to all test methods in 4 accelerator/device-specific test classes@config.patchclass decorators withsetUp/tearDowncontext managers (class decorator form wraps class as function, breakinginstantiate_device_type_tests)write_cubin_to_tmp: addnpubinbinary key for NPU device typeHardware Classification
hw_classificationinstantiate_device_type_testsTestStaticTritonLauncherUnitGENERICTestStaticTritonLauncherACCELERATORexcept_for="cpu", allow_xpu=TrueTestStaticTritonCompileResultACCELERATORexcept_for="cpu", allow_xpu=TrueTestFastCudaLauncherCUDAonly_for=("cuda",)—_FastCudaLauncheris a CUDA-only C extensionTestFastCudaLauncherCompileResultCUDAonly_for=("cuda", "xpu"), allow_xpu=True— fast launcher tests are CUDA/XPU onlyMotivation
The
@requires_gpu_and_tritondecorator usesGPU_TYPEfrominductor_utils, which checksGPU_TYPES(currently["cuda", "mps", "xpu", "mtia"]). Out-of-tree accelerators registered viaPrivateUse1(e.g., Ascend NPU) are not included in this list, causing the entire test module to be skipped.Test Plan
Verified on CPU (no GPU) and NPU (Ascend 910B4):
Verification Report
NPU Failures (hardware/software limitations)
test_unsigned_integersaclnnInplaceZerodoes not supportDT_UINT64test_anylibdevice.isinfdoes not supportfloat64(BiSheng compiler only supports fp16/bf16/fp32)test_incompatible_codeCompileThreadPooldoes not propagate thread-local config to worker threadsEnvironment
cc @jgong5 @mingfeima @XiaobingSuper @sanchitintel @ashokei @jingxu10 @aditew01 @gujinghui @PenghuiCheng @jianyuh @min-jean-cho @yanbing-j @Guobing-Chen @Xia-Weiwen @snadampal @voznesenskym @penguinwu @EikanWang @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben @jataylo @azahed98