Skip to content

bench: add prefix cache aware benchmark - #45

Merged
apinge merged 1 commit into
apinge:qwen38-flash-next-amd-current-fix-installfrom
sammysun0711:add_prefix_aware_benchmark
Oct 15, 2026
Merged

apinge merged 1 commit into
apinge:qwen38-flash-next-amd-current-fix-installfrom
sammysun0711:add_prefix_aware_benchmark

Conversation

@sammysun0711

Copy link
Copy Markdown
Collaborator

Motivation

This PR aim to port minimal function from upstream sgl-project#37359 to measures inference performance under controlled prefix-cache hit rates.

Modifications

  • Add controlled prefix-cache benchmark help function, reusing the generated-shared-prefix dataset.
  • Prewarm each unique prefix after model warmup and cache flushing, before measured traffic; exclude priming requests from latency and throughput metrics.
  • Add ./run_pure_text_bench_prefix_cache_hit.sh and update Qwen3.8 server launch script accordingly

Usage example:

  1. Launch a SGLang server with radix cache enable with cache report:
DISABLE_RADIX_CACHE=0 TP_SIZE=2 ./launch_qwen38_flash_next_fp8_mi308x_pure_tp_4_or_8_or_2.sh
  1. Run one controlled 12K-input, 350-output, 55%-hit point at concurrency 8:
MAX_CONCURRENCY=8 CACHE_HIT_PERCENT=55 ./run_pure_text_bench_prefix_cache_hit.sh 

Accuracy Tests

Not applicable

Speed Tests and Profiling

12K-input, 350-output, 55%-hit point at concurrency 8 on MI308X PTL TP2:

============ Serving Benchmark Result ============
Backend:                                 sglang    
Traffic request rate:                    inf       
Max request concurrency:                 8         
Successful requests:                     128       
Benchmark duration (s):                  112.28    
Total input tokens:                      1647143   
Total input text tokens:                 1647143   
Total generated tokens:                  44800     
Total generated tokens (retokenized):    40216     
Request throughput (req/s):              1.14      
Input token throughput (tok/s):          14670.35  
Output token throughput (tok/s):         399.01    
Peak output token throughput (tok/s):    712.00    
Peak concurrent requests:                16        
Total token throughput (tok/s):          15069.37  
Concurrency:                             8.00      
----------------End-to-End Latency----------------
Mean E2E Latency (ms):                   7012.98   
Median E2E Latency (ms):                 7001.46   
P90 E2E Latency (ms):                    7051.73   
P95 E2E Latency (ms):                    7091.37   
P99 E2E Latency (ms):                    7094.28   
---------------Time to First Token----------------
Mean TTFT (ms):                          2917.73   
Median TTFT (ms):                        3014.33   
P90 TTFT (ms):                           3039.01   
P95 TTFT (ms):                           3043.08   
P99 TTFT (ms):                           3054.64   
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms):                          11.73     
Median TPOT (ms):                        11.43     
P90 TPOT (ms):                           12.47     
P95 TPOT (ms):                           12.57     
P99 TPOT (ms):                           17.43     
---------------Inter-Token Latency----------------
Mean ITL (ms):                           11.77     
Median ITL (ms):                         11.39     
P90 ITL (ms):                            11.52     
P95 ITL (ms):                            11.64     
P99 ITL (ms):                            14.07     
Max ITL (ms):                            2374.97   
----------------Cache Hit Details-----------------
Total prompt tokens:                     1647143   
Total cached tokens:                     901120    
  Device:                                901120    
  Host:                                  0         
Cache hit rate:                          54.7%
  Device:                                100.0%
  Host:                                  0.0%
==================================================

Checklist

Review and Merge Process

  1. Ping Merge Oncalls to start the process. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • Common commands include /tag-and-rerun-ci, /tag-run-ci-label, /rerun-failed-ci
  4. After green CI and required approvals, ask Merge Oncalls or people with Write permission to merge the PR.

@sammysun0711
sammysun0711 requested review from apinge and a balanced review from Copilot October 13, 2026 10:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Request-count handling, hit-rate validation, input validation, and automated coverage remain unresolved.

4 open findings
What changed in this PR

Adds controlled prefix-cache benchmarking through prefix priming and cache-hit reporting.

Changes:

  • Adds prefix metadata and prewarming support.
  • Adds benchmark and server-launch scripts.
  • Records expected and observed cache-hit statistics.
File Description
scripts/​run_pure_text_bench_prefix_cache_hit.sh Runs a configurable prefix-cache benchmark.
scripts/​launch_qwen38_flash_next_fp8_mi308x_pure_tp_4_or_8_or_2.sh Configures radix caching and reporting.
python/​sglang/​benchmark/​serving.py Implements prefix priming and reporting.
python/​sglang/​benchmark/​datasets/​generated_shared_prefix.py Generates cache-prefix metadata.
python/​sglang/​benchmark/​datasets/​common.py Extends dataset rows with prefix fields.

🧠 Review effort: Balanced


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread python/sglang/benchmark/serving.py Resolved
Comment thread python/sglang/benchmark/serving.py Resolved
@apinge
apinge merged commit 1df949d into apinge:qwen38-flash-next-amd-current-fix-install Oct 15, 2026
78 of 88 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants