vllm-project / vllm

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

[Performance]: How to Improve Performance Under Concurrency #9722

Open ljwps opened 1 week ago

ljwps commented 1 week ago

Proposal to improve performance

I am using vllm version 0.6.3.post1 with four 4090 GPUs to infer the qwen2-72B-chat-int4 model. The request speed is very fast for a single request, but the performance is slow under concurrency, especially the latency for the first token. Additionally, the request throughput remains at about 1 to 2 requests per second. The main use case is intent recognition, with a prompt length of approximately 1000 characters and a generated length of about 5 to 9 characters. Besides using vllm alone for inference, I also tried using fastchat with vllm, and the testing results were basically the same. Below, I will provide the testing results for using vllm alone for inference.(zh_cn:我使用vllm,版本为0.6.3.post1,用4张4090推理qwen2-72B-chat-int4,一个请求速度很快,但并发下性能很慢,特别是首字时间,并且Request throughput一直都每秒1-2个,主要使用场景为意图识别,prompt长度大概在1000字符,生成字符大概在5-9个字。同时除了单独使用vllm启动推理,也尝试过使用fastchat+vllm,测试效果基本一致,下面贴出单独使用vllm启动推理的测试情况)

The inference command is: CUDA_VISIBLE_DEVICES=4,5,6,7 vllm serve /data/models/Qwen2-72B-Instruct-GPTQ-Int4 --max-model-len 10000 --tensor-parallel-size 4 --gpu-memory-utilization 0.6 --served-model-name Qwen2-72B-Chat-GPTQ-Int4

Report of performance regression

The benchmark_serving command is: python3 benchmarks/benchmark_serving.py --backend openai-chat --endpoint /v1/chat/completions --base-url http://192.168.10.115:8000 --model Qwen2-72B-Chat-GPTQ-Int4 --tokenizer /data/models/Qwen2-72B-Chat-GPTQ-Int4/ --dataset-name sharegpt --dataset-path /data/test.json --num-prompts 100 --max-concurrency 5

The --max-concurrency parameter takes the values 5, 10, 20, 30, 40, and 50.

Traffic request rate: inf
Maximum request concurrency: 5
============ Serving Benchmark Result ============
Successful requests:                     100       
Benchmark duration (s):                  83.07     
Total input tokens:                      77700     
Total generated tokens:                  600       
Request throughput (req/s):              1.20      
Output token throughput (tok/s):         7.22      
Total Token throughput (tok/s):          942.58    
---------------Time to First Token----------------
Mean TTFT (ms):                          3824.11   
Median TTFT (ms):                        3995.71   
P99 TTFT (ms):                           4023.67   
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms):                          65.28     
Median TPOT (ms):                        33.60     
P99 TPOT (ms):                           334.75    
---------------Inter-token Latency----------------
Mean ITL (ms):                           59.29     
Median ITL (ms):                         27.65     
P99 ITL (ms):                            1052.38   
==================================================
Traffic request rate: inf
Maximum request concurrency: 10
============ Serving Benchmark Result ============
Successful requests:                     100       
Benchmark duration (s):                  81.87     
Total input tokens:                      77700     
Total generated tokens:                  600       
Request throughput (req/s):              1.22      
Output token throughput (tok/s):         7.33      
Total Token throughput (tok/s):          956.34    
---------------Time to First Token----------------
Mean TTFT (ms):                          7801.03   
Median TTFT (ms):                        7987.75   
P99 TTFT (ms):                           8011.52   
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms):                          76.40     
Median TPOT (ms):                        40.11     
P99 TPOT (ms):                           509.98    
---------------Inter-token Latency----------------
Mean ITL (ms):                           69.01     
Median ITL (ms):                         32.71     
P99 ITL (ms):                            1892.95   
==================================================
Traffic request rate: inf
Maximum request concurrency: 20
============ Serving Benchmark Result ============
Successful requests:                     100       
Benchmark duration (s):                  81.46     
Total input tokens:                      77700     
Total generated tokens:                  600       
Request throughput (req/s):              1.23      
Output token throughput (tok/s):         7.37      
Total Token throughput (tok/s):          961.25    
---------------Time to First Token----------------
Mean TTFT (ms):                          14632.29  
Median TTFT (ms):                        14059.70  
P99 TTFT (ms):                           16235.35  
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms):                          330.13    
Median TPOT (ms):                        454.23    
P99 TPOT (ms):                           1625.36   
---------------Inter-token Latency----------------
Mean ITL (ms):                           320.36    
Median ITL (ms):                         41.50     
P99 ITL (ms):                            2144.87   
==================================================
Traffic request rate: inf
Maximum request concurrency: 30
============ Serving Benchmark Result ============
Successful requests:                     100       
Benchmark duration (s):                  82.97     
Total input tokens:                      77700     
Total generated tokens:                  603       
Request throughput (req/s):              1.21      
Output token throughput (tok/s):         7.27      
Total Token throughput (tok/s):          943.80    
---------------Time to First Token----------------
Mean TTFT (ms):                          18854.01  
Median TTFT (ms):                        19212.50  
P99 TTFT (ms):                           23907.83  
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms):                          875.24    
Median TPOT (ms):                        582.24    
P99 TPOT (ms):                           4836.03   
---------------Inter-token Latency----------------
Mean ITL (ms):                           841.87    
Median ITL (ms):                         44.59     
P99 ITL (ms):                            8133.98   
==================================================
Traffic request rate: inf
Maximum request concurrency: 40
============ Serving Benchmark Result ============
Successful requests:                     100       
Benchmark duration (s):                  82.96     
Total input tokens:                      77700     
Total generated tokens:                  600       
Request throughput (req/s):              1.21      
Output token throughput (tok/s):         7.23      
Total Token throughput (tok/s):          943.83    
---------------Time to First Token----------------
Mean TTFT (ms):                          26241.56  
Median TTFT (ms):                        22920.71  
P99 TTFT (ms):                           40782.67  
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms):                          866.58    
Median TPOT (ms):                        610.57    
P99 TPOT (ms):                           4825.75   
---------------Inter-token Latency----------------
Mean ITL (ms):                           845.52    
Median ITL (ms):                         42.89     
P99 ITL (ms):                            7938.50   
==================================================
Traffic request rate: inf
Maximum request concurrency: 50
============ Serving Benchmark Result ============
Successful requests:                     100       
Benchmark duration (s):                  83.19     
Total input tokens:                      77700     
Total generated tokens:                  600       
Request throughput (req/s):              1.20      
Output token throughput (tok/s):         7.21      
Total Token throughput (tok/s):          941.26    
---------------Time to First Token----------------
Mean TTFT (ms):                          31529.78  
Median TTFT (ms):                        29216.36  
P99 TTFT (ms):                           46898.71  
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms):                          863.05    
Median TPOT (ms):                        597.99    
P99 TPOT (ms):                           4838.11   
---------------Inter-token Latency----------------
Mean ITL (ms):                           843.20    
Median ITL (ms):                         44.27     
P99 ITL (ms):                            7181.44   
==================================================

Misc discussion on performance

I also tried using Ollama. The speed for a single request is not as fast as vllm, but the performance of Ollama is more stable under concurrency.(zh_cn:同时我还尝试了ollama,单次请求速度没有vllm快,但并发下ollama性能较为稳定)

Traffic request rate: inf
Maximum request concurrency: 5
============ Serving Benchmark Result ============
Successful requests:                     100       
Benchmark duration (s):                  19.85     
Total input tokens:                      77700     
Total generated tokens:                  796       
Request throughput (req/s):              5.04      
Output token throughput (tok/s):         40.09     
Total Token throughput (tok/s):          3953.79   
---------------Time to First Token----------------
Mean TTFT (ms):                          463.07    
Median TTFT (ms):                        344.87    
P99 TTFT (ms):                           2201.13   
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms):                          74.16     
Median TPOT (ms):                        69.42     
P99 TPOT (ms):                           216.63    
---------------Inter-token Latency----------------
Mean ITL (ms):                           69.02     
Median ITL (ms):                         62.40     
P99 ITL (ms):                            338.15    
==================================================
Traffic request rate: inf
Maximum request concurrency: 10
============ Serving Benchmark Result ============
Successful requests:                     100       
Benchmark duration (s):                  15.90     
Total input tokens:                      77700     
Total generated tokens:                  746       
Request throughput (req/s):              6.29      
Output token throughput (tok/s):         46.93     
Total Token throughput (tok/s):          4934.95   
---------------Time to First Token----------------
Mean TTFT (ms):                          1073.16   
Median TTFT (ms):                        1022.13   
P99 TTFT (ms):                           1522.29   
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms):                          72.74     
Median TPOT (ms):                        73.60     
P99 TPOT (ms):                           79.29     
---------------Inter-token Latency----------------
Mean ITL (ms):                           64.81     
Median ITL (ms):                         63.35     
P99 ITL (ms):                            87.79     
==================================================
Traffic request rate: inf
Maximum request concurrency: 20
============ Serving Benchmark Result ============
Successful requests:                     100       
Benchmark duration (s):                  17.32     
Total input tokens:                      77700     
Total generated tokens:                  784       
Request throughput (req/s):              5.77      
Output token throughput (tok/s):         45.26     
Total Token throughput (tok/s):          4531.19   
---------------Time to First Token----------------
Mean TTFT (ms):                          2638.31   
Median TTFT (ms):                        2823.21   
P99 TTFT (ms):                           3337.15   
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms):                          71.95     
Median TPOT (ms):                        73.92     
P99 TPOT (ms):                           82.08     
---------------Inter-token Latency----------------
Mean ITL (ms):                           65.27     
Median ITL (ms):                         63.04     
P99 ITL (ms):                            87.16     
==================================================
Traffic request rate: inf
Maximum request concurrency: 30
============ Serving Benchmark Result ============
Successful requests:                     100       
Benchmark duration (s):                  17.02     
Total input tokens:                      77700     
Total generated tokens:                  790       
Request throughput (req/s):              5.87      
Output token throughput (tok/s):         46.41     
Total Token throughput (tok/s):          4611.25   
---------------Time to First Token----------------
Mean TTFT (ms):                          3920.10   
Median TTFT (ms):                        4413.42   
P99 TTFT (ms):                           5084.40   
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms):                          71.21     
Median TPOT (ms):                        74.14     
P99 TPOT (ms):                           79.68     
---------------Inter-token Latency----------------
Mean ITL (ms):                           65.06     
Median ITL (ms):                         62.96     
P99 ITL (ms):                            84.72     
==================================================
Traffic request rate: inf
Maximum request concurrency: 40
============ Serving Benchmark Result ============
Successful requests:                     100       
Benchmark duration (s):                  16.96     
Total input tokens:                      77700     
Total generated tokens:                  760       
Request throughput (req/s):              5.90      
Output token throughput (tok/s):         44.82     
Total Token throughput (tok/s):          4626.90   
---------------Time to First Token----------------
Mean TTFT (ms):                          5072.32   
Median TTFT (ms):                        6086.13   
P99 TTFT (ms):                           6690.26   
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms):                          72.80     
Median TPOT (ms):                        74.25     
P99 TPOT (ms):                           81.73     
---------------Inter-token Latency----------------
Mean ITL (ms):                           64.87     
Median ITL (ms):                         63.03     
P99 ITL (ms):                            90.92     
==================================================
Traffic request rate: inf
Maximum request concurrency: 50
============ Serving Benchmark Result ============
Successful requests:                     100       
Benchmark duration (s):                  17.24     
Total input tokens:                      77700     
Total generated tokens:                  774       
Request throughput (req/s):              5.80      
Output token throughput (tok/s):         44.89     
Total Token throughput (tok/s):          4550.97   
---------------Time to First Token----------------
Mean TTFT (ms):                          6008.23   
Median TTFT (ms):                        7445.23   
P99 TTFT (ms):                           8207.12   
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms):                          71.76     
Median TPOT (ms):                        73.61     
P99 TPOT (ms):                           80.52     
---------------Inter-token Latency----------------
Mean ITL (ms):                           65.04     
Median ITL (ms):                         63.42     
P99 ITL (ms):                            86.66     
==================================================

Your current environment (if you think it is necessary)

The output of `python collect_env.py`

Collecting environment information... PyTorch version: 2.4.0+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.16.3 Libc version: glibc-2.35

Python version: 3.10.15 (main, Oct 3 2024, 07:27:34) [GCC 11.2.0] (64-bit runtime) Python platform: Linux-5.4.0-190-generic-x86_64-with-glibc2.35 Is CUDA available: True CUDA runtime version: 12.1.66 CUDA_MODULE_LOADING set to: LAZY GPU models and configuration: GPU 0: NVIDIA GeForce RTX 4090 GPU 1: NVIDIA GeForce RTX 4090 GPU 2: NVIDIA GeForce RTX 4090 GPU 3: NVIDIA GeForce RTX 4090 GPU 4: NVIDIA GeForce RTX 4090 GPU 5: NVIDIA GeForce RTX 4090 GPU 6: NVIDIA GeForce RTX 4090 GPU 7: NVIDIA GeForce RTX 4090

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, 57 bits virtual CPU(s): 144 On-line CPU(s) list: 0-143 Thread(s) per core: 2 Core(s) per socket: 36 Socket(s): 2 NUMA node(s): 2 Vendor ID: GenuineIntel CPU family: 6 Model: 106 Model name: Intel(R) Xeon(R) Platinum 8352V CPU @ 2.10GHz Stepping: 6 CPU MHz: 800.083 BogoMIPS: 4200.00 Virtualization: VT-x L1d cache: 3.4 MiB L1i cache: 2.3 MiB L2 cache: 90 MiB L3 cache: 108 MiB NUMA node0 CPU(s): 0-35,72-107 NUMA node1 CPU(s): 36-71,108-143 Vulnerability Gather data sampling: Mitigation; Microcode Vulnerability Itlb multihit: Not affected Vulnerability L1tf: Not affected Vulnerability Mds: Not affected Vulnerability Meltdown: Not affected Vulnerability Mmio stale data: Mitigation; Clear CPU buffers; SMT vulnerable Vulnerability Retbleed: 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 Vulnerable, KVM SW loop Vulnerability Srbds: Not affected Vulnerability Tsx async abort: Not affected 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 invpcid_single 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 wbnoinvd dtherm ida arat pln pts hwp_epp avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg tme avx512_vpopcntdq rdpid md_clear pconfig flush_l1d arch_capabilities

Versions of relevant libraries: [pip3] numpy==1.26.4 [pip3] nvidia-cublas-cu12==12.1.3.1 [pip3] nvidia-cuda-cupti-cu12==12.1.105 [pip3] nvidia-cuda-nvrtc-cu12==12.1.105 [pip3] nvidia-cuda-runtime-cu12==12.1.105 [pip3] nvidia-cudnn-cu12==9.1.0.70 [pip3] nvidia-cufft-cu12==11.0.2.54 [pip3] nvidia-curand-cu12==10.3.2.106 [pip3] nvidia-cusolver-cu12==11.4.5.107 [pip3] nvidia-cusparse-cu12==12.1.0.106 [pip3] nvidia-ml-py==12.560.30 [pip3] nvidia-nccl-cu12==2.20.5 [pip3] nvidia-nvjitlink-cu12==12.6.77 [pip3] nvidia-nvtx-cu12==12.1.105 [pip3] pyzmq==26.2.0 [pip3] torch==2.4.0+cu121 [pip3] torchvision==0.19.0+cu121 [pip3] transformers==4.45.2 [pip3] triton==3.0.0 [conda] numpy 1.26.4 pypi_0 pypi [conda] nvidia-cublas-cu12 12.1.3.1 pypi_0 pypi [conda] nvidia-cuda-cupti-cu12 12.1.105 pypi_0 pypi [conda] nvidia-cuda-nvrtc-cu12 12.1.105 pypi_0 pypi [conda] nvidia-cuda-runtime-cu12 12.1.105 pypi_0 pypi [conda] nvidia-cudnn-cu12 9.1.0.70 pypi_0 pypi [conda] nvidia-cufft-cu12 11.0.2.54 pypi_0 pypi [conda] nvidia-curand-cu12 10.3.2.106 pypi_0 pypi [conda] nvidia-cusolver-cu12 11.4.5.107 pypi_0 pypi [conda] nvidia-cusparse-cu12 12.1.0.106 pypi_0 pypi [conda] nvidia-ml-py 12.560.30 pypi_0 pypi [conda] nvidia-nccl-cu12 2.20.5 pypi_0 pypi [conda] nvidia-nvjitlink-cu12 12.6.77 pypi_0 pypi [conda] nvidia-nvtx-cu12 12.1.105 pypi_0 pypi [conda] pyzmq 26.2.0 pypi_0 pypi [conda] torch 2.4.0+cu121 pypi_0 pypi [conda] torchvision 0.19.0+cu121 pypi_0 pypi [conda] transformers 4.45.2 pypi_0 pypi [conda] triton 3.0.0 pypi_0 pypi ROCM Version: Could not collect Neuron SDK Version: N/A vLLM Version: 0.6.3.post1 vLLM Build Flags: CUDA Archs: Not Set; ROCm: Disabled; Neuron: Disabled GPU Topology: GPU0 GPU1 GPU2 GPU3 GPU4 GPU5 GPU6 GPU7 CPU Affinity NUMA Affinity GPU NUMA ID GPU0 X PIX NODE NODE SYS SYS SYS SYS 0-35,72-107 0 N/A GPU1 PIX X NODE NODE SYS SYS SYS SYS 0-35,72-107 0 N/A GPU2 NODE NODE X PIX SYS SYS SYS SYS 0-35,72-107 0 N/A GPU3 NODE NODE PIX X SYS SYS SYS SYS 0-35,72-107 0 N/A GPU4 SYS SYS SYS SYS X PIX NODE NODE 36-71,108-143 1 N/A GPU5 SYS SYS SYS SYS PIX X NODE NODE 36-71,108-143 1 N/A GPU6 SYS SYS SYS SYS NODE NODE X PIX 36-71,108-143 1 N/A GPU7 SYS SYS SYS SYS NODE NODE PIX X 36-71,108-143 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

Before submitting a new issue...

ljwps commented 3 days ago

Isn't anyone willing to answer?

fff196 commented 2 days ago

+1