Repository navigation
benchmark: add reproducible prefix-cache hit-rate evaluation - #37359
sammysun0711 wants to merge 12 commits into
Conversation
Signed-off-by: Xiake Sun <[email protected]>
Signed-off-by: Xiake Sun <[email protected]>
Signed-off-by: Xiake Sun <[email protected]>
Signed-off-by: Xiake Sun <[email protected]>
Signed-off-by: Xiake Sun <[email protected]>
Signed-off-by: Xiake Sun <[email protected]>
Signed-off-by: Xiake Sun <[email protected]>
Signed-off-by: Xiake Sun <[email protected]>
|
Assume all prewarmed prefixes are expected to fit in HBM, So, |
Signed-off-by: Xiake Sun <[email protected]>
Motivation
co-author with @Richardyu114 and @FionaZZ92
Prefix-hit-aware benchmarking is essential for evaluating real agent workloads, where repeated system prompts, tool schemas, and conversation context make high cache-hit rates. To accurately simulate production workload, this PR introduces a benchmark that measures inference performance under controlled prefix-cache hit rates.
sglang.bench_servingcan generate shared-prefix requests and report cached tokens, but it previously lacked a deterministic way to benchmark a requested cache-hit rate. In particular, ordinary warmup is followed by cache flushing, so measured requests can race to populate the prefix cache unless prefixes are primed in a separate phase.This PR adds a controlled lifecycle:
The implementation reuses the existing
generated-shared-prefixdataset instead of introducing another dataset API. Exact prefix metadata travels with eachDatasetRow, so the benchmark never reconstructs token prefixes from text.Non-goals
The following item are out of scope of this PR:
Modifications
cache_prefixandcache_prefix_lenmetadata toDatasetRow.--gsp-prewarm-prefixesand bounded--gsp-prewarm-concurrency.(routing_key, cache_prefix)after cache flush and before the measurement timer.prefix_cache_configandcache_report.benchmark/prefix_cache/bench_prefix_cache.py, a standalone, resumable matrix runner.manifest.json, append-onlyresults.jsonl, latest-per-tagsummary.csv, and one log per point. Restarting the command skips only valid points.Minimal usage
Start an SGLang server with cache reporting:
Run one controlled 32K-input, 512-output, 50%-hit point at concurrency 8:
Run a controlled matrix:
A single
results.jsonlentry example{ "tag": "prefix-cache-in32768-out512-hit50-c8-r1", "completed": 50, "max_concurrency": 8, "mean_ttft_ms": 4628.35, "mean_tpot_ms": 11.94, "request_throughput": 0.733, "prefix_cache_config": { "mode": "prewarmed", "num_prefixes": 2, "prewarm_requests": 2, "expected_hit_rate_pct": 50.01, "actual_hit_rate_pct": 49.90, "hit_rate_verified": true }, "cache_report": { "total_prompt_tokens": 1705959, "total_cached_tokens": 851200, "cache_hit_rate_pct": 49.90, "device_cached_tokens": 851200, "host_cached_tokens": 0 } }Accuracy Tests
This PR does not modify model forward code, kernels, sampling, scheduling, or generated token semantics. Accuracy impact is therefore not expected.
The tests cover request generation, exact prefix metadata, prefix deduplication, priming failures, uniform/Zipf validation, 0% controls, page rounding, cache-hit tolerance, latest-attempt resume behavior, and summary output.
Speed Tests and Profiling
This PR does not change inference execution speed. The results below validate that the
benchmark creates the requested cache state and captures the expected performance
signal; they are not a server optimization claim.
GLM-5.2 validation
zai-org/GLM-5.2-FP8gfx950), TP8concurrency 1/8 combinations
Server command
python3 -m sglang.launch_server \ --model-path zai-org/GLM-5.2-FP8 \ --served-model-name GLM-5.2-FP8 \ --trust-remote-code \ --reasoning-parser glm45 \ --tool-call-parser glm47 \ --tp 8 \ --dsa-prefill-backend tilelang \ --dsa-decode-backend tilelang \ --chunked-prefill-size 32768 \ --max-prefill-tokens 32768 \ --mem-fraction-static 0.80 \ --kv-cache-dtype fp8_e4m3 \ --max-running-requests 64 \ --schedule-policy lpm \ --cuda-graph-max-bs-decode 8 \ --cuda-graph-bs-decode 1 2 4 8 \ --speculative-algorithm EAGLE \ --speculative-num-steps 5 \ --speculative-eagle-topk 1 \ --speculative-num-draft-tokens 6 \ --model-loader-extra-config '{"enable_multithread_load": true}' \ --watchdog-timeout 1200 \ --enable-cache-report \ --enable-metrics \ --host 127.0.0.1 \ --port 9080Benchmark command
The validated subset contains 48 points and 2,400 measured requests.
The following tables report every validated output length and cache-hit target.
Concurrency 1
At concurrency 1, increasing cache hit from 30% to 90% reduces mean TTFT by about 78%
while TPOT remains nearly unchanged, which is the expected signal when cached prefixes
remove prefill work without changing decode work.
Concurrency 8
Checklist
Review and Merge Process
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ciCI States
Latest PR Test (Base): ❌ Run #38363166056
Latest PR Test (Extra): ❌ Run #38363165731
Latest PR Test (AMD ROCm 10): ❌ Run #38363165882