Skip to content

Error while inferencing phi3 or phi4 using ipex on cpu #784

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Kshubham20-score opened this issue Feb 9, 2025 · 2 comments
Open

Error while inferencing phi3 or phi4 using ipex on cpu #784

Kshubham20-score opened this issue Feb 9, 2025 · 2 comments
Assignees

Comments

@Kshubham20-score
Copy link

Describe the bug

OMP_NUM_THREADS=56 numactl -m 0 -C 0-55 python run.py --benchmark -m /home/shubham/quantization/phi4-14B/phi-4  --dtype bfloat16 --ipex 
[shubham@cluster-1u inference]$ OMP_NUM_THREADS=56 numactl -m 0 -C 0-55 python run.py --benchmark -m /home/shubham/quantization/phi4-14B/phi-4  --dtype bfloat16 --ipex 
LLM RUNTIME INFO: running model geneartion...
Namespace(model_id='/home/shubham/quantization/phi4-14B/phi-4', dtype='bfloat16', input_tokens='32', max_new_tokens=32, prompt=None, streaming=False, image_url='https://images.cocodataset.org/val2017/000000039769.jpg', audio='example.flac', config_file=None, greedy=False, ipex=True, deployment_mode=True, torch_compile=False, backend='ipex', profile=False, benchmark=True, num_iter=100, num_warmup=10, batch_size=1, token_latency=False, cache_weight_for_large_batch=False, vision_text_model=False)
Loading checkpoint shards: 100%|█████████████████████████████████████████████| 13/13 [00:03<00:00,  4.05it/s]
/home/shubham/miniconda3/lib/python3.12/site-packages/intel_extension_for_pytorch/utils/_logger.py:71: UserWarning: [MissingDependency]The transformers version is 4.47.0, bigger than validated 4.45.0, may have risks
  warnings.warn(msg)
2025-02-09 09:19:34,147 - _logger.py - IPEX - WARNING - [MissingDependency]The transformers version is 4.47.0, bigger than validated 4.45.0, may have risks
[INFO] SINGLE_INSTANCE MODE.
/home/shubham/miniconda3/lib/python3.12/site-packages/intel_extension_for_pytorch/transformers/optimize.py:1499: FutureWarning: `torch.cpu.amp.autocast(args...)` is deprecated. Please use `torch.amp.autocast('cpu', args...)` instead.
  with torch.no_grad(), torch.cpu.amp.autocast(
/home/shubham/miniconda3/lib/python3.12/site-packages/transformers/modeling_utils.py:5055: FutureWarning: `_is_quantized_training_enabled` is going to be deprecated in transformers 4.39.0. Please use `model.hf_quantizer.is_trainable` instead
  warnings.warn(
`loss_type=None` was set in the config but it is unrecognised.Using the default loss: `ForCausalLMLoss`.
/home/shubham/miniconda3/lib/python3.12/site-packages/transformers/modeling_attn_mask_utils.py:116: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  if (input_shape[-1] > 1 or self.sliding_window is not None) and self.is_causal:
/home/shubham/miniconda3/lib/python3.12/site-packages/transformers/modeling_attn_mask_utils.py:164: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  if past_key_values_length > 0:
/home/shubham/miniconda3/lib/python3.12/site-packages/intel_extension_for_pytorch/transformers/models/reference/fusions/mha_fusion.py:197: TracerWarning: torch.tensor results are registered as constants in the trace. You can safely ignore this warning if you use this function to create tensors out of constant variables that would be the same every time you call this function. In any other case, this might cause the trace to be incorrect.
  torch.tensor(self.inv_freq).contiguous(),
/home/shubham/miniconda3/lib/python3.12/site-packages/intel_extension_for_pytorch/transformers/models/reference/fusions/mha_fusion.py:197: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).
  torch.tensor(self.inv_freq).contiguous(),
/home/shubham/miniconda3/lib/python3.12/site-packages/intel_extension_for_pytorch/transformers/models/reference/fusions/mha_fusion.py:198: TracerWarning: torch.tensor results are registered as constants in the trace. You can safely ignore this warning if you use this function to create tensors out of constant variables that would be the same every time you call this function. In any other case, this might cause the trace to be incorrect.
  torch.tensor(self.max_seq_len_cached).contiguous(),
/home/shubham/miniconda3/lib/python3.12/site-packages/intel_extension_for_pytorch/transformers/models/reference/fusions/mha_fusion.py:199: TracerWarning: torch.tensor results are registered as constants in the trace. You can safely ignore this warning if you use this function to create tensors out of constant variables that would be the same every time you call this function. In any other case, this might cause the trace to be incorrect.
  torch.tensor(self.max_position_embeddings).contiguous(),
/home/shubham/miniconda3/lib/python3.12/site-packages/intel_extension_for_pytorch/transformers/models/reference/fusions/mha_fusion.py:206: TracerWarning: torch.tensor results are registered as constants in the trace. You can safely ignore this warning if you use this function to create tensors out of constant variables that would be the same every time you call this function. In any other case, this might cause the trace to be incorrect.
  torch.tensor(seq_len).contiguous(),
/home/shubham/miniconda3/lib/python3.12/site-packages/intel_extension_for_pytorch/transformers/models/reference/fusions/mha_fusion.py:206: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).
  torch.tensor(seq_len).contiguous(),
/home/shubham/miniconda3/lib/python3.12/site-packages/intel_extension_for_pytorch/transformers/models/reference/fusions/mha_fusion.py:207: TracerWarning: torch.tensor results are registered as constants in the trace. You can safely ignore this warning if you use this function to create tensors out of constant variables that would be the same every time you call this function. In any other case, this might cause the trace to be incorrect.
  torch.tensor(rope_type).contiguous(),
/home/shubham/miniconda3/lib/python3.12/site-packages/intel_extension_for_pytorch/transformers/models/reference/fusions/mha_fusion.py:210: TracerWarning: Converting a tensor to a Python number might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  self.max_seq_len_cached = max_seq_len_cached.item()
/home/shubham/miniconda3/lib/python3.12/site-packages/intel_extension_for_pytorch/transformers/models/cpu/fusions/mha_fusion.py:234: TracerWarning: torch.tensor results are registered as constants in the trace. You can safely ignore this warning if you use this function to create tensors out of constant variables that would be the same every time you call this function. In any other case, this might cause the trace to be incorrect.
  seq_info = torch.tensor(
/home/shubham/miniconda3/lib/python3.12/site-packages/intel_extension_for_pytorch/transformers/models/cpu/fusions/mha_fusion.py:234: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).
  seq_info = torch.tensor(
/home/shubham/miniconda3/lib/python3.12/site-packages/intel_extension_for_pytorch/transformers/models/reference/models.py:4428: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  and hidden_states.size(1) != 1
ipex.llm.optimize has set the optimized or quantization model for model.generate()
---- Prompt size: 32
/home/shubham/quantization/intel-extension-for-pytorch/examples/cpu/llm/inference/single_instance/run_generation.py:343: FutureWarning: `torch.cpu.amp.autocast(args...)` is deprecated. Please use `torch.amp.autocast('cpu', args...)` instead.
  with torch.inference_mode(), torch.no_grad(), torch.cpu.amp.autocast(
/home/shubham/miniconda3/lib/python3.12/site-packages/transformers/generation/configuration_utils.py:628: UserWarning: `do_sample` is set to `False`. However, `temperature` is set to `0.9` -- this flag is only used in sample-based generation modes. You should set `do_sample=True` or unset `temperature`.
  warnings.warn(
Traceback (most recent call last):
  File "/home/shubham/quantization/intel-extension-for-pytorch/examples/cpu/llm/inference/single_instance/run_generation.py", line 382, in <module>
    output = model.generate(input_ids, **generate_kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/shubham/miniconda3/lib/python3.12/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/shubham/miniconda3/lib/python3.12/site-packages/transformers/generation/utils.py", line 2283, in generate
    result = self._beam_search(
             ^^^^^^^^^^^^^^^^^^
  File "/home/shubham/miniconda3/lib/python3.12/site-packages/intel_extension_for_pytorch/transformers/generation/beam_search.py", line 212, in _beam_search
    if model_inputs["past_key_values"] is None:
       ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
KeyError: 'past_key_values'
LLM RUNTIME ERROR: Running generation task failed. Quit.

Versions

Collecting environment information...

PyTorch version: 2.5.1+cpu
PyTorch CXX11 ABI: No
IPEX version: 2.5.0+git6973d57
IPEX commit: 6973d57
Build type: Release

OS: Red Hat Enterprise Linux 9.5 (Plow) (x86_64)
GCC version: (conda-forge gcc 11.4.0-13) 11.4.0
Clang version: N/A
IGC version: N/A
CMake version: version 3.28.4
Libc version: glibc-2.34

Python version: 3.12.8 | packaged by conda-forge | (main, Dec 5 2024, 14:24:40) [GCC 13.3.0] (64-bit runtime)
Python platform: Linux-5.14.0-503.21.1.el9_5.x86_64-x86_64-with-glibc2.34
Is XPU available: False
DPCPP runtime: N/A
MKL version: N/A

GPU models and configuration onboard:
N/A

GPU models and configuration detected:
N/A

Driver version:

  • intel_opencl: N/A
  • level_zero: 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): 112
On-line CPU(s) list: 0-111
Vendor ID: GenuineIntel
Model name: Intel(R) Xeon(R) Platinum 8480C
CPU family: 6
Model: 143
Thread(s) per core: 2
Core(s) per socket: 56
Socket(s): 1
Stepping: 8
CPU(s) scaling MHz: 33%
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 avx_vnni avx512_bf16 wbnoinvd dtherm ida arat pln pts hwp hwp_act_window hwp_epp hwp_pkg_req 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: 2.6 MiB (56 instances)
L1i cache: 1.8 MiB (56 instances)
L2 cache: 112 MiB (56 instances)
L3 cache: 105 MiB (1 instance)
NUMA node(s): 1
NUMA node0 CPU(s): 0-111
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:
[conda] c-compiler 1.5.2 h0b41bf4_0 conda-forge
[conda] cxx-compiler 1.5.2 hf52228f_0 conda-forge
[conda] exceptiongroup 1.2.2 pyhd8ed1ab_1 conda-forge
[conda] intel-extension-for-pytorch 2.5.0+git6973d57 pypi_0 pypi
[conda] numpy 1.26.4 pypi_0 pypi
[conda] oneccl-bind-pt 2.5.0+cpu pypi_0 pypi
[conda] torch 2.5.1+cpu pypi_0 pypi
[conda] torchaudio 2.5.0+cpu pypi_0 pypi
[conda] torchvision 0.20.1+cpu pypi_0 pypi
[conda] transformers 4.47.0 pypi_0 pypi

@devpramod devpramod self-assigned this Feb 12, 2025
@devpramod
Copy link
Contributor

Hi @Kshubham20-score
Phi-4 is currently not part of the validated list. Please stay tuned for an update.
As for Phi-3, we will investigate the issue and get back to you.

@ZailiWang
Copy link
Contributor

Hi @Kshubham20-score
We have day-0 support for the recent released Phi4 mini and Phi4 multimodal. Please check the guidance if needed.

For the Phi3 error you encountered, would you share how you set up the environment and the concrete command you used?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants