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]: RuntimeError: CHECK_EQ(paged_kv_indptr.size(0), batch_size + 1) failed. 1 vs 257. When load gemma-2-9b-it using vllm #7070

Closed
seongjiko opened this issue Aug 2, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@seongjiko
Copy link

Your current environment

Collecting environment information...
PyTorch version: 2.3.1+cu121
Is debug build: False
CUDA used to build PyTorch: 12.1
ROCM used to build PyTorch: N/A

OS: Ubuntu 20.04.6 LTS (x86_64)
GCC version: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0
Clang version: Could not collect
CMake version: version 3.29.3
Libc version: glibc-2.31

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-117-generic-x86_64-with-glibc2.31
Is CUDA available: True
CUDA runtime version: 11.8.89
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: 
GPU 0: NVIDIA A100 80GB PCIe
GPU 1: NVIDIA A100 80GB PCIe
GPU 2: NVIDIA A100 80GB PCIe
GPU 3: NVIDIA A100 80GB PCIe

Nvidia driver version: 535.183.01
cuDNN version: Could not collect
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
Byte Order:                           Little Endian
Address sizes:                        46 bits physical, 48 bits virtual
CPU(s):                               72
On-line CPU(s) list:                  0-71
Thread(s) per core:                   2
Core(s) per socket:                   18
Socket(s):                            2
NUMA node(s):                         2
Vendor ID:                            GenuineIntel
CPU family:                           6
Model:                                85
Model name:                           Intel(R) Xeon(R) Gold 5220 CPU @ 2.20GHz
Stepping:                             7
CPU MHz:                              2200.000
CPU max MHz:                          3900.0000
CPU min MHz:                          1000.0000
BogoMIPS:                             4400.00
Virtualization:                       VT-x
L1d cache:                            1.1 MiB
L1i cache:                            1.1 MiB
L2 cache:                             36 MiB
L3 cache:                             49.5 MiB
NUMA node0 CPU(s):                    0-17,36-53
NUMA node1 CPU(s):                    18-35,54-71
Vulnerability Gather data sampling:   Mitigation; Microcode
Vulnerability Itlb multihit:          KVM: Mitigation: VMX disabled
Vulnerability L1tf:                   Not affected
Vulnerability Mds:                    Not affected
Vulnerability Meltdown:               Not affected
Vulnerability Mmio stale data:        Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Reg file data sampling: Not affected
Vulnerability Retbleed:               Mitigation; Enhanced IBRS
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 / Automatic IBRS; IBPB conditional; RSB filling; PBRSB-eIBRS SW sequence; BHI SW loop, KVM SW loop
Vulnerability Srbds:                  Not affected
Vulnerability Tsx async abort:        Mitigation; TSX disabled
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 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 cdp_l3 invpcid_single intel_ppin 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 mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb intel_pt avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts hwp hwp_act_window hwp_epp hwp_pkg_req pku ospke avx512_vnni md_clear flush_l1d arch_capabilities

Versions of relevant libraries:
[pip3] flashinfer==0.1.3+cu121torch2.3
[pip3] mypy-extensions==1.0.0
[pip3] numpy==1.26.4
[pip3] nvidia-nccl-cu11==2.20.5
[pip3] nvidia-nccl-cu12==2.20.5
[pip3] onnxruntime==1.18.0
[pip3] optree==0.11.0
[pip3] pytorch_revgrad==0.2.0
[pip3] sentence-transformers==3.0.1
[pip3] torch==2.3.1
[pip3] torchaudio==2.3.1
[pip3] torchvision==0.18.1
[pip3] transformers==4.43.1
[pip3] transformers-stream-generator==0.0.5
[pip3] triton==2.3.1
[conda] flashinfer                0.1.3+cu121torch2.3          pypi_0    pypi
[conda] numpy                     1.26.4                   pypi_0    pypi
[conda] nvidia-nccl-cu11          2.20.5                   pypi_0    pypi
[conda] nvidia-nccl-cu12          2.20.5                   pypi_0    pypi
[conda] optree                    0.11.0                   pypi_0    pypi
[conda] pytorch-cuda              11.8                 h7e8668a_5    pytorch
[conda] pytorch-revgrad           0.2.0                    pypi_0    pypi
[conda] sentence-transformers     3.0.1                    pypi_0    pypi
[conda] torch                     2.3.1                    pypi_0    pypi
[conda] torchaudio                2.3.1                    pypi_0    pypi
[conda] torchvision               0.18.1                   pypi_0    pypi
[conda] transformers              4.43.1                   pypi_0    pypi
[conda] transformers-stream-generator 0.0.5                    pypi_0    pypi
[conda] triton                    2.3.1                    pypi_0    pypi
ROCM Version: Could not collect
Neuron SDK Version: N/A
vLLM Version: 0.5.3.post1
vLLM Build Flags:
CUDA Archs: Not Set; ROCm: Disabled; Neuron: Disabled
GPU Topology:
GPU0    GPU1    GPU2    GPU3    CPU Affinity    NUMA Affinity   GPU NUMA ID
GPU0     X      NODE    SYS     SYS     0-17,36-53      0               N/A
GPU1    NODE     X      SYS     SYS     0-17,36-53      0               N/A
GPU2    SYS     SYS      X      NODE    18-35,54-71     1               N/A
GPU3    SYS     SYS     NODE     X      18-35,54-71     1               N/A

Legend:

  X    = Self
  SYS  = Connection traversing PCIe as well as the SMP interconnect between NUMA nodes (e.g., QPI/UPI)
  NODE = Connection traversing PCIe as well as the interconnect between PCIe Host Bridges within a NUMA node
  PHB  = Connection traversing PCIe as well as a PCIe Host Bridge (typically the CPU)
  PXB  = Connection traversing multiple PCIe bridges (without traversing the PCIe Host Bridge)
  PIX  = Connection traversing at most a single PCIe bridge
  NV#  = Connection traversing a bonded set of # NVLinks

🐛 Describe the bug

from langchain_community.llms import VLLM

llm = VLLM(
    model="/media/user/datadisk/LLM_models/ko-gemma-2-9b-it", 
     # model received from huggingface with the git clone command
    trust_remote_code=True,
    max_new_tokens=4096,
    top_k=3,
    top_p=0.9,
    temperature=0.7,
    
)

Hi, I found some bugs when loading the gemma-2-9b fine tuning model using the vLLM library.

1. Please use Flashinfer backend for models with logits_soft_cap (i.e., Gemma-2). Otherwise, the output might be wrong. Set Flashinfer backend by export VLLM_ATTENTION_BACKEND=FLASHINFER. (type=value_error)

The above error was resolved by setting the environment variable as shown below.

import os
os.environ['VLLM_ATTENTION_BACKEND'] = 'FLASHINFER'
2. 'NoneType' object is not callable (type=type_error)

The above error was resolved by installing the flashinfer library, see #6445 .

Since then, I've encountered the following issues

[rank0]: Traceback (most recent call last):
[rank0]:   File "/home/user/anaconda3/envs/llm-api/bin/uvicorn", line 8, in <module>
[rank0]:     sys.exit(main())
[rank0]:   File "/home/user/anaconda3/envs/llm-api/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
[rank0]:     return self.main(*args, **kwargs)
[rank0]:   File "/home/user/anaconda3/envs/llm-api/lib/python3.10/site-packages/click/core.py", line 1078, in main
[rank0]:     rv = self.invoke(ctx)
[rank0]:   File "/home/user/anaconda3/envs/llm-api/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
[rank0]:     return ctx.invoke(self.callback, **ctx.params)
[rank0]:   File "/home/user/anaconda3/envs/llm-api/lib/python3.10/site-packages/click/core.py", line 783, in invoke
[rank0]:     return __callback(*args, **kwargs)
[rank0]:   File "/home/user/anaconda3/envs/llm-api/lib/python3.10/site-packages/uvicorn/main.py", line 409, in main
[rank0]:     run(
[rank0]:   File "/home/user/anaconda3/envs/llm-api/lib/python3.10/site-packages/uvicorn/main.py", line 575, in run
[rank0]:     server.run()
[rank0]:   File "/home/user/anaconda3/envs/llm-api/lib/python3.10/site-packages/uvicorn/server.py", line 65, in run
[rank0]:     return asyncio.run(self.serve(sockets=sockets))
[rank0]:   File "/home/user/anaconda3/envs/llm-api/lib/python3.10/asyncio/runners.py", line 44, in run
[rank0]:     return loop.run_until_complete(main)
[rank0]:   File "uvloop/loop.pyx", line 1517, in uvloop.loop.Loop.run_until_complete
[rank0]:   File "/home/user/anaconda3/envs/llm-api/lib/python3.10/site-packages/uvicorn/server.py", line 69, in serve
[rank0]:     await self._serve(sockets)
[rank0]:   File "/home/user/anaconda3/envs/llm-api/lib/python3.10/site-packages/uvicorn/server.py", line 76, in _serve
[rank0]:     config.load()
[rank0]:   File "/home/user/anaconda3/envs/llm-api/lib/python3.10/site-packages/uvicorn/config.py", line 433, in load
[rank0]:     self.loaded_app = import_from_string(self.app)
[rank0]:   File "/home/user/anaconda3/envs/llm-api/lib/python3.10/site-packages/uvicorn/importer.py", line 19, in import_from_string
[rank0]:     module = importlib.import_module(module_str)
[rank0]:   File "/home/user/anaconda3/envs/llm-api/lib/python3.10/importlib/__init__.py", line 126, in import_module
[rank0]:     return _bootstrap._gcd_import(name[level:], package, level)
[rank0]:   File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
[rank0]:   File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
[rank0]:   File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
[rank0]:   File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
[rank0]:   File "<frozen importlib._bootstrap_external>", line 883, in exec_module
[rank0]:   File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
[rank0]:   File "/home/user/Patent-LLM/main.py", line 6, in <module>
[rank0]:     from routers import chat_manager, clear_memory
[rank0]:   File "/home/user/Patent-LLM/routers/clear_memory.py", line 5, in <module>
[rank0]:     from core.get_session import get_user_id
[rank0]:   File "/home/user/Patent-LLM/core/get_session.py", line 8, in <module>
[rank0]:     from core.llm import llm
[rank0]:   File "/home/user/Patent-LLM/core/llm.py", line 16, in <module>
[rank0]:     llm = VLLM(
[rank0]:   File "/home/user/anaconda3/envs/llm-api/lib/python3.10/site-packages/pydantic/v1/main.py", line 339, in __init__
[rank0]:     values, fields_set, validation_error = validate_model(__pydantic_self__.__class__, data)
[rank0]:   File "/home/user/anaconda3/envs/llm-api/lib/python3.10/site-packages/pydantic/v1/main.py", line 1048, in validate_model
[rank0]:     input_data = validator(cls_, input_data)
[rank0]:   File "/home/user/anaconda3/envs/llm-api/lib/python3.10/site-packages/langchain_core/utils/pydantic.py", line 149, in wrapper
[rank0]:     return func(cls, values)
[rank0]:   File "/home/user/anaconda3/envs/llm-api/lib/python3.10/site-packages/langchain_community/llms/vllm.py", line 89, in validate_environment
[rank0]:     values["client"] = VLLModel(
[rank0]:   File "/home/user/anaconda3/envs/llm-api/lib/python3.10/site-packages/vllm/vllm/entrypoints/llm.py", line 155, in __init__
[rank0]:     self.llm_engine = LLMEngine.from_engine_args(
[rank0]:   File "/home/user/anaconda3/envs/llm-api/lib/python3.10/site-packages/vllm/vllm/engine/llm_engine.py", line 441, in from_engine_args
[rank0]:     engine = cls(
[rank0]:   File "/home/user/anaconda3/envs/llm-api/lib/python3.10/site-packages/vllm/vllm/engine/llm_engine.py", line 265, in __init__
[rank0]:     self._initialize_kv_caches()
[rank0]:   File "/home/user/anaconda3/envs/llm-api/lib/python3.10/site-packages/vllm/vllm/engine/llm_engine.py", line 364, in _initialize_kv_caches
[rank0]:     self.model_executor.determine_num_available_blocks())
[rank0]:   File "/home/user/anaconda3/envs/llm-api/lib/python3.10/site-packages/vllm/vllm/executor/gpu_executor.py", line 94, in determine_num_available_blocks
[rank0]:     return self.driver_worker.determine_num_available_blocks()
[rank0]:   File "/home/user/anaconda3/envs/llm-api/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
[rank0]:     return func(*args, **kwargs)
[rank0]:   File "/home/user/anaconda3/envs/llm-api/lib/python3.10/site-packages/vllm/vllm/worker/worker.py", line 179, in determine_num_available_blocks
[rank0]:     self.model_runner.profile_run()
[rank0]:   File "/home/user/anaconda3/envs/llm-api/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
[rank0]:     return func(*args, **kwargs)
[rank0]:   File "/home/user/anaconda3/envs/llm-api/lib/python3.10/site-packages/vllm/vllm/worker/model_runner.py", line 896, in profile_run
[rank0]:     self.execute_model(model_input, kv_caches, intermediate_tensors)
[rank0]:   File "/home/user/anaconda3/envs/llm-api/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
[rank0]:     return func(*args, **kwargs)
[rank0]:   File "/home/user/anaconda3/envs/llm-api/lib/python3.10/site-packages/vllm/vllm/worker/model_runner.py", line 1292, in execute_model
[rank0]:     model_input.attn_metadata.begin_forward()
[rank0]:   File "/home/user/anaconda3/envs/llm-api/lib/python3.10/site-packages/vllm/vllm/attention/backends/flashinfer.py", line 146, in begin_forward
[rank0]:     self.prefill_wrapper.begin_forward(
[rank0]:   File "/home/user/anaconda3/envs/llm-api/lib/python3.10/site-packages/flashinfer/prefill.py", line 791, in begin_forward
[rank0]:     self._wrapper.begin_forward(
[rank0]: RuntimeError: CHECK_EQ(paged_kv_indptr.size(0), batch_size + 1) failed. 1 vs 257

I've loaded and used many other models via vLLM libraries, but this is the first time I've encountered this, and I haven't found any documentation of the issue.

I tried (ignorantly) to force the size by setting the batch_size variable to 256 or 0 directly in the /home/user/anaconda3/envs/llm-api/lib/python3.10/site-packages/flashinfer/prefill.py source file, but it only changed the number on both sides of the vs.

Is there a way to fix this?

@seongjiko seongjiko added the bug Something isn't working label Aug 2, 2024
@kvikk
Copy link

kvikk commented Aug 2, 2024

+1 Seeing the same thing.

@Noxoomo
Copy link

Noxoomo commented Aug 2, 2024

Seems like a bug in flash infer 0.1.3
Managed to fix same issue with
pip install flashinfer==0.1.2 -i https://flashinfer.ai/whl/cu121/torch2.3

@seongjiko
Copy link
Author

seongjiko commented Aug 4, 2024

Seems like a bug in flash infer 0.1.3 Managed to fix same issue with pip install flashinfer==0.1.2 -i https://flashinfer.ai/whl/cu121/torch2.3

I plan to try it out tomorrow, and judging by the number of likes, it seems to be the solution! If it resolves the issue, I will close it.
Thank you 😄

@seongjiko
Copy link
Author

It works!

@xfalcox
Copy link

xfalcox commented Aug 6, 2024

Seems like a bug in flash infer 0.1.3 Managed to fix same issue with pip install flashinfer==0.1.2 -i https://flashinfer.ai/whl/cu121/torch2.3

I plan to try it out tomorrow, and judging by the number of likes, it seems to be the solution! If it resolves the issue, I will close it. Thank you 😄

Can we re-open it as this isn't really a solution for the Docker image right?

@yzh119
Copy link

yzh119 commented Aug 7, 2024

@Noxoomo this is not a bug with flashinfer:

We found that vllm v0.5.3 didn't integrate flashinfer correctly: flashinfer-ai/flashinfer#362 (comment)
To avoid such issues, we add a check at flashinfer-side(flashinfer-ai/flashinfer#413), which was reflected in flashinfer v0.1.3, and it will break vllm v0.5.3.

As you said, downgrade flashinfer to v0.1.2 is a temporary solution to be compatible with vllm v0.5.3. But you are encouraged to use new wheels once vllm integration was fixed.

@RylanSchaeffer
Copy link

RylanSchaeffer commented Aug 16, 2024

@yzh119 is vllm integration fixed? I'm hitting many bugs running Gemma 2 with vllm

Most recently:

  File "/lfs/skampere1/0/rschaef/miniconda3/envs/reward_modeling_20240708/lib/python3.11/site-packages/vllm/worker/cache_engine.py", line 102, in copy
    self.attn_backend.copy_blocks(self.gpu_cache, src_to_dsts)
  File "/lfs/skampere1/0/rschaef/miniconda3/envs/reward_modeling_20240708/lib/python3.11/site-packages/vllm/attention/backends/flashinfer.py", line 56, in copy_blocks
    raise NotImplementedError

Edit: Solution was to upgrade vllm again.

@yzh119
Copy link

yzh119 commented Aug 16, 2024

@RylanSchaeffer yes, it's fixed in main branch and you can either wait for next vllm release or install vllm from source in main branch.

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

6 participants