Skip to content

[xpu][test]profiler can not get the key of multi_tensor_apply_kernel #2313

@wincent8

Description

@wincent8

🐛 Describe the bug

when we enable the test_foreach.py, refer to the cuda path, we added the xpu path

elif (
            is_xpu
            and torch.autograd.kineto_available()
            and torch.profiler.ProfilerActivity.XPU
            in torch.profiler.supported_activities()
        ):
            with torch.profiler.profile() as p:
                actual = self.func(*inputs, **kwargs)
                # synchronize within the profiler context to make sure events happen before exiting
                torch.xpu.synchronize()
            keys = tuple([e.key for e in p.key_averages()])
            mta_called = any("multi_tensor_apply_kernel" in k for k in keys)
 
            assert mta_called == (expect_fastpath and (not zero_size)), (
                f"{mta_called=}, {expect_fastpath=}, {zero_size=}, {self.func.__name__=}, {keys=}"
            )

about 1400 case will failed with AssertionError like below.

test/test_foreach.py::TestForeachXPU::test_parity__foreach_zero_fastpath_outplace_xpu_uint8 FAILED [0.2256s]
 
==================================================================================== FAILURES =====================================================================================
______________________________________________________ TestForeachXPU.test_parity__foreach_zero_fastpath_outplace_xpu_uint8 _______________________________________________________
Traceback (most recent call last):
  File "/home/sdp/wliao2/pytorch/test/test_foreach.py", line 262, in test_parity
    actual = func(
  File "/home/sdp/wliao2/pytorch/test/test_foreach.py", line 121, in __call__
    assert mta_called == (expect_fastpath and (not zero_size)), (
AssertionError: mta_called=False, expect_fastpath=True, zero_size=False, self.func.__name__='_foreach_zero_', keys=('aten::_foreach_zero_', 'aten::empty', 'urUSMHostAlloc', 'urEnqueueUSMMemcpy', 'Memcpy H2D (HOST -> DEVICE)', 'urEnqueueKernelLaunch', 'at::native::xpu::MultiTensorApplyKernelFunctor<at::native::xpu::TLMetaForAddress<1>*, at::native::xpu::TLMetaForWG*, at::native::xpu::ZeroFunctor<unsigned char, 1, 1, 0>>')
 
During handling of the above exception, another exception occurred:
 
Traceback (most recent call last):
  File "/home/sdp/miniforge-pypy3/envs/wliao2/lib/python3.10/site-packages/torch/testing/_internal/common_device_type.py", line 1151, in test_wrapper
    return test(*args, **kwargs)
  File "/home/sdp/miniforge-pypy3/envs/wliao2/lib/python3.10/unittest/mock.py", line 1818, in _inner
    return f(*args, **kw)
  File "/home/sdp/wliao2/pytorch/test/test_foreach.py", line 270, in test_parity
    with self.assertRaises(type(e)):
  File "/home/sdp/miniforge-pypy3/envs/wliao2/lib/python3.10/unittest/case.py", line 226, in __exit__
    self._raiseFailure("{} not raised".format(exc_name))
  File "/home/sdp/miniforge-pypy3/envs/wliao2/lib/python3.10/unittest/case.py", line 163, in _raiseFailure
    raise self.test_case.failureException(msg)
AssertionError: AssertionError not raised
 
The above exception was the direct cause of the following exception:
 
Traceback (most recent call last):
  File "/home/sdp/miniforge-pypy3/envs/wliao2/lib/python3.10/site-packages/torch/testing/_internal/common_utils.py", line 3300, in wrapper
    method(*args, **kwargs)
  File "/home/sdp/miniforge-pypy3/envs/wliao2/lib/python3.10/site-packages/torch/testing/_internal/common_device_type.py", line 428, in instantiated_test
    result = test(self, **param_kwargs)
  File "/home/sdp/miniforge-pypy3/envs/wliao2/lib/python3.10/site-packages/torch/testing/_internal/common_utils.py", line 1707, in wrapper
    fn(*args, **kwargs)
  File "/home/sdp/miniforge-pypy3/envs/wliao2/lib/python3.10/site-packages/torch/testing/_internal/common_device_type.py", line 1163, in test_wrapper
    raise e_tracked from e
Exception: AssertionError not raised
 
Caused by sample input at index 0: SampleInput(input=TensorList[Tensor[size=(20, 20), device="xpu:0", dtype=torch.uint8], Tensor[size=(19, 19), device="xpu:0", dtype=torch.uint8], Tensor[size=(18, 18), device="xpu:0", dtype=torch.uint8], Tensor[size=(17, 17), device="xpu:0", dtype=torch.uint8], Tensor[size=(16, 16), device="xpu:0", dtype=torch.uint8], Tensor[size=(15, 15), device="xpu:0", dtype=torch.uint8], Tensor[size=(14, 14), device="xpu:0", dtype=torch.uint8], Tensor[size=(13, 13), device="xpu:0", dtype=torch.uint8], Tensor[size=(12, 12), device="xpu:0", dtype=torch.uint8], Tensor[size=(11, 11), device="xpu:0", dtype=torch.uint8], Tensor[size=(10, 10), device="xpu:0", dtype=torch.uint8], Tensor[size=(9, 9), device="xpu:0", dtype=torch.uint8], Tensor[size=(8, 8), device="xpu:0", dtype=torch.uint8], Tensor[size=(7, 7), device="xpu:0", dtype=torch.uint8], Tensor[size=(6, 6), device="xpu:0", dtype=torch.uint8], Tensor[size=(5, 5), device="xpu:0", dtype=torch.uint8], Tensor[size=(4, 4), device="xpu:0", dtype=torch.uint8], Tensor[size=(3, 3), device="xpu:0", dtype=torch.uint8], Tensor[size=(2, 2), device="xpu:0", dtype=torch.uint8], Tensor[size=(1, 1), device="xpu:0", dtype=torch.uint8]], args=(), kwargs={}, broadcasts_input=False, name='')
 
To execute this test, run the following from the base repo dir:
    PYTORCH_OPINFO_SAMPLE_INPUT_INDEX=0 python test/test_foreach.py TestForeachXPU.test_parity__foreach_zero_fastpath_outplace_xpu_uint8
 
This message can be suppressed by setting PYTORCH_PRINT_REPRO_ON_FAILURE=0

and if we change the "mta_called = any("multi_tensor_apply_kernel" in k for k in keys)" to "mta_called = any("MultiTensorApplyKernelFunctor" in k for k in keys)", about 700 case will pass and leave 700 failed. the error as below,

TestForeachXPU.test_foreach_copy_with_multi_dtypes__foreach_copy_xpu_int16 ____________________________________________________
Traceback (most recent call last):
  File "/home/sdp/miniforge-pypy3/envs/wliao2/lib/python3.10/site-packages/torch/testing/_internal/common_device_type.py", line 1151, in test_wrapper
    return test(*args, **kwargs)
  File "/home/sdp/miniforge-pypy3/envs/wliao2/lib/python3.10/unittest/mock.py", line 1818, in _inner
    return f(*args, **kw)
  File "/home/sdp/miniforge-pypy3/envs/wliao2/lib/python3.10/site-packages/torch/testing/_internal/common_device_type.py", line 1435, in only_fn
    return fn(slf, *args, **kwargs)
  File "/home/sdp/wliao2/pytorch/test/test_foreach.py", line 1410, in test_foreach_copy_with_multi_dtypes
    out = foreach_copy_(
  File "/home/sdp/wliao2/pytorch/test/test_foreach.py", line 121, in __call__
    assert mta_called == (expect_fastpath and (not zero_size)), (
AssertionError: mta_called=False, expect_fastpath=True, zero_size=False, self.func.__name__='_foreach_copy_', keys=('aten::_foreach_copy_', 'aten::copy_', 'urEnqueueKernelLaunch', 'at::native::xpu::UnrolledElementwiseKernel<at::native::xpu::CopyScalarFunc<float>, at::detail::Array<char*, 2>, TrivialOffsetCalculator<1, unsigned int>, TrivialOffsetCalculator<1, unsigned int>, at::native::memory::LoadWithCast<1>, at::native::memory::StoreWithCast<1> >')
 
The above exception was the direct cause of the following exception:
 
Traceback (most recent call last):
  File "/home/sdp/miniforge-pypy3/envs/wliao2/lib/python3.10/site-packages/torch/testing/_internal/common_utils.py", line 3300, in wrapper
    method(*args, **kwargs)
  File "/home/sdp/miniforge-pypy3/envs/wliao2/lib/python3.10/site-packages/torch/testing/_internal/common_device_type.py", line 428, in instantiated_test
    result = test(self, **param_kwargs)
  File "/home/sdp/miniforge-pypy3/envs/wliao2/lib/python3.10/site-packages/torch/testing/_internal/common_utils.py", line 1707, in wrapper
    fn(*args, **kwargs)
  File "/home/sdp/miniforge-pypy3/envs/wliao2/lib/python3.10/site-packages/torch/testing/_internal/common_device_type.py", line 1163, in test_wrapper
    raise e_tracked from e
Exception: mta_called=False, expect_fastpath=True, zero_size=False, self.func.__name__='_foreach_copy_', keys=('aten::_foreach_copy_', 'aten::copy_', 'urEnqueueKernelLaunch', 'at::native::xpu::UnrolledElementwiseKernel<at::native::xpu::CopyScalarFunc<float>, at::detail::Array<char*, 2>, TrivialOffsetCalculator<1, unsigned int>, TrivialOffsetCalculator<1, unsigned int>, at::native::memory::LoadWithCast<1>, at::native::memory::StoreWithCast<1> >')
 
Caused by sample input at index 0: SampleInput(input=TensorList[Tensor[size=(20, 20), device="xpu:0", dtype=torch.int16], Tensor[size=(19, 19), device="xpu:0", dtype=torch.int16], Tensor[size=(18, 18), device="xpu:0", dtype=torch.int16], Tensor[size=(17, 17), device="xpu:0", dtype=torch.int16], Tensor[size=(16, 16), device="xpu:0", dtype=torch.int16], Tensor[size=(15, 15), device="xpu:0", dtype=torch.int16], Tensor[size=(14, 14), device="xpu:0", dtype=torch.int16], Tensor[size=(13, 13), device="xpu:0", dtype=torch.int16], Tensor[size=(12, 12), device="xpu:0", dtype=torch.int16], Tensor[size=(11, 11), device="xpu:0", dtype=torch.int16], Tensor[size=(10, 10), device="xpu:0", dtype=torch.int16], Tensor[size=(9, 9), device="xpu:0", dtype=torch.int16], Tensor[size=(8, 8), device="xpu:0", dtype=torch.int16], Tensor[size=(7, 7), device="xpu:0", dtype=torch.int16], Tensor[size=(6, 6), device="xpu:0", dtype=torch.int16], Tensor[size=(5, 5), device="xpu:0", dtype=torch.int16], Tensor[size=(4, 4), device="xpu:0", dtype=torch.int16], Tensor[size=(3, 3), device="xpu:0", dtype=torch.int16], Tensor[size=(2, 2), device="xpu:0", dtype=torch.int16], Tensor[size=(1, 1), device="xpu:0", dtype=torch.int16]], args=(TensorList[Tensor[size=(20, 20), device="xpu:0", dtype=torch.int16], Tensor[size=(19, 19), device="xpu:0", dtype=torch.int16], Tensor[size=(18, 18), device="xpu:0", dtype=torch.int16], Tensor[size=(17, 17), device="xpu:0", dtype=torch.int16], Tensor[size=(16, 16), device="xpu:0", dtype=torch.int16], Tensor[size=(15, 15), device="xpu:0", dtype=torch.int16], Tensor[size=(14, 14), device="xpu:0", dtype=torch.int16], Tensor[size=(13, 13), device="xpu:0", dtype=torch.int16], Tensor[size=(12, 12), device="xpu:0", dtype=torch.int16], Tensor[size=(11, 11), device="xpu:0", dtype=torch.int16], Tensor[size=(10, 10), device="xpu:0", dtype=torch.int16], Tensor[size=(9, 9), device="xpu:0", dtype=torch.int16], Tensor[size=(8, 8), device="xpu:0", dtype=torch.int16], Tensor[size=(7, 7), device="xpu:0", dtype=torch.int16], Tensor[size=(6, 6), device="xpu:0", dtype=torch.int16], Tensor[size=(5, 5), device="xpu:0", dtype=torch.int16], Tensor[size=(4, 4), device="xpu:0", dtype=torch.int16], Tensor[size=(3, 3), device="xpu:0", dtype=torch.int16], Tensor[size=(2, 2), device="xpu:0", dtype=torch.int16], Tensor[size=(1, 1), device="xpu:0", dtype=torch.int16]]), kwargs={}, broadcasts_input=False, name='')
 
To execute this test, run the following from the base repo dir:
    PYTORCH_OPINFO_SAMPLE_INPUT_INDEX=0 python test/test_foreach.py TestForeachXPU.test_foreach_copy_with_multi_dtypes__foreach_copy_xpu_int16
 
This message can be suppressed by setting PYTORCH_PRINT_REPRO_ON_FAILURE=0

Versions

Collecting environment information...
PyTorch version: N/A
Is debug build: N/A
CUDA used to build PyTorch: N/A
ROCM used to build PyTorch: N/A

OS: Ubuntu 24.04.2 LTS (x86_64)
GCC version: (Ubuntu 11.4.0-9ubuntu1) 11.4.0
Clang version: 18.1.3 (1ubuntu1)
CMake version: version 3.31.6
Libc version: glibc-2.39

Python version: 3.10.0 | packaged by conda-forge | (default, Nov 20 2021, 02:24:10) [GCC 9.4.0] (64-bit runtime)
Python platform: Linux-6.8.0-38-generic-x86_64-with-glibc2.39
Is CUDA available: N/A
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: Could not collect
Nvidia driver version: Could not collect
cuDNN version: Could not collect
Is XPU available: N/A
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: N/A

CPU:
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Address sizes: 46 bits physical, 57 bits virtual
Byte Order: Little Endian
CPU(s): 224
On-line CPU(s) list: 0-223
Vendor ID: GenuineIntel
Model name: Intel(R) Xeon(R) Platinum 8480+
CPU family: 6
Model: 143
Thread(s) per core: 2
Core(s) per socket: 56
Socket(s): 2
Stepping: 6
CPU(s) scaling MHz: 100%
CPU max MHz: 3800.0000
CPU min MHz: 800.0000
BogoMIPS: 4000.00
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cat_l2 cdp_l3 intel_ppin cdp_l2 ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb intel_pt avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local split_lock_detect user_shstk avx_vnni avx512_bf16 wbnoinvd dtherm ida arat pln pts vnmi avx512vbmi umip pku ospke waitpkg avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg tme avx512_vpopcntdq la57 rdpid bus_lock_detect cldemote movdiri movdir64b enqcmd fsrm md_clear serialize tsxldtrk pconfig arch_lbr ibt amx_bf16 avx512_fp16 amx_tile amx_int8 flush_l1d arch_capabilities
Virtualization: VT-x
L1d cache: 5.3 MiB (112 instances)
L1i cache: 3.5 MiB (112 instances)
L2 cache: 224 MiB (112 instances)
L3 cache: 210 MiB (2 instances)
NUMA node(s): 2
NUMA node0 CPU(s): 0-55,112-167
NUMA node1 CPU(s): 56-111,168-223
Vulnerability Gather data sampling: Not affected
Vulnerability Itlb multihit: Not affected
Vulnerability L1tf: Not affected
Vulnerability Mds: Not affected
Vulnerability Meltdown: Not affected
Vulnerability Mmio stale data: Not affected
Vulnerability Reg file data sampling: Not affected
Vulnerability Retbleed: Not affected
Vulnerability Spec rstack overflow: Not affected
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2: Mitigation; Enhanced / Automatic IBRS; IBPB conditional; RSB filling; PBRSB-eIBRS SW sequence; BHI BHI_DIS_S
Vulnerability Srbds: Not affected
Vulnerability Tsx async abort: Not affected

Versions of relevant libraries:
[pip3] dpcpp-cpp-rt==2025.2.1
[pip3] flake8==7.3.0
[pip3] flake8-bugbear==24.12.12
[pip3] flake8-comprehensions==3.16.0
[pip3] flake8-executable==2.1.3
[pip3] flake8-logging-format==2024.24.12
[pip3] flake8-pyi==25.5.0
[pip3] flake8_simplify==0.22.0
[pip3] impi-rt==2021.16.1
[pip3] intel-cmplr-lib-rt==2025.2.1
[pip3] intel-cmplr-lib-ur==2025.2.1
[pip3] intel-cmplr-lic-rt==2025.2.1
[pip3] intel-opencl-rt==2025.2.1
[pip3] intel-openmp==2025.2.1
[pip3] intel-pti==0.13.1
[pip3] intel-sycl-rt==2025.2.1
[pip3] mkl==2025.2.0
[pip3] mypy==1.16.0
[pip3] mypy_extensions==1.1.0
[pip3] numpy==1.26.4
[pip3] oneccl==2021.16.1
[pip3] oneccl-devel==2021.16.1
[pip3] onemkl-sycl-blas==2025.2.0
[pip3] onemkl-sycl-dft==2025.2.0
[pip3] onemkl-sycl-lapack==2025.2.0
[pip3] onemkl-sycl-rng==2025.2.0
[pip3] onemkl-sycl-sparse==2025.2.0
[pip3] onnx==1.19.1
[pip3] onnx-ir==0.1.12
[pip3] onnxscript==0.5.4
[pip3] optree==0.17.0
[pip3] pytorch-triton-xpu==3.5.0+git1b0418a9
[pip3] tbb==2022.2.0
[pip3] tcmlib==1.4.0
[pip3] torch==2.10.0.dev20251030+xpu
[pip3] umf==0.11.0
[conda] dpcpp-cpp-rt 2025.2.1 pypi_0 pypi
[conda] impi-rt 2021.16.1 pypi_0 pypi
[conda] intel-cmplr-lib-rt 2025.2.1 pypi_0 pypi
[conda] intel-cmplr-lib-ur 2025.2.1 pypi_0 pypi
[conda] intel-cmplr-lic-rt 2025.2.1 pypi_0 pypi
[conda] intel-opencl-rt 2025.2.1 pypi_0 pypi
[conda] intel-openmp 2025.2.1 pypi_0 pypi
[conda] intel-pti 0.13.1 pypi_0 pypi
[conda] intel-sycl-rt 2025.2.1 pypi_0 pypi
[conda] mkl 2025.2.0 pypi_0 pypi
[conda] numpy 1.26.4 pypi_0 pypi
[conda] oneccl 2021.16.1 pypi_0 pypi
[conda] oneccl-devel 2021.16.1 pypi_0 pypi
[conda] onemkl-sycl-blas 2025.2.0 pypi_0 pypi
[conda] onemkl-sycl-dft 2025.2.0 pypi_0 pypi
[conda] onemkl-sycl-lapack 2025.2.0 pypi_0 pypi
[conda] onemkl-sycl-rng 2025.2.0 pypi_0 pypi
[conda] onemkl-sycl-sparse 2025.2.0 pypi_0 pypi
[conda] optree 0.17.0 pypi_0 pypi
[conda] pytorch-triton-xpu 3.5.0+git1b0418a9 pypi_0 pypi
[conda] tbb 2022.2.0 pypi_0 pypi
[conda] tcmlib 1.4.0 pypi_0 pypi
[conda] torch 2.10.0.dev20251030+xpu pypi_0 pypi
[conda] torchfix 0.4.0 pypi_0 pypi
[conda] umf 0.11.0 pypi_0 pypi

Metadata

Metadata

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions