Skip to content

Commit 01f94d4

Browse files
daisydenetaf
authored andcommitted
[xpu][test] [1/N] Enable missing Intel GPU inductor tests (pytorch#167047)
Pull Request resolved: pytorch#167047 Approved by: https://github.com/etaf, https://github.com/jansel Co-authored-by: xinan.lin <[email protected]>
1 parent 35dae27 commit 01f94d4

30 files changed

+332
-283
lines changed

test/dynamo/test_higher_order_ops.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@
3939
)
4040
from torch.testing._internal.hop_db import hop_db
4141
from torch.testing._internal.logging_utils import LoggingTestCase, make_logging_test
42-
from torch.testing._internal.triton_utils import requires_cuda_and_triton
42+
from torch.testing._internal.triton_utils import (
43+
requires_cuda_and_triton,
44+
requires_gpu_and_triton,
45+
)
4346

4447

4548
def count_ops(gm, args, freq, op):
@@ -6980,7 +6983,7 @@ def fn(x, y):
69806983
fn, backend, x, y, skip_check=True
69816984
) # dropout decomp is known to diverge with eager
69826985

6983-
@requires_cuda_and_triton
6986+
@requires_gpu_and_triton
69846987
@torch._functorch.config.patch(functionalize_rng_ops=True)
69856988
def test_fallback(self):
69866989
def gn(x, y):

test/inductor/test_aot_inductor.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1554,7 +1554,8 @@ def forward(self, x, y):
15541554

15551555
# scaled_dot_product_flash_attention
15561556
@unittest.skipIf(
1557-
not HAS_XPU_AND_TRITON and not SM80OrLater, "bfloat16 only supported in sm80+"
1557+
not SM80OrLater and not HAS_XPU_AND_TRITON,
1558+
"bfloat16 only supported in sm80+ or XPU",
15581559
)
15591560
def test_sdpa(self):
15601561
class Model(torch.nn.Module):
@@ -1571,7 +1572,10 @@ def forward(self, q, k, v):
15711572
)
15721573
self.check_model(Model(), example_inputs)
15731574

1574-
@unittest.skipIf(not SM80OrLater, "bfloat16 only supported in sm80+")
1575+
@unittest.skipIf(
1576+
not SM80OrLater and not HAS_XPU_AND_TRITON,
1577+
"bfloat16 only supported in sm80+ or XPU",
1578+
)
15751579
@unittest.skipIf(
15761580
# for archs where this isn't lowered to flash attention, the math
15771581
# backend will be used and it doesn't work for bfloat16
@@ -5926,8 +5930,8 @@ def forward_block(self, x):
59265930
@requires_gpu
59275931
def test_d2h_copy(self):
59285932
# device to copy host should always have the same stride
5929-
if "cuda" not in self.device:
5930-
raise unittest.SkipTest("This test is only for CUDA")
5933+
if self.device not in ["cuda", "xpu"]:
5934+
raise unittest.SkipTest("This test is only for CUDA or XPU")
59315935

59325936
class ToCpuModel(nn.Module):
59335937
def forward(self, x):

test/inductor/test_aot_inductor_package.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
load_weights_to_pt2_contents,
2929
)
3030
from torch.testing._internal.common_cuda import _get_torch_cuda_version
31-
from torch.testing._internal.common_utils import IS_FBCODE, skipIfXpu
31+
from torch.testing._internal.common_utils import IS_FBCODE, skipIfXpu, TEST_CUDA
3232
from torch.testing._internal.inductor_utils import GPU_TYPE, HAS_GPU
3333

3434

@@ -267,9 +267,9 @@ def forward(self, x, y):
267267

268268
@unittest.skipIf(IS_FBCODE, "cmake won't work in fbcode")
269269
@unittest.skipIf(
270-
_get_torch_cuda_version() < (12, 6), "Test is only supported on CUDA 12.6+"
270+
TEST_CUDA and _get_torch_cuda_version() < (12, 6),
271+
"Test is only supported on CUDA 12.6+",
271272
)
272-
@skipIfXpu # build system may be different
273273
def test_compile_after_package(self):
274274
self.check_package_cpp_only()
275275

0 commit comments

Comments
 (0)