Validating ISL/OSL distributions with the mock server
Validating ISL/OSL distributions with the mock server
The in-repo mock server records the token length of every request it receives.
Use this to verify that aiperf is generating prompts at the ISL and OSL you
configured — and to compare distributions against other benchmarking tools such
as vllm bench serve or sglang bench_serving.
The histograms below show what a correctly-matched comparison looks like — aiperf and vLLM Docker producing identical ISL distributions for the same seed and parameters. Blue = aiperf, red = vLLM Docker; overlapping bars appear purple.
An interactive version with additional tokenizer comparisons is available in isl-distribution-examples.html.
Quick start
When the benchmark finishes the mock server writes two files:
Recording JSONL schema
Each line is a self-contained record:
isl is the template-inclusive input token count — the full tokenized
representation the server receives, including any chat template markup. For
PromptCorpus.RANDOM without --apply-chat-template the isl value matches
the configured --prompt-input-tokens-mean target directly.
tokenization_mode indicates how ISL was measured:
Inspecting the distribution
Comparing two recordings
The tools/compare_recordings.py utility produces a self-contained HTML
report from any two JSONL recording files:
What the report contains
- Stat cards for ISL and OSL — mean, std, p5/p95, min/max, and delta between the two runs
- Overlapping histograms for ISL and OSL (2-token bins, blue/red transparent bars so overlapping regions are visually distinct)
- Tokenization-mode breakdown table — count and percentage for each
tokenization_modevalue per run - Vocabulary top-N diff table — the token IDs with the largest count
difference between runs (loaded automatically from the companion
.summary.jsonfiles if present)
CLI reference
The .summary.json companion file is detected automatically at
<recording>.summary.json — no extra flag needed.
Validating against vLLM Docker
Run both tools against separate mock server instances in parallel, then compare the recordings:
Capturing raw prompts
To capture the exact prompt text sent by a benchmark client — useful for
diagnosing content differences between tools — use tools/capture_server.py.
It records every request’s messages array byte-for-byte without tokenizing
and returns a minimal synthetic streaming response so the client does not
error out.
Then point your benchmark client at http://localhost:18000. Each line in the
output JSONL contains:
CLI reference
Diffing captured prompts
After capturing from two tools with the same seed, compare content at the Python level:
Note that with --max-concurrency > 1 requests arrive at the capture server
out of order. Sort by content (not by the sequential "i" field) before
comparing, or use --max-concurrency 1 to force serial delivery.
Notes on template-inclusive ISL
The mock server applies the tokenizer’s chat template before measuring ISL when a native template is available. This means the recorded ISL includes template overhead (role markers, system prompt, generation prompt suffix) on top of the prompt content. For a model like Llama 3.1 8B Instruct the template adds approximately 35 tokens per request.
Clients that send message content as a multimodal list
[{"type":"text","text":"..."}] rather than a plain string — including
vllm bench serve --backend openai-chat — are handled transparently: the
mock server normalises list content via _content_to_text before passing
to apply_chat_template, so ISL measurement is consistent regardless of
how the client formats the content field.