vllm-project / vllm

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

[Usage]: How to determine how many concurrent requests can be supported in an acceptable time duration with demo api server? #4853

Open senbinyu opened 5 months ago

senbinyu commented 5 months ago

Your current environment

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

OS: Ubuntu 20.04.4 LTS (x86_64) GCC version: (Ubuntu 11.2.0-19ubuntu1) 11.2.0 Clang version: Could not collect CMake version: version 3.27.9 Libc version: glibc-2.35

Python version: 3.11.0 (main, Mar 1 2023, 18:26:19) [GCC 11.2.0] (64-bit runtime) Python platform: Linux-5.15.0-105-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 RTX 6000 Ada Generation GPU 1: NVIDIA RTX 6000 Ada Generation GPU 2: NVIDIA RTX 6000 Ada Generation GPU 3: NVIDIA RTX 6000 Ada Generation

Nvidia driver version: 535.171.04 cuDNN version: Could not collect HIP runtime version: N/A MIOpen runtime version: N/A Is XNNPACK available: True

CPU: 架构: x86_64 CPU 运行模式: 32-bit, 64-bit 字节序: Little Endian Address sizes: 48 bits physical, 48 bits virtual CPU: 64 在线 CPU 列表: 0-63 每个核的线程数: 2 每个座的核数: 32 座: 1 NUMA 节点: 1 厂商 ID: AuthenticAMD CPU 系列: 25 型号: 8 型号名称: AMD Ryzen Threadripper PRO 5975WX 32-Cores 步进: 2 Frequency boost: enabled CPU MHz: 1800.000 CPU 最大 MHz: 7006.6401 CPU 最小 MHz: 1800.0000 BogoMIPS: 7186.68 虚拟化: AMD-V L1d 缓存: 1 MiB L1i 缓存: 1 MiB L2 缓存: 16 MiB L3 缓存: 128 MiB NUMA 节点0 CPU: 0-63 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: Mitigation; safe RET, no microcode 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; Retpolines, IBPB conditional, IBRS_FW, STIBP always-on, RSB filling, PBRSB-eIBRS Not affected Vulnerability Srbds: Not affected Vulnerability Tsx async abort: Not affected 标记: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid aperfmperf rapl pni pclmulqdq monitor ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb cat_l3 cdp_l3 invpcid_single hw_pstate ssbd mba ibrs ibpb stibp vmmcall fsgsbase bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local clzero irperf xsaveerptr rdpru wbnoinvd amd_ppin arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif v_spec_ctrl umip pku ospke vaes vpclmulqdq rdpid overflow_recov succor smca fsrm

Versions of relevant libraries: [pip3] mypy-protobuf==3.4.0 [pip3] numpy==1.26.2 [pip3] nvidia-nccl-cu11==2.14.3 [pip3] nvidia-nccl-cu12==2.18.1 [pip3] pytorch-lightning==2.1.3 [pip3] torch==2.1.2 [pip3] torchaudio==2.1.2 [pip3] torchmetrics==1.3.0.post0 [pip3] torchvision==0.16.2 [pip3] triton==2.1.0 [conda] numpy 1.26.2 pypi_0 pypi [conda] nvidia-nccl-cu11 2.14.3 pypi_0 pypi [conda] nvidia-nccl-cu12 2.18.1 pypi_0 pypi [conda] pytorch-lightning 2.1.3 pypi_0 pypi [conda] torch 2.1.2 pypi_0 pypi [conda] torchaudio 2.1.2 pypi_0 pypi [conda] torchmetrics 1.3.0.post0 pypi_0 pypi [conda] torchvision 0.16.2 pypi_0 pypi [conda] triton 2.1.0 pypi_0 pypiROCM Version: Could not collect Neuron SDK Version: N/A vLLM Version: 0.4.0 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 PHB SYS SYS 0-63 0 N/A GPU1 PHB X SYS SYS 0-63 0 N/A GPU2 SYS SYS X PHB 0-63 0 N/A GPU3 SYS SYS PHB X 0-63 0 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

How would you like to use vllm

I used the demo API server (vllm.entrypoint.api_server.py with --max-num-seqs=256). I ran one server at one gpu now. When sending multiple concurrent requests, vllm should schedule them into a continuous batch and generate responses. However, the generate time increases linearly with the number of concurrent requests (4 requests ~1.5s, 8 requests ~2.7s, 16 request ~5s. It would be acceptable within 2s for me). In my case, i think it did not hit the memory bound, since the running time from A6000(48G) and 4090(24G) is almost the same. So does this mean it is already limited by the I/O bound or the GPU calc capability? Is there any trick or api i can use to improve the number of concurrent requests with an acceptable time duration? Great thanks.

rkooo567 commented 4 months ago

How do you send requests? can you share the code here?

Also note that when your batch size is large, enough it will reach to compute bound. And once it hits the compute bound, increasing batch doesn't improve much performance.

Other possibility is you don't have enough kv caches to batch all requests. In this case, although you max num seqs is 256, it may never reach that batch size because you cannot batch requests more than your available kv caches.

senbinyu commented 4 months ago

@rkooo567 The demo codes are attched. I changed the .py files to .txt since it dosen't support the upload of .py files. I used threadpool to send requests in order to mimic the behavior of concurrent requests. DeepseekCoder is used as the engine model, after awq, loading model weights took 3.7GB. So i guess the compute bound rather than the kv cache might be the reason.
api_server.txt github_demo.txt multi_8192.json

rkooo567 commented 4 months ago

one thing you can try is to set disable_log_stats=False, and it can also show you the # of running requests. If it is close to max num seqs, I think it is the compute bound case. if it is too low, maybe a code bug (since you don't use much memory for model weights)