Benchmarking random single-turn prompts to test prefix caching
Random tokens never share prefixes, masking prefix-caching wins and sizing needs.
Operator task guide
Chunked prefill splits long prompt prefills across scheduler steps capped by --max-num-batched-tokens so large prompts do not stall active decode streams (improving inter-token latency). Automatic prefix caching (--enable-prefix-caching) reuses KV blocks across shared system prompts or multi-turn chats.
Setting --max-num-batched-tokens too high spikes activation memory and triggers CUDA OOM during warmup, while setting it too low drops prefill throughput on compute-bound GPUs. Benchmark one flag change at a time with vllm bench serve.
Reviewed . Reference guidance is not a diagnosis of your workload.
Recent vLLM versions enable chunked prefill and prefix caching by default depending on model and version. Check startup logs so you know which scheduler settings are active.
grep -iE 'chunked|prefix_caching|max_num_batched_tokens|max_num_seqs' vllm.logCapture p50/p95/p99 TTFT, ITL, and output tokens/sec with fixed prompt/output distributions and seed before tuning flags.
vllm bench serve --backend vllm --base-url http://127.0.0.1:8000 \
--model YOUR_MODEL --dataset-name random \
--random-input-len 2048 --random-output-len 256 --seed 42 \
--num-prompts 500 --request-rate 8 --percentile-metrics ttft,itl,e2el --metric-percentiles 50,95,99Lower --max-num-batched-tokens (e.g. 2048 to 4096) to protect decode ITL under heavy long-prompt arrival, or raise it (e.g. 8192 to 16384) when GPU HBM allows and maximizing prefill throughput matters more.
vllm serve YOUR_MODEL \
--enable-chunked-prefill \
--enable-prefix-caching \
--max-num-batched-tokens 4096 \
--max-num-seqs 128Inspect Prometheus metrics after each benchmark run to verify prefix cache hit rates increased without introducing KV preemptions or activation OOMs.
curl -fsS http://127.0.0.1:8000/metrics | grep -E 'prefix_cache|num_preemptions|gpu_cache_usage_perc'| Signal | What it means | Next action |
|---|---|---|
| High decode ITL jitter whenever long prompts arrive | Large prefills are monopolizing scheduler iterations. | Enable chunked prefill and lower --max-num-batched-tokens. |
| CUDA OOM during dummy run / memory profiling at startup | --max-num-batched-tokens or --max-num-seqs creates an oversized activation peak. | Reduce --max-num-batched-tokens (for example to 2048 or 4096) and re-profile. |
| High TTFT on multi-turn chat or RAG system prompts | Shared prompt prefixes are being recomputed. | Verify --enable-prefix-caching is active and check prefix_cache_hits in /metrics. |
| Preemptions climb while raising --max-num-seqs | Scheduler admits more requests than KV cache blocks can hold. | Lower --max-num-seqs or increase KV capacity via FP8 KV / higher TP. |
Random tokens never share prefixes, masking prefix-caching wins and sizing needs.
vLLM profiles worst-case activation memory against max_num_batched_tokens at boot.
Recomputing evicted sequences consumes GPU FLOPs and cuts real served tok/s.
Separate queue wait, prefill latency, and cache misses.
Resolve startup OOMs tied to max_num_batched_tokens.
Stop silent throughput collapse from sequence eviction.
Monitor TTFT, ITL, cache hits, and preemptions live.
For low-latency interactive serving, 2048 to 4096 protects inter-token latency while keeping activation peaks modest. For offline batch prefill throughput on 80GB+ GPUs, 8192 to 16384 increases compute utilization.
It accelerates multi-turn conversations, few-shot system prompts, agent loops, and RAG workloads where requests share identical leading token blocks.
Yes, if --max-num-batched-tokens is set larger than available activation headroom or exceeds max-model-len expectations during startup profiling.
Use --no-enable-prefix-caching or --no-enable-chunked-prefill (flag names depend on vLLM release; confirm with vllm serve --help) while holding seed and prompt mix constant.
Get the likely cause, supporting evidence, and next safe steps with the same cloud reasoning used by paid plans. A crash the engine recognizes is answered in seconds, then checked by an independent AI review that updates this page when it finishes. A crash it does not recognize waits for the AI's own answer, which can take a few minutes. No account, card, or installation. Logs are masked at Denpex API ingress and are not saved to account history.
Before uploading, review cloud data handling and local options.
Upload your log file. Large files are processed in your browser. Only selected evidence is submitted when you run diagnosis.
No credit card. No automatic subscription. See whether Denpex helps with an incident you already understand.
Up to 50 diagnoses a day for 30 days. Verify your work email to activate an eligible company evaluation, then replay a resolved incident and compare the evidence and next steps with your team's confirmed cause.
Use the three free diagnoses to review your error and relevant evidence. Keep reference guidance separate from the cause and recovery status of your own workload.
Diagnose your incident