Skip to content
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

[Bug]: Error in CPU Inference #3928

Open
chzhyang opened this issue Apr 9, 2024 · 7 comments
Open

[Bug]: Error in CPU Inference #3928

chzhyang opened this issue Apr 9, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@chzhyang
Copy link

chzhyang commented Apr 9, 2024

Your current environment

The output of `python collect_env.py`
PyTorch version: 2.2.1+cpu                                                                                                                                                           
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 12.3.0-1ubuntu1~22.04) 12.3.0                                                                                                                                   
Clang version: Could not collect                                                                                                                                                     
CMake version: version 3.29.0                                                                                                                                                        
Libc version: glibc-2.35                                                                                                                                                             
                                                                                                                                                                                     
Python version: 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] (64-bit runtime)                                                                                                  
Python platform: Linux-5.15.0-97-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):                             240                                                                                                                                              
On-line CPU(s) list:                0-239                                                                                                                                            
Vendor ID:                          GenuineIntel                                                                                                                                     
Model name:                         Intel(R) Xeon(R) Platinum 8490H                                                                                                                  
CPU family:                         6                                                                                                                                                
Model:                              143
Socket(s):                          2
Stepping:                           8
CPU max MHz:                        3500.0000
CPU min MHz:                        800.0000
BogoMIPS:                           3800.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 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.6 MiB (120 instances)
L1i cache:                          3.8 MiB (120 instances)
L2 cache:                           240 MiB (120 instances)
L3 cache:                           225 MiB (2 instances)
NUMA node(s):                       2
NUMA node0 CPU(s):                  0-59,120-179
NUMA node1 CPU(s):                  60-119,180-239
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
Vulnerability Srbds:                Not affected
Vulnerability Tsx async abort:      Not affected

Versions of relevant libraries:
[pip3] numpy==1.26.4
[pip3] torch==2.2.1+cpu
[pip3] triton==2.3.0
[conda] Could not collectROCM Version: Could not collect
Neuron SDK Version: N/A
vLLM Version: 0.4.0.post1
vLLM Build Flags:
CUDA Archs: Not Set; ROCm: Disabled; Neuron: Disabled
GPU Topology:
Could not collect

🐛 Describe the bug

Refere to this doc, I build an docker image:

docker build -f Dockerfile.cpu -t vllm-cpu-env --shm-size=4g .

Then run container:

docker run -it \
             --rm \
             --network=host \
             vllm-cpu-env

Then try to load Mixtral 8x7b and inference, but get AssertionError: Torch not compiled with CUDA enabled.

from vllm import LLM, SamplingParams

# Sample prompts.
prompts = [
    "Hello, my name is",
    "The president of the United States is",
    "The capital of France is",
    "The future of AI is",
]
sampling_params = SamplingParams(temperature=0.8, top_p=0.95)
model_path="/models/Mixtral-8x7B-Instruct-v0.1"
llm = LLM(model=model_path,device="cpu",trust_remote_code=True)
outputs = llm.generate(prompts, sampling_params)
for output in outputs:
    prompt = output.prompt
    generated_text = output.outputs[0].text
    print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")
WARNING 04-09 14:13:01 ray_utils.py:70] Failed to import Ray with ModuleNotFoundError("No module named 'ray'"). For distributed inference, please install Ray with `pip install ray`.
INFO 04-09 14:13:01 llm_engine.py:81] Initializing an LLM engine (v0.4.0.post1) with config: model='/models/Mixtral-8x7B-Instruct-v0.1.safetensors', speculative_config=None, tokenizer='/models/Mixtral-8x7B-Instruct-v0.1.safetensors', tokenizer_mode=auto, revision=None, tokenizer_revision=None, trust_remote_code=True, dtype=torch.bfloat16, max_seq_len=32768, download_dir=None, load_format=auto, tensor_parallel_size=1, disable_custom_all_reduce=True, quantization=None, enforce_eager=False, kv_cache_dtype=auto, quantization_param_path=None, device_config=cpu, seed=0)
WARNING 04-09 14:13:01 cpu_executor.py:126] CUDA graph is not supported on CPU, fallback to the eager mode.
WARNING 04-09 14:13:01 cpu_executor.py:145] Environment variable VLLM_CPU_KVCACHE_SPACE (GB) for CPU backend is not set, using 4 by default.
INFO 04-09 14:13:01 pynccl_utils.py:17] Failed to import NCCL library: NCCL only supports CUDA and ROCm backends.
INFO 04-09 14:13:01 pynccl_utils.py:18] It is expected if you are not running on NVIDIA GPUs.
WARNING 04-09 14:13:01 utils.py:359] Pin memory is not supported on CPU.
INFO 04-09 14:13:01 selector.py:21] Using Torch SDPA backend.
Traceback (most recent call last):
  File "/workspace/vllm/examples/offline_inference.py", line 18, in <module>
    llm = LLM(model=mix2,device="cpu",trust_remote_code=True)
  File "/usr/local/lib/python3.10/dist-packages/vllm-0.4.0.post1+cpu-py3.10-linux-x86_64.egg/vllm/entrypoints/llm.py", line 112, in __init__
    self.llm_engine = LLMEngine.from_engine_args(
  File "/usr/local/lib/python3.10/dist-packages/vllm-0.4.0.post1+cpu-py3.10-linux-x86_64.egg/vllm/engine/llm_engine.py", line 209, in from_engine_args
    engine = cls(
  File "/usr/local/lib/python3.10/dist-packages/vllm-0.4.0.post1+cpu-py3.10-linux-x86_64.egg/vllm/engine/llm_engine.py", line 119, in __init__
    self.model_executor = executor_class(
  File "/usr/local/lib/python3.10/dist-packages/vllm-0.4.0.post1+cpu-py3.10-linux-x86_64.egg/vllm/executor/cpu_executor.py", line 37, in __init__
    self._init_worker()
  File "/usr/local/lib/python3.10/dist-packages/vllm-0.4.0.post1+cpu-py3.10-linux-x86_64.egg/vllm/executor/cpu_executor.py", line 61, in _init_worker
    self.driver_worker.load_model()
  File "/usr/local/lib/python3.10/dist-packages/vllm-0.4.0.post1+cpu-py3.10-linux-x86_64.egg/vllm/worker/cpu_worker.py", line 168, in load_model
    self.model_runner.load_model()
  File "/usr/local/lib/python3.10/dist-packages/vllm-0.4.0.post1+cpu-py3.10-linux-x86_64.egg/vllm/worker/cpu_worker.py", line 27, in load_model
    self.model = get_model(self.model_config,
  File "/usr/local/lib/python3.10/dist-packages/vllm-0.4.0.post1+cpu-py3.10-linux-x86_64.egg/vllm/model_executor/model_loader.py", line 81, in get_model
    model = model_class(model_config.hf_config, linear_method,
  File "/usr/local/lib/python3.10/dist-packages/vllm-0.4.0.post1+cpu-py3.10-linux-x86_64.egg/vllm/model_executor/models/mixtral.py", line 353, in __init__
    self.model = MixtralModel(config,
  File "/usr/local/lib/python3.10/dist-packages/vllm-0.4.0.post1+cpu-py3.10-linux-x86_64.egg/vllm/model_executor/models/mixtral.py", line 298, in __init__
    self.layers = nn.ModuleList([
  File "/usr/local/lib/python3.10/dist-packages/vllm-0.4.0.post1+cpu-py3.10-linux-x86_64.egg/vllm/model_executor/models/mixtral.py", line 299, in <listcomp>
    MixtralDecoderLayer(config, linear_method=linear_method)
  File "/usr/local/lib/python3.10/dist-packages/vllm-0.4.0.post1+cpu-py3.10-linux-x86_64.egg/vllm/model_executor/models/mixtral.py", line 239, in __init__
    self.block_sparse_moe = MixtralMoE(
  File "/usr/local/lib/python3.10/dist-packages/vllm-0.4.0.post1+cpu-py3.10-linux-x86_64.egg/vllm/model_executor/models/mixtral.py", line 90, in __init__
    torch.empty(self.num_total_experts,
  File "/usr/local/lib/python3.10/dist-packages/torch/utils/_device.py", line 77, in __torch_function__
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/torch/cuda/__init__.py", line 293, in _lazy_init
    raise AssertionError("Torch not compiled with CUDA enabled")
AssertionError: Torch not compiled with CUDA enabled
@chzhyang chzhyang added the bug Something isn't working label Apr 9, 2024
@WoosukKwon
Copy link
Collaborator

Hi @chzhyang, thanks for reporting this. MoE models are not yet supported by the CPU backend.

@chzhyang
Copy link
Author

chzhyang commented Apr 9, 2024

Hi @chzhyang, thanks for reporting this. MoE models are not yet supported by the CPU backend.

Thanks for your quick reply. If we have a matrix showing the models, hardwares, quantization, etc, it would be more user friendly :)

@WoosukKwon
Copy link
Collaborator

@chzhyang Thanks for the feedback! Yes, we are preparing it. Currently, the CPU backend only supports BF16 and FP32 data types. FP16 and quantization support is in progress.

cc @bigPYJ1151

@bigPYJ1151
Copy link
Contributor

Hi @chzhyang Thanks for your feedback. The CPU backend is initially supported and still under development. You can track the status and recent plan via #3654

@papandadj
Copy link

Hi @chzhyang Thanks for your feedback. The CPU backend is initially supported and still under development. You can track the status and recent plan via #3654

Thank you for providing the CPU execution mode.
I attempted to build a CPU runtime environment in Docker. When I execute python3 -m vllm.entrypoints.openai.api_server --port 38000 --model /root/.cache/modelscope/hub/qwen/Qwen1.5-14B-Chat --served-model-name Qwen1.5-7B-Chat --max-model-len 4096, It encountered an error.

Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.
INFO 04-12 09:56:31 pynccl_utils.py:17] Failed to import NCCL library: NCCL only supports CUDA and ROCm backends.
INFO 04-12 09:56:31 pynccl_utils.py:18] It is expected if you are not running on NVIDIA GPUs.
INFO 04-12 09:56:31 selector.py:43] Using Torch SDPA backend.
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/python3.10/dist-packages/vllm-0.4.0.post1+cpu-py3.10-linux-x86_64.egg/vllm/entrypoints/openai/api_server.py", line 157, in <module>
    engine = AsyncLLMEngine.from_engine_args(
  File "/usr/local/lib/python3.10/dist-packages/vllm-0.4.0.post1+cpu-py3.10-linux-x86_64.egg/vllm/engine/async_llm_engine.py", line 347, in from_engine_args
    engine = cls(
  File "/usr/local/lib/python3.10/dist-packages/vllm-0.4.0.post1+cpu-py3.10-linux-x86_64.egg/vllm/engine/async_llm_engine.py", line 311, in __init__
    self.engine = self._init_engine(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/vllm-0.4.0.post1+cpu-py3.10-linux-x86_64.egg/vllm/engine/async_llm_engine.py", line 421, in _init_engine
    return engine_class(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/vllm-0.4.0.post1+cpu-py3.10-linux-x86_64.egg/vllm/engine/llm_engine.py", line 119, in __init__
    self.model_executor = executor_class(
  File "/usr/local/lib/python3.10/dist-packages/vllm-0.4.0.post1+cpu-py3.10-linux-x86_64.egg/vllm/executor/gpu_executor.py", line 41, in __init__
    self._init_worker()
  File "/usr/local/lib/python3.10/dist-packages/vllm-0.4.0.post1+cpu-py3.10-linux-x86_64.egg/vllm/executor/gpu_executor.py", line 66, in _init_worker
    self.driver_worker.init_device()
  File "/usr/local/lib/python3.10/dist-packages/vllm-0.4.0.post1+cpu-py3.10-linux-x86_64.egg/vllm/worker/worker.py", line 98, in init_device
    raise RuntimeError(
RuntimeError: Not support device type: cpu

CPU DATASET:

Flags:                 fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon rep_good nopl xtopology cpuid tsc_known_freq pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch cpuid_fault invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves arat avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq rdpid arch_capabilities

I'm using Qwen's model, which I believe is of BF16 data type. Is BF16 data type not yet supported for running on a CPU?

@bigPYJ1151
Copy link
Contributor

Hi @papandadj thanks for your feedback. The online inference is not enabled on CPU by default because it needs more tuning. I think you can look forward #3993 being merged.

@seymaalan
Copy link

the CPU backend only supports BF16 and FP32

is there any update on FP16 and quantization support?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants