Back

Technical · Experiment

Can Auditing 5% of Agent Turns Slow the Other 95%?

An empirical vLLM v0.34.0 benchmark measuring cross-cohort tail-latency spillover when a sample of agent turns requests prompt_logprobs, and why Prometheus prefix-cache hit rate stays flat.

When running multi-turn agents behind a shared vLLM replica with automatic prefix caching enabled, teams often sample a small fraction of turns for online auditing, reward scoring, or log-probability checks using prompt_logprobs.

At 5% sampling, that looks harmless on paper. Most turns never ask for prompt logprobs, and your Prometheus prefix-cache hit rate dashboard barely moves.

This experiment tests what actually happens on the shared GPU and API server. Auditing just 5% of turns at 75% of measured baseline capacity (18.0 req/s) pushes p95 time-to-first-token (TTFT) for the other, completely unscored streaming turns up by +523.3% (6.2×) in steady state, while the reported Prometheus prefix-cache hit ratio stays pinned at 97.94% (0.00 percentage points of change).

Experiment note. All code, raw manifests, and plotting scripts are in bajajku/vllm-prompt-logprobs-spillover (pinned to commit aa52129). Runs executed on vllm==0.34.0 serving Qwen/Qwen2.5-3B-Instruct in bfloat16 on 1× NVIDIA A100-SXM4-80GB (--enable-prefix-caching, --generation-config vllm, repetition_penalty=1.0, max_model_len=16384, gpu_memory_utilization=0.85). Across all 76 benchmark runs (58,368 requests covering calibration, main sweep, and three diagnostic hunts), there were 0 errors, 0 KV-cache preemptions, 0 Hugging Face generation_config overrides, and 0 mid-run Triton JIT compilations (prompt_logprobs kernels for k ∈ {0, 1, 5} were warmed before prefix-cache reset and timing).

1. The mechanism and the telemetry blind spot

Three implementation details in vllm==0.34.0 combine to create both the slowdown and the monitoring gap:

  1. Prefix-cache read bypass: When a request sets prompt_logprobs, Request.get_prefix_cache_hit_limit() returns 0, causing KVCacheManager.get_computed_blocks() to bypass prefix-cache reads and recompute full-prompt prefill for that turn.
  2. Telemetry exclusion: KVCacheManager.record_prefix_cache_stats() skips requests where prefix_cache_lookup_enabled(request) is False. Bypassed turns are excluded from both vllm:prefix_cache_queries and vllm:prefix_cache_hits.
  3. Nonstreaming constraint: vllm/entrypoints/openai/completion/protocol.py rejects prompt_logprobs > 0 when stream=True, so audited turns (and their matched controls) must hit the nonstreaming /v1/completions endpoint.

That led to a pre-registered hypothesis before running the sweep:

  • Hypothesis: At 75% of measured baseline capacity, auditing 5% of turns raises p95 TTFT for a separate, unscored streaming cohort by at least 20%, while the reported prefix-cache hit ratio moves by less than 3 percentage points.

2. Experimental design and isolation

To avoid confounding cache effects with ramp-up artifacts or client-side JSON bottlenecks, the benchmark isolates the workload along three axes:

  • Stationary multi-turn workload: 24 seeded, 32-turn sessions (768 total turns per run) with staggered starting turn depths and pre-primed rollover histories. That keeps the aggregate prompt-length distribution stationary from start to finish (4,224 to 8,192 prompt tokens, exact 6,208.0 mean prompt tokens per quarter), with fixed output_tokens=64, ignore_eos=True, and temperature=0.0.
  • OS-process cohort isolation:
    • Sessions 0–15 (512 turns): The unscored streaming measurement cohort (stream=True, never audited in any condition), executed in its own isolated OS process synchronized via CLOCK_MONOTONIC. Nonstreaming logprob downloads and JSON parsing cannot stall streaming timers or SSE reads; streaming client dispatch lag remained tight (dlag_p95 = 1.9–2.7 ms in steady state and 2.45 ms even at k=5).
    • Sessions 16–23 (256 turns): The nonstreaming audit/control pool (stream=False across all conditions, with JSON parsing deferred strictly post-run). Audited turns form nested subsets (1% ⊂ 5% ⊂ 10%) within each replicate (audit_seed = 9000 + arrival_seed), paired against exact nonstreaming controls at 0% and a 5% cache-miss-only control (token 0 mutated, prompt_logprobs unset).
  • Arrivals and baseline calibration: Stationary round-robin turn-shuffled Poisson arrivals across three arrival seeds (101, 202, 303) with boundary separation so consecutive turns of the same session never collide. Sweeping 0% auditing across 4–40 req/s under an SLO of p95 TTFT ≤ 500 ms measured baseline capacity at 24.0 req/s (p95 = 161.1 ms at 24 req/s, transitioning into overload at 28 req/s), fixing the 75% target load at 18.0 req/s.

For every run, the harness records client-side TTFT, E2E, TPOT ((t_end - t_first) / (completion_tokens - 1)), TTFB, body transfer time, dispatch lag, and response payload bytes alongside server-side Prometheus /metrics deltas before and after replay (vllm:prefix_cache_hits / vllm:prefix_cache_queries, vllm:request_prefill_kv_computed_tokens_sum, vllm:prompt_tokens_by_source{source="computed"}, vllm:num_preemptions, and fine-grained latency histograms).

3. Main sweep: 5% auditing vs. the other 95%

Audit spillover money chart: audited turn fraction versus unscored streaming cohort p95 TTFT in vLLM v0.34.0 at 75% load (18.0 req/s), showing flat 97.9% reported prefix-cache hit rate as GPU prefill work and tail latency surge.

Unscored streaming cohort p95 TTFT (log scale, mean ± SD across 3 seeds) at 18.0 req/s. Reported prefix-cache hit rate stays pinned at 97.9% even as 10% auditing pushes the server into queueing collapse.

Audit % Unscored p50 TTFT Unscored p95 TTFT (mean ± SD) vs. 0% Baseline Reported Hit % True Effective Hit % Newly Computed Prefill Achieved RPS Regime
0% 62.2 ms 95.4 ± 8.9 ms +0.0% 97.94% 97.94% 98,304 tok (1.0×) 17.84 steady
1% 64.5 ms 266.2 ± 28.3 ms +179.1% 97.94% 96.97% 144,555 tok (1.5×) 17.76 steady
5% 138.8 ms 594.4 ± 71.6 ms +523.3% 97.94% 93.10% 329,131 tok (3.3×) 17.40 steady
10% 5,221.4 ms 15,033.0 ± 3,005.6 ms +15,664.4% 97.94% 88.08% 568,192 tok (5.8×) 12.42 UNSTABLE

The hypothesis is strongly confirmed:

  • At 5% auditing, unscored streaming p95 TTFT jumps from 95.4 ms to 594.4 ± 71.6 ms (+523.3%, 6.2×) in steady state, newly computed prefill tokens rise 3.3× (98,304 → 329,131 tokens), and the reported cache hit rate moves by 0.00 percentage points (97.94% → 97.94%).
  • Even 1% auditing (8 turns out of 768) nearly triples unscored p95 TTFT (+179.1%).
  • At 10% auditing, the server enters queueing collapse (achieved_rps = 12.42 < 0.90 × 18.0, p95 TTFT 15,033.0 ms), yet Prometheus continues to report 97.94%.

4. Hunt 1: Late turns hurt more than many early turns

Because session starting depths are staggered uniformly across time, we can test whether spillover scales simply with total newly computed prefill tokens or with the size of individual prefill spikes.

Hunt 1 bar chart comparing unscored cohort p95 TTFT for baseline, 24 or 36 early-turn audits, and 5 or 10 late-turn audits at 75% load.

Unscored cohort p95 TTFT across baseline (92 ms, 98K new prefill tokens), early_24 (322 ms, 206K), early_36 (360 ms, 260K), late_5 (244 ms, 136K), and late_10 (423 ms, 176K) at 75% load.

Auditing just 10 late turns (1.3% of all turns, 176K newly computed prefill tokens) raises unscored p95 TTFT to 423.4 ± 22.9 ms (+358.5%). That is worse than auditing 36 early turns (4.7% of turns, 260K new prefill tokens, 360.4 ± 24.8 ms / +290.3%) or 24 early turns (206K new prefill tokens, 321.8 ± 22.2 ms / +248.5%), and even 5 late turns (136K new tokens) pushes p95 TTFT to 244 ms.

Tail latency here is governed by bursty per-request prefill spikes rather than aggregate prefill token count alone: a handful of deep 8K-token recomputations create longer head-of-line stalls for co-scheduled streaming turns than three times as many 4K-token early recomputations.

5. Hunt 2: Separating cache bypass, logprobs compute, and API-server serialization

A prompt_logprobs request does three distinct things: it bypasses prefix-cache reads, computes lm_head + log_softmax over the full prompt, and serializes a large JSON payload (0.48 MB at k=0, 0.87 MB at k=1, 2.44 MB at k=5 per audited turn) inside the vLLM API server. Hunt 2 isolates those components at 75% load (18.0 req/s):

Hunt 2 grouped bar chart with per-seed dots comparing client unscored p95 TTFT, server Prometheus p95 TTFT, and server p95 queue time across baseline, 5% cache-miss control, and 5% prompt_logprobs at k=0, k=1, and k=5.

3-seed medians (bars) and individual seeds (dots) comparing isolated client unscored p95 TTFT against server Prometheus p95 TTFT and queue time.

Condition Payload / Audited Turn Reported Hit % Client Unscored p95 (median) Server Prometheus p95 (median)
baseline_0pct 0.00 MB 97.94% 90.5 ms ~70 ms
cache_miss_5pct 0.00 MB 93.01% 461.8 ms ~467 ms
audit5pct_k0 0.48 MB 97.94% 536.9 ms 483.4 ms
audit5pct_k1 0.87 MB 97.94% 635.1 ms 487.7 ms
audit5pct_k5 2.44 MB 97.94% 1,468.8 ms 901.7 ms

Three findings stand out across the 3-seed medians (90.5 → 461.8 → 536.9 → 635.1 → 1,468.8 ms):

  1. Prefix-cache bypass drives most of the k=0/k=1 spillover, and Prometheus sees it when prompt_logprobs is off. Mutating token 0 on 5% of turns without prompt_logprobs (cache_miss_5pct) raises median unscored p95 TTFT to 461.8 ms (per-seed: 333.6, 461.8, 2,339.3 ms; mean 1,044.9 ms), while Prometheus accurately reports the hit-rate drop (97.94% → 93.01%). On seed s202 (2,339.3 ms client / 2,726 ms server), decode concurrency briefly spiraled (Running: 19 → 82 → 153 → 228 reqs) right on the 18 req/s stability cliff, compounded by token-0 mutation orphaning the next non-audited turn's 128-token prefix block (+4,096 to +4,480 extra prefill tokens, or +1.25%–1.36% over audit5pct).
  2. audit5pct_k0 and audit5pct_k1 closely track server Prometheus p95, while telemetry goes blind. Client medians of 536.9 ms (mean 582.0 ± 151.8 ms) and 635.1 ms (mean 602.5 ± 73.3 ms) align with server Prometheus p95 medians (483.4 ms and 487.7 ms), while reported cache hit stays stuck at 97.94%.
  3. At k=5, API-server JSON serialization adds a major event-loop stall. With 2.44 MB per audited response, client unscored p95 surges to 1,468.8 ms median (1,297.6 ± 395.6 ms mean, client p50 389.6 ms) versus 901.7 ms median (886.0 ms mean) on server Prometheus, a +567 ms median (+412 ms mean) vLLM API-server serialization / event-loop gap cleanly separated from client parsing (dlag_p95 = 2.45 ms). Because Prometheus histograms aggregate all 768 requests (including the 38 slow audited turns), whereas client unscored p95 measures only the 512 streaming turns, that +567 ms gap is a conservative lower bound on API-server serialization overhead.

6. Hunt 3: Spillover across the load curve

Does this spillover only appear near saturation? Running 0% vs. 5% auditing across 35%, 50%, 75%, and 90% of measured baseline capacity (24.0 req/s) shows that even lightly loaded replicas suffer severe tail degradation:

Hunt 3 line chart comparing 0% baseline and 5% prompt_logprobs auditing unscored cohort p95 TTFT across 35%, 50%, 75%, and 90% of measured baseline capacity (24.0 req/s).

Unscored cohort p95 TTFT for 0% vs. 5% auditing across 35% to 90% of measured baseline capacity (24.0 req/s).

Load (% of 24.0 req/s) Target RPS 0% Audit p95 TTFT 5% Audit p95 TTFT Delta
35% 8.4 req/s 68.0 ms 356.9 ms +425.0%
50% 12.0 req/s 73.5 ms 438.7 ms +496.8%
75% 18.0 req/s 92.5 ms 605.7 ms +554.7%
90% 21.6 req/s 155.6 ms 7,189.2 ms +4,521.6% (all 3 seeds unstable)

Even at 35% load (8.4 req/s), auditing 5% of turns pushes unscored p95 TTFT up +425.0% (68.0 → 356.9 ms). At 90% load, all three replicates collapse.

7. Scope, limitations, and operational takeaways

  • High-reuse multi-turn geometry (4,096 + 128 tokens, 97.94% baseline hit rate): Spillover amplification scales with the ratio of cached prefix to newly appended tokens (~48:1 here, representative of long-context coding and tool-use agents). Short single-turn prompts or low-reuse workloads will show a proportionally smaller prefill multiplier.
  • Model-to-GPU headroom and vocabulary size (Qwen2.5-3B-Instruct on A100-80GB): This pairing left ample KV headroom (~22% active KV utilization, 0 evictions/preemptions), isolating compute, queueing, and serialization contention. Tighter memory ratios (such as 70B models at high concurrency) may additionally trigger KV eviction or preemption cascades. Conversely, Qwen2.5's 151,936-token vocabulary makes full-prompt lm_head + log_softmax heavier relative to a 3B backbone than on models with smaller vocabularies.
  • Unpinned chunked-prefill budget: start_server.sh uses vLLM v0.34.0's default --max-num-batched-tokens; tuning chunk budgets trades off per-request prefill latency against inter-token smoothness and tail spillover.
  • Practical mitigations:
    1. Isolate pools: Route prompt_logprobs auditing or offline scoring to dedicated shadow/batch replicas rather than sharing pools with latency-sensitive streaming traffic.
    2. Minimize k if inline scoring is unavoidable: Returning k=5 top logprobs per prompt token inflates nonstreaming payloads to 2.44 MB and introduces hundreds of milliseconds of API-server serialization delay.
    3. Watch computed-prefill counters, not just hit ratio: Alert on vllm:request_prefill_kv_computed_tokens_sum and vllm:prompt_tokens_by_source{source="computed"} alongside vllm:prefix_cache_hits / vllm:prefix_cache_queries.

8. Reproducing the benchmark

On a Linux host with 1× NVIDIA A100-SXM4-80GB (or comparable GPU) and a Python 3.12 virtual environment with vllm==0.34.0, httpx, numpy, and matplotlib:

bash
git clone https://github.com/bajajku/vllm-prompt-logprobs-spillover.git
cd vllm-prompt-logprobs-spillover
git checkout aa521295e4c2d7bbfa565d6e498e6e54fe5cb9ee

# Terminal 1: start vLLM v0.34.0 with prefix caching & custom buckets
GPU_ID=0 PORT=8025 ./start_server.sh

# Terminal 2: run calibration, main 4x3 sweep, 3 hunts, and plot generation
./run_experiment.sh

Individual stages can also be invoked directly via benchmark.py calibrate, benchmark.py sweep, benchmark.py hunts, and plot_results.py.

← All writingAnonymous feedbackBack to top ↑