vllm-project / vllm

A high-throughput and memory-efficient inference and serving engine for LLMs
https://docs.vllm.ai
Apache License 2.0
27.74k stars 4.1k forks source link

[Bug]: Vllm api server does not receive supported parameter `truncate_prompt_tokens` #6890

Open thangld201 opened 2 months ago

thangld201 commented 2 months ago

Your current environment

The output of `python collect_env.py`

🐛 Describe the bug

I used the openai compatible server deployed with vllm:

python -m vllm.entrypoints.openai.api_server --model meta-llama/Meta-Llama-3-8B-Instruct--host 127.0.0.1 --port 8077 --enforce-eager --gpu-memory-utilization 0.8 --swap-space 32

When I send a request with the following snippet (openai client):

openai_api_key="EMPTY"
openai_api_base="http://localhost:8077/v1"
from openai import OpenAI
client = OpenAI(
        api_key=openai_api_key,
        base_url=openai_api_base,
)
models = client.models.list()
model = models.data[0].id
client.chat.completions.create(
    messages=[
            {
            "role": "user",
            "content": "How are you today?"
            },
        ],
        model=model,
        max_tokens=128,
        temperature=0.0,
        seed=42,
        extra_body=dict(
            truncate_prompt_tokens=1792,
        )
    )

I got the error:

in _request
    raise self._make_status_error_from_response(err.response) from None
openai.BadRequestError: Error code: 400 - {'object': 'error', 'message': "[{'type': 'extra_forbidden', 'loc': ('body', 'truncate_prompt_tokens'), 'msg': 'Extra inputs are not permitted', 'input': 1792}]", 'type': 'BadRequestError', 'param': None, 'code': 400}

The following code, however, works:

openai_api_key="EMPTY"
openai_api_base="http://localhost:8077/v1"
from openai import OpenAI
client = OpenAI(
        api_key=openai_api_key,
        base_url=openai_api_base,
)
models = client.models.list()
model = models.data[0].id
client.chat.completions.create(
    messages=[
            {
            "role": "user",
            "content": "How are you today?"
            },
        ],
        model=model,
        max_tokens=128,
        temperature=0.0,
        seed=42,
        extra_body=dict(
            min_tokens=20, # replace with another random extra parameter
        )
    )

I wonder why in https://docs.vllm.ai/en/latest/serving/openai_compatible_server.html#extra-parameters, truncate_prompt_tokens is supported but I am getting the error here ?

DarkLight1337 commented 2 months ago

Did you make a typo? I could not find max_prompt_tokens on that page.

thangld201 commented 2 months ago

@DarkLight1337, my bad. It's truncate_prompt_tokens (still same problem).

DarkLight1337 commented 2 months ago

Does the server receive the request at all? Or is it a validation error from the OpenAI client?

thangld201 commented 2 months ago

@DarkLight1337 I saw the request on server side, with 400 status code.

DarkLight1337 commented 2 months ago

Which vLLM version are you using? I'm not getting this problem on my end. Please run python collect_env.py as shown in the OP.

thangld201 commented 2 months ago

I am using vllm version 0.5.1, I checked the source codes for this version (in my env cache) and saw that truncate_prompt_tokens is in SamplingParams already. Currently I work around this by manually truncate the prompts beforehand, but I will try other versions and see if it persists.

DarkLight1337 commented 2 months ago

Just in case, can you also check your Pydantic version?

thangld201 commented 2 months ago

My Pydantic version is 2.7.0. I also checked other lib versions but it was according to vllm's requirements so I dont think thats the problem though ....

cjfcsjt commented 2 months ago

Similar issue when using "prompt_logprob" parameters, when serving "MiniCPM-Llama3-V-2_5" @DarkLight1337

Serve command:

CUDA_VISIBLE_DEVICES=0 vllm serve openbmb/MiniCPM-Llama3-V-2_5 --trust-remote-code --dtype auto --api-key token-abc123

Python code

from openai import OpenAI
client = OpenAI(
    base_url="http://localhost:8000/v1",
    api_key="token-abc123",
)

completion = client.chat.completions.create(
    model="openbmb/MiniCPM-Llama3-V-2_5",
    messages=[
        {"role": "user", "content": "Do you think 2 is larger than 1? answer yes or no."}
    ],
    extra_body={
        "stop": ['<|eot_id|>'],
        "prompt_logprobs": True,
    }
)

Return

Error code: 400 - {'object': 'error', 'message': "[{'type': 'extra_forbidden', 'loc': ('body', 'prompt_logprobs'), 'msg': 'Extra inputs are not permitted', 'input': True}]", 'type': 'BadRequestError', 'param': None, 'code': 400}

The environment

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 22.04.2 LTS (x86_64)
GCC version: (Ubuntu 9.5.0-1ubuntu1~22.04) 9.5.0
Clang version: Could not collect
CMake version: version 3.30.1
Libc version: glibc-2.35

Python version: 3.10.13 (main, Sep 11 2023, 13:44:35) [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-5.15.0-113-generic-x86_64-with-glibc2.35
Is CUDA available: True
CUDA runtime version: 12.2.140
CUDA_MODULE_LOADING set to: LAZY

Nvidia driver version: 535.183.01
cuDNN version: Probably one of the following:
/usr/local/cuda-12.2/targets/x86_64-linux/lib/libcudnn.so.8.9.7
/usr/local/cuda-12.2/targets/x86_64-linux/lib/libcudnn_adv_infer.so.8.9.7
/usr/local/cuda-12.2/targets/x86_64-linux/lib/libcudnn_adv_train.so.8.9.7
/usr/local/cuda-12.2/targets/x86_64-linux/lib/libcudnn_cnn_infer.so.8.9.7
/usr/local/cuda-12.2/targets/x86_64-linux/lib/libcudnn_cnn_train.so.8.9.7
/usr/local/cuda-12.2/targets/x86_64-linux/lib/libcudnn_ops_infer.so.8.9.7
/usr/local/cuda-12.2/targets/x86_64-linux/lib/libcudnn_ops_train.so.8.9.7
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:                      46 bits physical, 48 bits virtual
Byte Order:                         Little Endian
CPU(s):                             96
On-line CPU(s) list:                0-95
Vendor ID:                          GenuineIntel
Model name:                         Intel(R) Xeon(R) Gold 6248R CPU @ 3.00GHz
CPU family:                         6
Model:                              85
Thread(s) per core:                 2
Core(s) per socket:                 24
Socket(s):                          2
Stepping:                           7
CPU max MHz:                        4000.0000
CPU min MHz:                        1200.0000
BogoMIPS:                           6000.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 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 pku ospke avx512_vnni md_clear flush_l1d arch_capabilities
Virtualization:                     VT-x
L1d cache:                          1.5 MiB (48 instances)
L1i cache:                          1.5 MiB (48 instances)
L2 cache:                           48 MiB (48 instances)
L3 cache:                           71.5 MiB (2 instances)
NUMA node(s):                       2
NUMA node0 CPU(s):                  0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94
NUMA node1 CPU(s):                  1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63,65,67,69,71,73,75,77,79,81,83,85,87,89,91,93,95
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 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 IBRS; IBPB conditional; RSB filling; PBRSB-eIBRS SW sequence; BHI Syscall hardening, KVM SW loop
Vulnerability Srbds:                Not affected
Vulnerability Tsx async abort:      Mitigation; TSX disabled

Versions of relevant libraries:
[pip3] numpy==1.26.4
[pip3] nvidia-nccl-cu12==2.20.5
[pip3] open-clip-torch==2.24.0
[pip3] optree==0.12.1
[pip3] torch==2.3.1+cu121
[pip3] torch-struct==0.5
[pip3] torchaudio==2.3.1+cu121
[pip3] torchvision==0.18.1+cu121
[pip3] transformers==4.43.3
[pip3] transformers-stream-generator==0.0.5
[pip3] triton==2.3.1
[pip3] vllm-nccl-cu12==2.18.1.0.4.0
[conda] blas                      1.0                         mkl  
[conda] ffmpeg                    4.3                  hf484d3e_0    pytorch
[conda] libjpeg-turbo             2.0.0                h9bf148f_0    pytorch
[conda] mkl                       2023.1.0         h213fc3f_46344  
[conda] mkl-service               2.4.0           py310h5eee18b_1  
[conda] mkl_fft                   1.3.8           py310h5eee18b_0  
[conda] mkl_random                1.2.4           py310hdb19cb5_0  
[conda] nomkl                     0.0.3                    pypi_0    pypi
[conda] numpy                     1.26.4          py310h5f9d8c6_0  
[conda] numpy-base                1.26.4          py310hb5e798b_0  
[conda] nvidia-nccl-cu12          2.20.5                   pypi_0    pypi
[conda] open-clip-torch           2.24.0                   pypi_0    pypi
[conda] optree                    0.12.1                   pypi_0    pypi
[conda] pytorch-cuda              12.1                 ha16c6d3_5    pytorch
[conda] pytorch-mutex             1.0                        cuda    pytorch
[conda] torch                     2.3.1                    pypi_0    pypi
[conda] torch-struct              0.5                      pypi_0    pypi
[conda] torchaudio                2.3.1+cu121              pypi_0    pypi
[conda] torchvision               0.18.1                   pypi_0    pypi
[conda] transformers              4.43.2                   pypi_0    pypi
[conda] transformers-stream-generator 0.0.5                    pypi_0    pypi
[conda] triton                    2.2.0                    pypi_0    pypi
[conda] vllm-nccl-cu12            2.18.1.0.4.0             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

Pydantic version

Version: 2.8.2
DarkLight1337 commented 2 months ago

Does this happen for any other model?

cjfcsjt commented 2 months ago

Does this happen for any other model?

Same issue when using OpenGVLab/InternVL2-4B, which is also an available model according to latest vllm doc @DarkLight1337

DarkLight1337 commented 2 months ago

Similar issue when using "prompt_logprob" parameters, when serving "MiniCPM-Llama3-V-2_5" @DarkLight1337

prompt_logprobs isn't a valid parameter to the OpenAI-compatible server. Please refer to the OpenAI API documentation for how to require logprobs (note that OpenAI API spec only allows getting logprobs from the output tokens).

DarkLight1337 commented 2 months ago

Similar issue when using "prompt_logprob" parameters, when serving "MiniCPM-Llama3-V-2_5" @DarkLight1337

prompt_logprobs isn't a valid parameter to the OpenAI-compatible server. Please refer to the OpenAI API documentation for how to require logprobs (note that OpenAI API spec only allows getting logprobs from the output tokens).

Actually, there is an existing workaround for this: https://github.com/vllm-project/vllm/issues/6508

cjfcsjt commented 2 months ago

Similar issue when using "prompt_logprob" parameters, when serving "MiniCPM-Llama3-V-2_5" @DarkLight1337

prompt_logprobs isn't a valid parameter to the OpenAI-compatible server. Please refer to the OpenAI API documentation for how to require logprobs (note that OpenAI API spec only allows getting logprobs from the output tokens).

Actually, there is an existing workaround for this: #6508

Thanks!! I will try to follow this on minicpm_v2_5 and internvl2-4B.