vllm - 💡(How to fix) Fix [Bug]: Severe Head-of-Line Blocking (147x TTFT) under Prefix Caching with Asymmetric Batches [4 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vllm-project/vllm#37308Fetched 2026-04-08 00:53:34
View on GitHub
Comments
4
Participants
3
Timeline
6
Reactions
0
Author
Timeline (top)
commented ×4cross-referenced ×1labeled ×1

Error Message

Under the 6-request concurrent trace below, the two 128-token requests (r08, r05) observe:

Code Example

/nfshomes/yunze/miniconda3/envs/vllm-fuzz/lib/python3.11/site-packages/torch/cuda/__init__.py:63: FutureWarning: The pynvml package is deprecated. Please install nvidia-ml-py instead. If you did not install pynvml directly, please report this to the maintainers of the package that installed pynvml for you.
  import pynvml  # type: ignore[import]
Collecting environment information...
==============================
        System Info
==============================
OS                           : Red Hat Enterprise Linux release 8.10 (Ootpa) (x86_64)
GCC version                  : (GCC) 8.5.0 20210514 (Red Hat 8.5.0-28)
Clang version                : Could not collect
CMake version                : version 3.26.5
Libc version                 : glibc-2.28

==============================
       PyTorch Info
==============================
PyTorch version              : 2.9.0+cu128
Is debug build               : False
CUDA used to build PyTorch   : 12.8
ROCM used to build PyTorch   : N/A

==============================
      Python Environment
==============================
Python version               : 3.11.14 (main, Oct 21 2025, 18:31:21) [GCC 11.2.0] (64-bit runtime)
Python platform              : Linux-4.18.0-553.109.1.el8_10.x86_64-x86_64-with-glibc2.28

==============================
       CUDA / GPU Info
==============================
Is CUDA available            : True
CUDA runtime version         : 13.1.115
CUDA_MODULE_LOADING set to   : 
GPU models and configuration : GPU 0: NVIDIA RTX A6000
Nvidia driver version        : 590.48.01
cuDNN version                : Could not collect
HIP runtime version          : N/A
MIOpen runtime version       : N/A
Is XNNPACK available         : True

==============================
          CPU Info
==============================
Architecture:        x86_64
CPU op-mode(s):      32-bit, 64-bit
Byte Order:          Little Endian
CPU(s):              32
On-line CPU(s) list: 0-31
Thread(s) per core:  1
Core(s) per socket:  16
Socket(s):           2
NUMA node(s):        2
Vendor ID:           AuthenticAMD
CPU family:          23
Model:               49
Model name:          AMD EPYC 7302 16-Core Processor
Stepping:            0
CPU MHz:             3000.000
CPU max MHz:         3000.0000
CPU min MHz:         1500.0000
BogoMIPS:            6000.12
Virtualization:      AMD-V
L1d cache:           32K
L1i cache:           32K
L2 cache:            512K
L3 cache:            16384K
NUMA node0 CPU(s):   0-15
NUMA node1 CPU(s):   16-31
Flags:               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 pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 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 hw_pstate ssbd mba ibrs ibpb stibp vmmcall fsgsbase bmi1 avx2 smep bmi2 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 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 rdpid overflow_recov succor smca sme sev sev_es

==============================
Versions of relevant libraries
==============================
[pip3] flashinfer-python==0.5.2
[pip3] numpy==2.2.6
[pip3] nvidia-cublas-cu12==12.8.4.1
[pip3] nvidia-cuda-cupti-cu12==12.8.90
[pip3] nvidia-cuda-nvrtc-cu12==12.8.93
[pip3] nvidia-cuda-runtime-cu12==12.8.90
[pip3] nvidia-cudnn-cu12==9.10.2.21
[pip3] nvidia-cudnn-frontend==1.18.0
[pip3] nvidia-cufft-cu12==11.3.3.83
[pip3] nvidia-cufile-cu12==1.13.1.3
[pip3] nvidia-curand-cu12==10.3.9.90
[pip3] nvidia-cusolver-cu12==11.7.3.90
[pip3] nvidia-cusparse-cu12==12.5.8.93
[pip3] nvidia-cusparselt-cu12==0.7.1
[pip3] nvidia-cutlass-dsl==4.4.1
[pip3] nvidia-cutlass-dsl-libs-base==4.4.1
[pip3] nvidia-ml-py==13.590.48
[pip3] nvidia-nccl-cu12==2.27.5
[pip3] nvidia-nvjitlink-cu12==12.8.93
[pip3] nvidia-nvshmem-cu12==3.3.20
[pip3] nvidia-nvtx-cu12==12.8.90
[pip3] pynvml==13.0.1
[pip3] pyzmq==27.1.0
[pip3] torch==2.9.0
[pip3] torchaudio==2.9.0
[pip3] torchvision==0.24.0
[pip3] transformers==4.57.6
[pip3] triton==3.5.0
[conda] flashinfer-python                    0.5.2            pypi_0           pypi
[conda] numpy                                2.2.6            pypi_0           pypi
[conda] nvidia-cublas-cu12                   12.8.4.1         pypi_0           pypi
[conda] nvidia-cuda-cupti-cu12               12.8.90          pypi_0           pypi
[conda] nvidia-cuda-nvrtc-cu12               12.8.93          pypi_0           pypi
[conda] nvidia-cuda-runtime-cu12             12.8.90          pypi_0           pypi
[conda] nvidia-cudnn-cu12                    9.10.2.21        pypi_0           pypi
[conda] nvidia-cudnn-frontend                1.18.0           pypi_0           pypi
[conda] nvidia-cufft-cu12                    11.3.3.83        pypi_0           pypi
[conda] nvidia-cufile-cu12                   1.13.1.3         pypi_0           pypi
[conda] nvidia-curand-cu12                   10.3.9.90        pypi_0           pypi
[conda] nvidia-cusolver-cu12                 11.7.3.90        pypi_0           pypi
[conda] nvidia-cusparse-cu12                 12.5.8.93        pypi_0           pypi
[conda] nvidia-cusparselt-cu12               0.7.1            pypi_0           pypi
[conda] nvidia-cutlass-dsl                   4.4.1            pypi_0           pypi
[conda] nvidia-cutlass-dsl-libs-base         4.4.1            pypi_0           pypi
[conda] nvidia-ml-py                         13.590.48        pypi_0           pypi
[conda] nvidia-nccl-cu12                     2.27.5           pypi_0           pypi
[conda] nvidia-nvjitlink-cu12                12.8.93          pypi_0           pypi
[conda] nvidia-nvshmem-cu12                  3.3.20           pypi_0           pypi
[conda] nvidia-nvtx-cu12                     12.8.90          pypi_0           pypi
[conda] pynvml                               13.0.1           pypi_0           pypi
[conda] pyzmq                                27.1.0           pypi_0           pypi
[conda] torch                                2.9.0            pypi_0           pypi
[conda] torchaudio                           2.9.0            pypi_0           pypi
[conda] torchvision                          0.24.0           pypi_0           pypi
[conda] transformers                         4.57.6           pypi_0           pypi
[conda] triton                               3.5.0            pypi_0           pypi

==============================
         vLLM Info
==============================
ROCM Version                 : Could not collect
vLLM Version                 : 0.11.2
vLLM Build Flags:
  CUDA Archs: Not Set; ROCm: Disabled
GPU Topology:
  	GPU0	NIC0	NIC1	NIC2	CPU Affinity	NUMA Affinity	GPU NUMA ID
GPU0	 X 	SYS	SYS	NODE	4,9	0		N/A
NIC0	SYS	 X 	PIX	SYS				
NIC1	SYS	PIX	 X 	SYS				
NIC2	NODE	SYS	SYS	 X 				

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

NIC Legend:

  NIC0: mlx5_2
  NIC1: mlx5_3
  NIC2: mlx5_bond_0

==============================
     Environment Variables
==============================
LD_LIBRARY_PATH=/opt/common/cuda/cuda-13.1.1/lib64:
CUDA_HOME=/opt/common/cuda/cuda-13.1.1
CUDA_HOME=/opt/common/cuda/cuda-13.1.1
CUDA_VISIBLE_DEVICES=0
CUDA_VISIBLE_DEVICES=0
PYTORCH_NVML_BASED_CUDA_CHECK=1
TORCHINDUCTOR_COMPILE_THREADS=1

---

Model: Qwen/Qwen2.5-0.5B-Instruct
vLLM version: (tested on current main)
GPU: NVIDIA RTX A6000
CUDA version: 12.x
Python: 3.10

---

python -m vllm.entrypoints.openai.api_server \
    --model Qwen/Qwen2.5-0.5B-Instruct \
    --port 8000 \
    --gpu-memory-utilization 0.95 \
    --max-model-len 32768 \
    --enable-prefix-caching \
    --disable-log-requests

---

(vllm-fuzz) bash-4.4$ python3 archived_findings/latency_spike_march_17/repro_minimal.py   --base-url http://localhost:8000 --runs 3                                                                                                                                             
============================================================                                                                                                                                                                                                                    
  vLLM head-of-line blocking — minimal reproduction                                                                                                                                                                                                                             
  Finding : finding_00923_1785332041 (iteration 923)                                                                                                                                                                                                                            
  Server  : http://localhost:8000                                                                                                                                                                                                                                               
  Model   : Qwen/Qwen2.5-0.5B-Instruct                                                                                                                                                                                                                                          
  Runs    : 3                                                                                                                                                                                                                                                                   
  Threshold: 97 ms TTFT                                                                                                                                                                                                                                                         
============================================================                                                                                                                                                                                                                    
                                                                                                                                                                                                                                                                                
Trace: 6 concurrent requests — 4 heavy (2048 tokens) + 2 light (128 tokens)                                                                                                                                                                                                     
  r08 : 128-token prompt,  32 output tokens  (streaming)     ← victim                                                                                                                                                                                                           
  r05 : 128-token prompt,  64 output tokens  (streaming)     ← victim                                                                                                                                                                                                           
  r04 : 2048-token prompt, 256 output tokens (streaming)                                                                                                                                                                                                                        
  r06 : 2048-token prompt, 128 output tokens (non-streaming)KV pressure                                                                                                                                                                                                      
  r07 : 2048-token prompt, 512 output tokens (streaming)     ← decode bottleneck                                                                                                                                                                                                
  r02 : 2048-token prompt, 128 output tokens (streaming)                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                                                
  Run  1  (3704ms wall)
    r08                           :    488.9 ms *** SLOW
    r04                           :    721.4 ms *** SLOW
    r06                           : (non-streaming, no TTFT)
    r05                           :    749.8 ms *** SLOW
    r07                           :    990.3 ms *** SLOW
    r02                           :   1218.1 ms *** SLOW
                         
  Run  2  (2302ms wall)
    r08                           :     25.1 ms
    r04                           :     33.9 ms
    r06                           : (non-streaming, no TTFT)
    r05                           :     56.6 ms
    r07                           :     51.4 ms
    r02                           :     39.7 ms

  Run  3  (2290ms wall)
    r08                           :     13.3 ms
    r04                           :     31.8 ms
    r06                           : (non-streaming, no TTFT)
    r05                           :     54.7 ms
    r07                           :     49.7 ms
    r02                           :     37.5 ms

============================================================
  RESULTS SUMMARY
============================================================
  Streaming TTFT across 15 samples (3 runs × streaming requests):
    mean :    304.2 ms
    p50  :     51.4 ms
    p99  :   1218.1 ms
    max  :   1218.1 ms
    threshold :     97.0 ms

  Small-request (r08 + r05) TTFT6 samples:
    mean :    231.4 ms
    p99  :    749.8 ms  (7.7× threshold)

------------------------------------------------------------
  RESULT : CONFIRMED
  p99 TTFT 1218.1 ms exceeds threshold 97 ms (12.6×)
RAW_BUFFERClick to expand / collapse

Your current environment

<details> <summary>The output of <code>python collect_env.py</code></summary>
/nfshomes/yunze/miniconda3/envs/vllm-fuzz/lib/python3.11/site-packages/torch/cuda/__init__.py:63: FutureWarning: The pynvml package is deprecated. Please install nvidia-ml-py instead. If you did not install pynvml directly, please report this to the maintainers of the package that installed pynvml for you.
  import pynvml  # type: ignore[import]
Collecting environment information...
==============================
        System Info
==============================
OS                           : Red Hat Enterprise Linux release 8.10 (Ootpa) (x86_64)
GCC version                  : (GCC) 8.5.0 20210514 (Red Hat 8.5.0-28)
Clang version                : Could not collect
CMake version                : version 3.26.5
Libc version                 : glibc-2.28

==============================
       PyTorch Info
==============================
PyTorch version              : 2.9.0+cu128
Is debug build               : False
CUDA used to build PyTorch   : 12.8
ROCM used to build PyTorch   : N/A

==============================
      Python Environment
==============================
Python version               : 3.11.14 (main, Oct 21 2025, 18:31:21) [GCC 11.2.0] (64-bit runtime)
Python platform              : Linux-4.18.0-553.109.1.el8_10.x86_64-x86_64-with-glibc2.28

==============================
       CUDA / GPU Info
==============================
Is CUDA available            : True
CUDA runtime version         : 13.1.115
CUDA_MODULE_LOADING set to   : 
GPU models and configuration : GPU 0: NVIDIA RTX A6000
Nvidia driver version        : 590.48.01
cuDNN version                : Could not collect
HIP runtime version          : N/A
MIOpen runtime version       : N/A
Is XNNPACK available         : True

==============================
          CPU Info
==============================
Architecture:        x86_64
CPU op-mode(s):      32-bit, 64-bit
Byte Order:          Little Endian
CPU(s):              32
On-line CPU(s) list: 0-31
Thread(s) per core:  1
Core(s) per socket:  16
Socket(s):           2
NUMA node(s):        2
Vendor ID:           AuthenticAMD
CPU family:          23
Model:               49
Model name:          AMD EPYC 7302 16-Core Processor
Stepping:            0
CPU MHz:             3000.000
CPU max MHz:         3000.0000
CPU min MHz:         1500.0000
BogoMIPS:            6000.12
Virtualization:      AMD-V
L1d cache:           32K
L1i cache:           32K
L2 cache:            512K
L3 cache:            16384K
NUMA node0 CPU(s):   0-15
NUMA node1 CPU(s):   16-31
Flags:               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 pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 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 hw_pstate ssbd mba ibrs ibpb stibp vmmcall fsgsbase bmi1 avx2 smep bmi2 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 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 rdpid overflow_recov succor smca sme sev sev_es

==============================
Versions of relevant libraries
==============================
[pip3] flashinfer-python==0.5.2
[pip3] numpy==2.2.6
[pip3] nvidia-cublas-cu12==12.8.4.1
[pip3] nvidia-cuda-cupti-cu12==12.8.90
[pip3] nvidia-cuda-nvrtc-cu12==12.8.93
[pip3] nvidia-cuda-runtime-cu12==12.8.90
[pip3] nvidia-cudnn-cu12==9.10.2.21
[pip3] nvidia-cudnn-frontend==1.18.0
[pip3] nvidia-cufft-cu12==11.3.3.83
[pip3] nvidia-cufile-cu12==1.13.1.3
[pip3] nvidia-curand-cu12==10.3.9.90
[pip3] nvidia-cusolver-cu12==11.7.3.90
[pip3] nvidia-cusparse-cu12==12.5.8.93
[pip3] nvidia-cusparselt-cu12==0.7.1
[pip3] nvidia-cutlass-dsl==4.4.1
[pip3] nvidia-cutlass-dsl-libs-base==4.4.1
[pip3] nvidia-ml-py==13.590.48
[pip3] nvidia-nccl-cu12==2.27.5
[pip3] nvidia-nvjitlink-cu12==12.8.93
[pip3] nvidia-nvshmem-cu12==3.3.20
[pip3] nvidia-nvtx-cu12==12.8.90
[pip3] pynvml==13.0.1
[pip3] pyzmq==27.1.0
[pip3] torch==2.9.0
[pip3] torchaudio==2.9.0
[pip3] torchvision==0.24.0
[pip3] transformers==4.57.6
[pip3] triton==3.5.0
[conda] flashinfer-python                    0.5.2            pypi_0           pypi
[conda] numpy                                2.2.6            pypi_0           pypi
[conda] nvidia-cublas-cu12                   12.8.4.1         pypi_0           pypi
[conda] nvidia-cuda-cupti-cu12               12.8.90          pypi_0           pypi
[conda] nvidia-cuda-nvrtc-cu12               12.8.93          pypi_0           pypi
[conda] nvidia-cuda-runtime-cu12             12.8.90          pypi_0           pypi
[conda] nvidia-cudnn-cu12                    9.10.2.21        pypi_0           pypi
[conda] nvidia-cudnn-frontend                1.18.0           pypi_0           pypi
[conda] nvidia-cufft-cu12                    11.3.3.83        pypi_0           pypi
[conda] nvidia-cufile-cu12                   1.13.1.3         pypi_0           pypi
[conda] nvidia-curand-cu12                   10.3.9.90        pypi_0           pypi
[conda] nvidia-cusolver-cu12                 11.7.3.90        pypi_0           pypi
[conda] nvidia-cusparse-cu12                 12.5.8.93        pypi_0           pypi
[conda] nvidia-cusparselt-cu12               0.7.1            pypi_0           pypi
[conda] nvidia-cutlass-dsl                   4.4.1            pypi_0           pypi
[conda] nvidia-cutlass-dsl-libs-base         4.4.1            pypi_0           pypi
[conda] nvidia-ml-py                         13.590.48        pypi_0           pypi
[conda] nvidia-nccl-cu12                     2.27.5           pypi_0           pypi
[conda] nvidia-nvjitlink-cu12                12.8.93          pypi_0           pypi
[conda] nvidia-nvshmem-cu12                  3.3.20           pypi_0           pypi
[conda] nvidia-nvtx-cu12                     12.8.90          pypi_0           pypi
[conda] pynvml                               13.0.1           pypi_0           pypi
[conda] pyzmq                                27.1.0           pypi_0           pypi
[conda] torch                                2.9.0            pypi_0           pypi
[conda] torchaudio                           2.9.0            pypi_0           pypi
[conda] torchvision                          0.24.0           pypi_0           pypi
[conda] transformers                         4.57.6           pypi_0           pypi
[conda] triton                               3.5.0            pypi_0           pypi

==============================
         vLLM Info
==============================
ROCM Version                 : Could not collect
vLLM Version                 : 0.11.2
vLLM Build Flags:
  CUDA Archs: Not Set; ROCm: Disabled
GPU Topology:
  	GPU0	NIC0	NIC1	NIC2	CPU Affinity	NUMA Affinity	GPU NUMA ID
GPU0	 X 	SYS	SYS	NODE	4,9	0		N/A
NIC0	SYS	 X 	PIX	SYS				
NIC1	SYS	PIX	 X 	SYS				
NIC2	NODE	SYS	SYS	 X 				

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

NIC Legend:

  NIC0: mlx5_2
  NIC1: mlx5_3
  NIC2: mlx5_bond_0

==============================
     Environment Variables
==============================
LD_LIBRARY_PATH=/opt/common/cuda/cuda-13.1.1/lib64:
CUDA_HOME=/opt/common/cuda/cuda-13.1.1
CUDA_HOME=/opt/common/cuda/cuda-13.1.1
CUDA_VISIBLE_DEVICES=0
CUDA_VISIBLE_DEVICES=0
PYTORCH_NVML_BASED_CUDA_CHECK=1
TORCHINDUCTOR_COMPILE_THREADS=1
</details>

🐛 Describe the bug

Again, we are fuzzing VLLM for a class project and found a few issues, after a while of triaging we think there is another issue is particularly of interest to report:

Model: Qwen/Qwen2.5-0.5B-Instruct
vLLM version: (tested on current main)
GPU: NVIDIA RTX A6000
CUDA version: 12.x
Python: 3.10

Launch command:

python -m vllm.entrypoints.openai.api_server \
    --model Qwen/Qwen2.5-0.5B-Instruct \
    --port 8000 \
    --gpu-memory-utilization 0.95 \
    --max-model-len 32768 \
    --enable-prefix-caching \
    --disable-log-requests

When 4 large-prompt requests (2048 tokens) and 2 small-prompt requests (128 tokens) arrive concurrently within a 40ms window — all sharing the same cached prefix, the two small requests are head-of-line blocked behind the large requests' prefill and decode phases, producing a 14–147× TTFT regression.

The small requests (prompt=128, max_tokens=32) should complete in under 100ms on an idle server. Under this trace they observe p99 TTFT of 1400–14000ms. The server reports healthy throughout. No errors, no crashes — the latency degradation is completely silent.

This was found via automated fuzzing and confirmed across 10 independent runs on a dedicated node with no other workloads, then multiple reruns by myself.

Trigger conditions:

  • --enable-prefix-caching enabled (all 6 requests share a 32-token cached prefix)
  • 4 concurrent requests with prompt_len=2048, at least one with max_tokens≥256
  • 2 concurrent requests with prompt_len=128
  • All 6 arrive within a ~40ms burst window
  • One large request uses stream=False (holds its KV slot for the full decode duration)

No logprobs. No n_completions. No special sampling parameters.


Expected behavior

A request with prompt=128 tokens, max_tokens=32 should receive its first token within ~100ms regardless of what other requests are in-flight. vLLM's continuous batching is designed to interleave prefill and decode so that short requests are not blocked by long ones.

Observed behavior

Under the 6-request concurrent trace below, the two 128-token requests (r08, r05) observe:

MetricValue
Expected p99 TTFT~97 ms
Observed p99 TTFT (10 runs)1428 ms
Observed max single-sample TTFT14239 ms
Regression14.7–147×

The server remains healthy (/health → 200, /metrics shows requests_running=6, requests_waiting=0) for the entire duration. No error is returned to any client, which is potentially the worrisome part.

Observed Output in one reproduction

(vllm-fuzz) bash-4.4$ python3 archived_findings/latency_spike_march_17/repro_minimal.py   --base-url http://localhost:8000 --runs 3                                                                                                                                             
============================================================                                                                                                                                                                                                                    
  vLLM head-of-line blocking — minimal reproduction                                                                                                                                                                                                                             
  Finding : finding_00923_1785332041 (iteration 923)                                                                                                                                                                                                                            
  Server  : http://localhost:8000                                                                                                                                                                                                                                               
  Model   : Qwen/Qwen2.5-0.5B-Instruct                                                                                                                                                                                                                                          
  Runs    : 3                                                                                                                                                                                                                                                                   
  Threshold: 97 ms TTFT                                                                                                                                                                                                                                                         
============================================================                                                                                                                                                                                                                    
                                                                                                                                                                                                                                                                                
Trace: 6 concurrent requests — 4 heavy (2048 tokens) + 2 light (128 tokens)                                                                                                                                                                                                     
  r08 : 128-token prompt,  32 output tokens  (streaming)     ← victim                                                                                                                                                                                                           
  r05 : 128-token prompt,  64 output tokens  (streaming)     ← victim                                                                                                                                                                                                           
  r04 : 2048-token prompt, 256 output tokens (streaming)                                                                                                                                                                                                                        
  r06 : 2048-token prompt, 128 output tokens (non-streaming) ← KV pressure                                                                                                                                                                                                      
  r07 : 2048-token prompt, 512 output tokens (streaming)     ← decode bottleneck                                                                                                                                                                                                
  r02 : 2048-token prompt, 128 output tokens (streaming)                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                                                
  Run  1  (3704ms wall)
    r08                           :    488.9 ms *** SLOW
    r04                           :    721.4 ms *** SLOW
    r06                           : (non-streaming, no TTFT)
    r05                           :    749.8 ms *** SLOW
    r07                           :    990.3 ms *** SLOW
    r02                           :   1218.1 ms *** SLOW
                         
  Run  2  (2302ms wall)
    r08                           :     25.1 ms
    r04                           :     33.9 ms
    r06                           : (non-streaming, no TTFT)
    r05                           :     56.6 ms
    r07                           :     51.4 ms
    r02                           :     39.7 ms

  Run  3  (2290ms wall)
    r08                           :     13.3 ms
    r04                           :     31.8 ms
    r06                           : (non-streaming, no TTFT)
    r05                           :     54.7 ms
    r07                           :     49.7 ms
    r02                           :     37.5 ms

============================================================
  RESULTS SUMMARY
============================================================
  Streaming TTFT across 15 samples (3 runs × streaming requests):
    mean :    304.2 ms
    p50  :     51.4 ms
    p99  :   1218.1 ms
    max  :   1218.1 ms
    threshold :     97.0 ms

  Small-request (r08 + r05) TTFT — 6 samples:
    mean :    231.4 ms
    p99  :    749.8 ms  (7.7× threshold)

------------------------------------------------------------
  RESULT : CONFIRMED
  p99 TTFT 1218.1 ms exceeds threshold 97 ms (12.6×)

To reproduce

  1. Run the launch command.
  2. then you can use this script

I attach the finding trace we used we reconstruct in the repro script as well.

Before submitting a new issue...

  • Make sure you already searched for relevant issues, and asked the chatbot living at the bottom right corner of the documentation page, which can answer lots of frequently asked questions.

extent analysis

Fix Plan

To address the head-of-line blocking issue, we need to modify the request handling mechanism in vLLM to prioritize small requests. Here are the steps:

  • Modify the vllm.entrypoints.openai.api_server module:
    • Introduce a new parameter --priority-small-requests to enable prioritization of small requests.
    • Implement a priority queue to handle incoming requests, where small requests are given higher priority.
  • Update the vllm.models module:
    • Modify the prefill and decode phases to yield control back to the main thread when a small request is pending.
    • Use a semaphore or a lock to ensure that only one large request is being processed at a time, allowing small requests to be interleaved.
  • Implement a timeout mechanism:
    • Set a timeout for large requests to prevent them from blocking small requests indefinitely.
    • Use a timer to monitor the processing time of large requests and interrupt them if they exceed the timeout.

Example code snippet:

import threading
import queue

class PriorityQueue:
    def __init__(self):
        self.queue = queue.Queue()
        self.lock = threading.Lock()

    def put(self, request):
        with self.lock:
            self.queue.put(request)

    def get(self):
        with self.lock:
            return self.queue.get()

class RequestHandler:
    def __init__(self, priority_queue):
        self.priority_queue = priority_queue
        self.semaphore = threading.Semaphore(1)

    def handle_request(self, request):
        if request.size < 128:  # small request
            self.priority_queue.put(request)
        else:
            self.semaphore.acquire()
            try:
                # process large request
                pass
            finally:
                self.semaphore.release()

    def process_requests(self):
        while True:
            request = self.priority_queue.get()
            if request.size < 128:  # small request
                # process small request
                pass
            else:
                # process large request
                pass

# Usage
priority_queue = PriorityQueue()
request_handler = RequestHandler(priority_queue)

# Create and start a thread to process requests
thread = threading.Thread(target=request_handler.process_requests)
thread.start()

# Handle incoming requests
while True:
    request = get_request_from_client()
    request_handler.handle_request(request)

Verification

To verify the fix, run the reproduction script with the modified vLLM code and measure the TTFT of small requests. The p99 TTFT should be within the expected threshold of 97 ms.

Extra Tips

  • Monitor the performance of the modified vLLM code to ensure that it does not introduce any new issues or regressions.
  • Consider implementing a more sophisticated scheduling algorithm to handle requests, such as a least-attained-service (LAS) scheduler.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

A request with prompt=128 tokens, max_tokens=32 should receive its first token within ~100ms regardless of what other requests are in-flight. vLLM's continuous batching is designed to interleave prefill and decode so that short requests are not blocked by long ones.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING