intel / torch-xpu-ops

Apache License 2.0
23 stars 15 forks source link

[Evaluated] Issues in test_tensor_creation_ops.py #264

Open daisyden opened 4 months ago

daisyden commented 4 months ago

šŸ› Describe the bug

  1. torch.random.fork_rng(devices=rng_device) does not support XPU backend TestRandomTensorCreationXPU.test_randperm_xpu image

  2. torch.xpu.FloatTensor is not supported. so tests like test_tensor_factory_gpu_type_inference and test_constructor_dtype had to be disabled.

  3. multiple device seems not supported, when I used ZE_AFFINITY_MASK to use tile 0 and tile 1, seems still only xpu:0 is detected.

image

image

This makes test_copy_from_tensor_mult_devices and test_copy_from_dlpack_mult_devices cannot work.

  1. RuntimeError: "eq_xpu" not implemented for 'UInt16' in case TestTensorCreationXPU.test_cat_out_fast_path_dim0_dim1_xpu_uint16, the same apply to TestTensorCreationXPU.test_cat_out_fast_path_dim0_dim1_xpu_uint32 and TestTensorCreationXPU.test_cat_out_fast_path_dim0_dim1_xpu_uint64
(xpupatch) daisyden@a4bf01946f22:~/workspace/skiplist/pytorch3/third_party/torch-xpu-ops/test/xpu$ PYTORCH_ENABLE_XPU_FALLBACK=1 PYTORCH_TEST_WITH_SLOW=1 pytest -v test_tensor_creation_ops_xpu.py -k 'test_cat_out_fast_path_dim0_dim1_xpu_uint16'
================================================================================= test session starts ==================================================================================
platform linux -- Python 3.10.14, pytest-8.2.0, pluggy-1.5.0 -- /home/daisyden/miniconda3/envs/xpupatch/bin/python
cachedir: .pytest_cache
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase(PosixPath('/home/daisyden/workspace/skiplist/pytorch3/third_party/torch-xpu-ops/test/xpu/.hypothesis/examples'))
rootdir: /home/daisyden/workspace/skiplist/pytorch3
configfile: pytest.ini
plugins: hypothesis-6.102.2
collected 620 items / 619 deselected / 1 selected                                                                                                                                      

test_tensor_creation_ops_xpu.py::TestTensorCreationXPU::test_cat_out_fast_path_dim0_dim1_xpu_uint16 
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> PDB set_trace (IO-capturing turned off) >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> /home/daisyden/miniconda3/envs/xpupatch/lib/python3.10/site-packages/torch/testing/_comparison.py(1015)_compare_regular_values_close()
-> matches = torch.isclose(
(Pdb) bt
  /home/daisyden/miniconda3/envs/xpupatch/bin/pytest(8)<module>()
-> sys.exit(console_main())
  /home/daisyden/miniconda3/envs/xpupatch/lib/python3.10/site-packages/_pytest/config/__init__.py(206)console_main()
-> code = main()
  /home/daisyden/miniconda3/envs/xpupatch/lib/python3.10/site-packages/_pytest/config/__init__.py(178)main()
-> ret: Union[ExitCode, int] = config.hook.pytest_cmdline_main(
  /home/daisyden/miniconda3/envs/xpupatch/lib/python3.10/site-packages/pluggy/_hooks.py(513)__call__()
-> return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
  /home/daisyden/miniconda3/envs/xpupatch/lib/python3.10/site-packages/pluggy/_manager.py(120)_hookexec()
-> return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  /home/daisyden/miniconda3/envs/xpupatch/lib/python3.10/site-packages/pluggy/_callers.py(103)_multicall()
-> res = hook_impl.function(*args)
  /home/daisyden/miniconda3/envs/xpupatch/lib/python3.10/site-packages/_pytest/main.py(332)pytest_cmdline_main()
-> return wrap_session(config, _main)
  /home/daisyden/miniconda3/envs/xpupatch/lib/python3.10/site-packages/_pytest/main.py(285)wrap_session()
-> session.exitstatus = doit(config, session) or 0
  /home/daisyden/miniconda3/envs/xpupatch/lib/python3.10/site-packages/_pytest/main.py(339)_main()
-> config.hook.pytest_runtestloop(session=session)
  /home/daisyden/miniconda3/envs/xpupatch/lib/python3.10/site-packages/pluggy/_hooks.py(513)__call__()
-> return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
  /home/daisyden/miniconda3/envs/xpupatch/lib/python3.10/site-packages/pluggy/_manager.py(120)_hookexec()
-> return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  /home/daisyden/miniconda3/envs/xpupatch/lib/python3.10/site-packages/pluggy/_callers.py(103)_multicall()
-> res = hook_impl.function(*args)
  /home/daisyden/miniconda3/envs/xpupatch/lib/python3.10/site-packages/_pytest/main.py(364)pytest_runtestloop()
-> item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
  /home/daisyden/miniconda3/envs/xpupatch/lib/python3.10/site-packages/pluggy/_hooks.py(513)__call__()
-> return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
  /home/daisyden/miniconda3/envs/xpupatch/lib/python3.10/site-packages/pluggy/_manager.py(120)_hookexec()
-> return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  /home/daisyden/miniconda3/envs/xpupatch/lib/python3.10/site-packages/pluggy/_callers.py(103)_multicall()
-> res = hook_impl.function(*args)
  /home/daisyden/miniconda3/envs/xpupatch/lib/python3.10/site-packages/_pytest/runner.py(116)pytest_runtest_protocol()
-> runtestprotocol(item, nextitem=nextitem)
  /home/daisyden/miniconda3/envs/xpupatch/lib/python3.10/site-packages/_pytest/runner.py(135)runtestprotocol()
-> reports.append(call_and_report(item, "call", log))
  /home/daisyden/miniconda3/envs/xpupatch/lib/python3.10/site-packages/_pytest/runner.py(240)call_and_report()
-> call = CallInfo.from_call(
  /home/daisyden/miniconda3/envs/xpupatch/lib/python3.10/site-packages/_pytest/runner.py(341)from_call()
-> result: Optional[TResult] = func()
  /home/daisyden/miniconda3/envs/xpupatch/lib/python3.10/site-packages/_pytest/runner.py(241)<lambda>()
-> lambda: runtest_hook(item=item, **kwds), when=when, reraise=reraise
  /home/daisyden/miniconda3/envs/xpupatch/lib/python3.10/site-packages/pluggy/_hooks.py(513)__call__()
-> return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
  /home/daisyden/miniconda3/envs/xpupatch/lib/python3.10/site-packages/pluggy/_manager.py(120)_hookexec()
-> return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  /home/daisyden/miniconda3/envs/xpupatch/lib/python3.10/site-packages/pluggy/_callers.py(103)_multicall()
-> res = hook_impl.function(*args)
  /home/daisyden/miniconda3/envs/xpupatch/lib/python3.10/site-packages/_pytest/runner.py(173)pytest_runtest_call()
-> item.runtest()
  /home/daisyden/miniconda3/envs/xpupatch/lib/python3.10/site-packages/_pytest/unittest.py(343)runtest()
-> testcase(result=self)
  /home/daisyden/miniconda3/envs/xpupatch/lib/python3.10/unittest/case.py(650)__call__()
-> return self.run(*args, **kwds)
  /home/daisyden/miniconda3/envs/xpupatch/lib/python3.10/site-packages/torch/testing/_internal/common_device_type.py(480)run()
-> super().run(result=result)
  /home/daisyden/miniconda3/envs/xpupatch/lib/python3.10/site-packages/torch/testing/_internal/common_utils.py(2883)run()
-> self._run_custom(
  /home/daisyden/miniconda3/envs/xpupatch/lib/python3.10/site-packages/torch/testing/_internal/common_utils.py(2855)_run_custom()
-> super_run(result=result)
  /home/daisyden/miniconda3/envs/xpupatch/lib/python3.10/unittest/case.py(591)run()
-> self._callTestMethod(testMethod)
  /home/daisyden/miniconda3/envs/xpupatch/lib/python3.10/unittest/case.py(549)_callTestMethod()
-> method()
  /home/daisyden/miniconda3/envs/xpupatch/lib/python3.10/site-packages/torch/testing/_internal/common_utils.py(2756)wrapper()
-> method(*args, **kwargs)
  /home/daisyden/miniconda3/envs/xpupatch/lib/python3.10/site-packages/torch/testing/_internal/common_device_type.py(419)instantiated_test()
-> result = test(self, **param_kwargs)
  /home/daisyden/workspace/skiplist/pytorch3/third_party/torch-xpu-ops/test/xpu/test_tensor_creation_ops_xpu.py(562)test_cat_out_fast_path_dim0_dim1()
-> self.assertEqual(a, b)
  /home/daisyden/miniconda3/envs/xpupatch/lib/python3.10/site-packages/torch/testing/_internal/common_utils.py(3600)assertEqual()
-> error_metas = not_close_error_metas(
  /home/daisyden/miniconda3/envs/xpupatch/lib/python3.10/site-packages/torch/testing/_comparison.py(1227)not_close_error_metas()
-> pair.compare()
  /home/daisyden/miniconda3/envs/xpupatch/lib/python3.10/site-packages/torch/testing/_comparison.py(707)compare()
-> self._compare_values(actual, expected)
  /home/daisyden/miniconda3/envs/xpupatch/lib/python3.10/site-packages/torch/testing/_comparison.py(834)_compare_values()
-> compare_fn(
> /home/daisyden/miniconda3/envs/xpupatch/lib/python3.10/site-packages/torch/testing/_comparison.py(1015)_compare_regular_values_close()
-> matches = torch.isclose(
(Pdb) p a
*** NameError: name 'a' is not defined
(Pdb) l
1010            identifier: Optional[Union[str, Callable[[str], str]]] = None,
1011        ) -> None:
1012            """Checks if the values of two tensors are close up to a desired tolerance."""
1013            import pdb
1014            pdb.set_trace()
1015 ->         matches = torch.isclose(
1016                actual, expected, rtol=rtol, atol=atol, equal_nan=equal_nan
1017            )
1018            if torch.all(matches):
1019                return
1020 
(Pdb) p actual
tensor([92, 56, 76, 84], device='xpu:0', dtype=torch.uint16)
(Pdb) p expected
tensor([92, 56, 76, 84], device='xpu:0', dtype=torch.uint16)
(Pdb) n
> /home/daisyden/miniconda3/envs/xpupatch/lib/python3.10/site-packages/torch/testing/_comparison.py(1016)_compare_regular_values_close()
-> actual, expected, rtol=rtol, atol=atol, equal_nan=equal_nan
(Pdb) 
> /home/daisyden/miniconda3/envs/xpupatch/lib/python3.10/site-packages/torch/testing/_comparison.py(1015)_compare_regular_values_close()
-> matches = torch.isclose(
(Pdb) 
RuntimeError: "eq_xpu" not implemented for 'UInt16'
> /home/daisyden/miniconda3/envs/xpupatch/lib/python3.10/site-packages/torch/testing/_comparison.py(1015)_compare_regular_values_close()
-> matches = torch.isclose(
(Pdb) 
  1. accuracy issue

image image

  1. sparse op isse image

Versions

Collecting environment information... PyTorch version: 2.4.0a0+git470723f Is debug build: False CUDA used to build PyTorch: None ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04.3 LTS (x86_64) GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0 Clang version: 14.0.0-1ubuntu1.1 CMake version: version 3.26.4 Libc version: glibc-2.35

Python version: 3.10.14 (main, May 6 2024, 19:42:50) [GCC 11.2.0] (64-bit runtime) Python platform: Linux-5.15.0-106-generic-x86_64-with-glibc2.35 Is CUDA available: False CUDA runtime version: No CUDA CUDA_MODULE_LOADING set to: N/A GPU models and configuration: No CUDA Nvidia driver version: No CUDA cuDNN version: No CUDA HIP runtime version: N/A MIOpen runtime version: N/A Is XNNPACK available: True

CPU: Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Address sizes: 52 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: 8 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 invpcid_single intel_ppin cdp_l2 ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi 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 avx_vnni avx512_bf16 wbnoinvd dtherm ida arat pln pts hwp hwp_act_window hwp_epp hwp_pkg_req 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 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 Retbleed: Not affected Vulnerability Spec rstack overflow: Not affected Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization Vulnerability Spectre v2: Mitigation; Enhanced 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] numpy==1.26.4 [pip3] optree==0.11.0 [pip3] torch==2.4.0a0+git470723f [conda] mkl-include 2024.1.0 intel_691 intel [conda] mkl-static 2024.1.0 intel_691 intel [conda] numpy 1.26.4 pypi_0 pypi [conda] optree 0.11.0 pypi_0 pypi [conda] torch 2.4.0a0+git470723f pypi_0 pypi

daisyden commented 4 months ago

To reproduce use branch daisyden/test_tensor_creation_ops, for example: cd test/xpu PYTORCH_ENABLE_XPU_FALLBACK=1 PYTORCH_TEST_WITH_SLOW=1 pytest -v test_tensor_creation_ops_xpu.py -k 'test_cat_out_fast_path_dim0_dim1_xpu_uint16'

fengyuan14 commented 4 months ago

Fixed an issue in eq and ne. Unsigned int data types are not supported in eq and ne.

fengyuan14 commented 4 months ago

Keep the issue open.

ZhiweiYan-96 commented 4 months ago

@daisyden @fengyuan14 I added XPU related class DispatchStub in my local env, I may separately push it or push it with overall codegen together. I need some testing on my local env at present.

ZhiweiYan-96 commented 3 months ago

hi @daisyden The modification of DispatchStub is filed at https://github.com/pytorch/pytorch/pull/126977/files#diff-54c373491da67eb31c3777457d7b043a49dd3966412edfd928ffd2013e4d6a54

daisyden commented 4 weeks ago

test_nn_xpu.py test_type also report AttributeError: module 'torch.xpu' has no attribute 'FloatTensor'