You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
got below error message
Traceback (most recent call last):
File "/home/intel/sn/xpu.py", line 37, in
layer_test(nn.LayerNorm([1, 28, 28]))
File "/home/intel/sn/xpu.py", line 16, in layer_test
output_tensor = layer(input_tensor)
File "/home/intel/sn/sd-ipex/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1532, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/home/intel/sn/sd-ipex/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1541, in _call_impl
return forward_call(*args, **kwargs)
File "/home/intel/sn/sd-ipex/lib/python3.10/site-packages/torch/nn/modules/normalization.py", line 201, in forward
return F.layer_norm(
File "/home/intel/sn/sd-ipex/lib/python3.10/site-packages/torch/nn/functional.py", line 2573, in layer_norm
return torch.layer_norm(input, normalized_shape, weight, bias, eps, torch.backends.cudnn.enabled)
RuntimeError: expected scalar type Float but found Half
Had a quick test on CPU & CUDA.
CPU raises a similar error: RuntimeError: mixed dtype (CPU): expect parameter to have scalar type of Float
CUDA test passed: success torch.float32 cuda:0
This error is expected on the CPU. The CPU autocast handles layernorm as fallthrough. If it is mixed data types, then the weight should be fp32 and the input should be a lower precision data type. CUDA puts layernorm into the fp32 cast policy so cuda can pass the example, and generate a fp32 result.
Describe the bug
when running below code, got "RuntimeError: expected scalar type Float but found Half "
import torch
import torch.nn as nn
import intel_extension_for_pytorch as ipex
def layer_test(layer):
with torch.amp.autocast('xpu'):
layer = layer.to(device, torch.float16)
input_tensor = torch.randn(1, 1, 28, 28).to(device, torch.float32)
output_tensor = layer(input_tensor)
print('success', output_tensor.dtype, output_tensor.device)
layer_test(nn.LayerNorm([1, 28, 28]))
got below error message
Traceback (most recent call last):
File "/home/intel/sn/xpu.py", line 37, in
layer_test(nn.LayerNorm([1, 28, 28]))
File "/home/intel/sn/xpu.py", line 16, in layer_test
output_tensor = layer(input_tensor)
File "/home/intel/sn/sd-ipex/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1532, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/home/intel/sn/sd-ipex/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1541, in _call_impl
return forward_call(*args, **kwargs)
File "/home/intel/sn/sd-ipex/lib/python3.10/site-packages/torch/nn/modules/normalization.py", line 201, in forward
return F.layer_norm(
File "/home/intel/sn/sd-ipex/lib/python3.10/site-packages/torch/nn/functional.py", line 2573, in layer_norm
return torch.layer_norm(input, normalized_shape, weight, bias, eps, torch.backends.cudnn.enabled)
RuntimeError: expected scalar type Float but found Half
Versions
Collecting environment information...
PyTorch version: 2.3.1+cxx11.abi
PyTorch CXX11 ABI: Yes
IPEX version: 2.3.110+xpu
IPEX commit: 95c9459
Build type: Release
OS: Ubuntu 22.04.4 LTS (x86_64)
GCC version: (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0
Clang version: N/A
IGC version: N/A
CMake version: version 3.22.1
Libc version: glibc-2.35
Python version: 3.10.12 (main, Sep 11 2024, 15:47:36) [GCC 11.4.0] (64-bit runtime)
Python platform: Linux-6.5.0-18-generic-x86_64-with-glibc2.35
Is XPU available: True
DPCPP runtime: N/A
MKL version: N/A
GPU models and configuration onboard:
N/A
GPU models and configuration detected:
Driver version:
CPU:
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Address sizes: 46 bits physical, 48 bits virtual
Byte Order: Little Endian
CPU(s): 12
On-line CPU(s) list: 0-11
Vendor ID: GenuineIntel
Model name: 12th Gen Intel(R) Core(TM) i7-12700
CPU family: 6
Model: 151
Thread(s) per core: 1
Core(s) per socket: 12
Socket(s): 1
Stepping: 2
CPU max MHz: 4900.0000
CPU min MHz: 800.0000
BogoMIPS: 4224.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 sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l2 cdp_l2 ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdt_a rdseed adx smap clflushopt clwb intel_pt sha_ni xsaveopt xsavec xgetbv1 xsaves split_lock_detect avx_vnni dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp hwp_pkg_req hfi vnmi umip pku ospke waitpkg gfni vaes vpclmulqdq tme rdpid movdiri movdir64b fsrm md_clear serialize pconfig arch_lbr ibt flush_l1d arch_capabilities
Virtualization: VT-x
L1d cache: 512 KiB (12 instances)
L1i cache: 512 KiB (12 instances)
L2 cache: 12 MiB (9 instances)
L3 cache: 25 MiB (1 instance)
NUMA node(s): 1
NUMA node0 CPU(s): 0-11
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
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
Vulnerability Srbds: Not affected
Vulnerability Tsx async abort: Not affected
Versions of relevant libraries:
[pip] dpcpp-cpp-rt==2024.2.1
[pip] impi-devel==2021.13.1
[pip] impi-rt==2021.13.1
[pip] intel-cmplr-lib-rt==2024.2.1
[pip] intel-cmplr-lib-ur==2024.2.1
[pip] intel-cmplr-lic-rt==2024.2.1
[pip] intel_extension_for_pytorch==2.3.110+xpu
[pip] intel-opencl-rt==2024.2.1
[pip] intel-openmp==2024.2.1
[pip] intel-sycl-rt==2024.2.1
[pip] mkl==2024.2.1
[pip] mkl-dpcpp==2024.2.1
[pip] numpy==2.1.3
[pip] oneccl-bind-pt==2.3.100+xpu
[pip] oneccl-devel==2021.13.1
[pip] onemkl-sycl-blas==2024.2.1
[pip] onemkl-sycl-datafitting==2024.2.1
[pip] onemkl-sycl-dft==2024.2.1
[pip] onemkl-sycl-lapack==2024.2.1
[pip] onemkl-sycl-rng==2024.2.1
[pip] onemkl-sycl-sparse==2024.2.1
[pip] onemkl-sycl-stats==2024.2.1
[pip] onemkl-sycl-vm==2024.2.1
[pip] torch==2.3.1+cxx11.abi
[pip] torchaudio==2.3.1+cxx11.abi
[pip] torchvision==0.18.1+cxx11.abi
The text was updated successfully, but these errors were encountered: