Skip to content

Benchmark client

This page explains how snap-asr-bench runs a benchmark, what each timing covers, and what it assumes. The reasons behind the larger choices are in Design decisions.

Scope

The client replays each input as a live caption stream: one audio or video file, or every clip in a manifest. It cuts the audio into chunks and sends each chunk as a streamed POST /v1/audio/transcriptions request to vLLM. It measures per-request and per-stream latency. With --concurrency, it runs several such streams at once (Concurrent load), each with one request in flight. The warm-up also runs streams in parallel, but isn't measured. It doesn't yet search for capacity or report cost per stream (Limitations 5). With reference transcripts it also scores each stream's word error rate.

Components

Component Runs on Role
snap-asr-bench (src/snap_asr_bench/) Each inference host (in a container), or the bench host Stages input, plans and sends chunks, collects telemetry, writes the JSONL
vLLM (deploy/nvidia, deploy/trn2) Each inference host, as vllm.service Serves Qwen3-ASR on port 8000
Log sidecar (sidecar/asr_log_sidecar.py) Each inference host, as asr-log-sidecar.service Streams the vLLM journal and accelerator telemetry on port 8001
run-on-hosts.sh (deploy/client/) Your workstation Starts the same run on every inference host over SSM

Code map

Module Responsibility
cli.py Arguments, host fingerprint (run_start), preparing the inputs, overall flow, S3 upload
plan.py Reading and checking benchmark plans, and resolving each job's options
manifest.py Reading, filtering and sampling manifest CSVs
source.py Staging local or S3 inputs, with an ETag cache for S3 and a size and mtime cache for local files
reference.py Reference transcripts: text files, Ego4D AV JSON and generic segment JSON
wer.py Text normalization and word error counts
score.py snap-asr-bench-score: WER tables from one or more runs' JSONL
media.py ffprobe, audio extraction, slicing, silence search, per-chunk encoding
chunking.py Chunk planning for each strategy and boundary mode
runner.py Targets, the warm-up, the sweep, pacing and per-stream summaries
transcribe.py One request: upload, SSE parsing, timing
telemetry.py /metrics scraping and sidecar streams
network.py Network baseline probes
events.py The JSONL event log

Run lifecycle

sequenceDiagram
    participant C as Client
    participant V as vLLM
    participant S as Sidecar
    C->>C: run_start, read the manifest (if any)
    loop each input
        C->>C: stage, ffprobe, extract 16 kHz PCM to disk, load the reference
    end
    loop each target, in file order (all at once with --parallel-targets)
        C->>V: /health, /version, /v1/models
        C->>S: /health
        C->>V: network baseline (start)
        par background collectors
            C->>V: /metrics every --metrics-interval
            C->>S: /journal and /command/* streams
        and the warm-up (with --warmup-seconds)
            C->>V: warm-up input, every configuration, parallel afap streams
        and then the jobs, in plan order
            loop each job and each input
                loop each stream configuration and concurrency level
                    C->>C: plan and encode every chunk of every speaker
                    par each speaker
                        loop each chunk
                            C->>V: POST /v1/audio/transcriptions (SSE)
                        end
                    end
                    C->>C: score speaker 0's transcript (with a reference)
                end
            end
        end
        C->>V: network baseline (end)
    end
    C->>C: run_end, upload events.jsonl
Hold "Alt" / "Option" to enable pan & zoom
  1. Fingerprint. run_start records the arguments, options, targets and host: OS, Python, package, ffmpeg and ffprobe versions, TCP settings, EC2 identity, client image ID and the work directory's mount. The client warns if the work directory is on the root volume.
  2. Stage. Every input, and the warm-up input if given, is staged the same way, before any target is contacted. A local input is copied to <work-dir>/inputs/_local/<absolute path>, so clips with the same file name stay apart, and copied again only when its size or modification time changes. An S3 input is downloaded to <work-dir>/inputs/<bucket>/<key>, and reused on later runs while its ETag and size are unchanged. The warm-up input is staged under inputs/warmup/, an S3 manifest under inputs/manifests/ and S3 reference files under inputs/references/. Local manifests and references are read in place.
  3. Extract. ffprobe output is logged in full. ffmpeg decodes the first audio stream to headerless 16 kHz mono 16-bit PCM in <run dir>/audio/<n>.s16le, numbered 0000 onwards in manifest order (a skipped clip leaves a gap), and the warm-up input to <run dir>/warmup.s16le. Each clip is read into memory when its turn comes, so only one is held at a time. The reference transcript, if any, is loaded too, and input_ready records the clip's hash, length, manifest row and reference.
  4. Per target. The client logs /health, /version and /v1/models, and uses the target's model, or else the first model listed. It runs the network baseline, starts the collectors, runs the warm-up if one is set, runs each job's sweep over every input, waits 2 s for trailing telemetry, stops the collectors and runs the baseline again.
  5. Finish. run_end is written and the JSONL is uploaded to --results-s3, even if the run failed part-way.

Inputs and manifests

A run measures either one input or the clips of a --manifest: a CSV with one row per clip, local or on S3. Manifests of Ego4D and Ego-Exo4D clips, with uid, s3_uri, media_path and transcript_path columns, work as they are.

Column Required Default names, first found wins Meaning
Clip ID yes clip_id, uid, id, name (--id-column) Bound to every stream as input_id. Must be unique.
Media yes uri, s3_uri, media_path, path (--uri-column) Local path or s3:// URI. Without --uri-column each row uses its first non-empty one, so an Ego4D row uses its S3 copy and an Ego-Exo4D row its media_path.
Reference no reference, reference_path, transcript_path (--reference-column) Path or s3:// URI of the clip's reference transcript.
Inline reference no reference_text The reference itself, for short manual transcripts. Wins over the reference column.

Examples are in resources/examples/manifests/ (Validate accuracy). Every other column is passed through: input_ready.row holds the whole row, and snap-asr-bench-score --by can group by any column, such as duration_bucket, activity or dataset.

  • Paths. Relative paths are resolved against the manifest's own directory or S3 prefix. --rewrite FROM=TO replaces a path prefix first, for example --rewrite /data/datasets/=s3://<bucket>/datasets/ so a manifest written on one machine works on the inference hosts.
  • Selection. --where COLUMN=VALUE[,VALUE...] keeps matching rows (repeatable; all must match), --require-reference keeps rows with a reference, --sample N --seed S keeps a seeded random sample in manifest order, and --limit N keeps the first N left. They apply in that order. manifest_loaded records the manifest's hash, the selection and the chosen clip IDs.
  • Failures. A clip that can't be staged, probed or decoded is skipped with an input_error, and listed in run_end.skipped_inputs. The run carries on, but exits non-zero. A reference that can't be loaded is logged as reference_error, and the clip is measured without a score. With a single input either failure stops the run.

The sweep

A run has one or more jobs. Without --plan the flags make one job; a benchmark plan can hold several. Jobs run one after another, in plan order. In a job, every input, and every combination of these options for it, is one load of concurrency streams, run in this nesting order (outermost first):

job × input × strategy × boundary × audio-format × pacing × chunk-seconds × concurrency × repeat

The input is outermost, so every configuration on one clip runs close together in time, and server drift over a long run mostly lands between clips rather than between configurations. Repeats are innermost, so repeat 0 of each configuration runs right before repeat 1. Targets run one after another, or all at once with --parallel-targets (design decision 3), and each one runs every job. On-host runs give each host one target, so the hosts run in parallel.

Warm-up

A server's first requests with a new chunk length can be much slower than later ones (Limitations). With --warmup-seconds above 0, each target warms up before its sweep:

  • Own audio. It sends --warmup-input, never the measured input. It refuses an identical file, or one shorter than the longest --chunk-seconds.
  • Every configuration. The warm-up input is cut with every combination of strategy, boundary, format and chunk length in every job's sweep, at afap pacing. A configuration whose stream raises isn't tried again. Each warm-up stream runs on its own, from the start of the clip (concurrency 1, speaker 0, no load_id), whatever --concurrency is.
  • Parallel streams. --warmup-concurrency streams (default 4) run at once, so every DP rank gets traffic.
  • Minimum time. Streams keep starting until --warmup-seconds have passed and every configuration has started once.
  • Coverage. warmup_end records the requests each vLLM engine served, from vllm:request_success_total on /metrics, and lists any that served none.
  • Labels. Warm-up events carry phase: "warmup" and sweep events phase: "measure". Use only phase == "measure" for results. Warm-up prints a start and an end line (plus a warning for unreached engines), not a line per stream.

What's still open is in Limitations.

Benchmark plans

--plan reads a run's options from one TOML file, modelled on fio job files, so a benchmark can be named, reviewed and versioned instead of living in shell history. resources/examples/plans/platform-comparison.toml is a full example:

[run]                       # set once per target, before the first job
targets = "targets.toml"
warmup-seconds = 120
warmup-input = "s3://<bucket>/warmup/warmup.wav"

[defaults]                  # every job starts from these
manifest = "s3://<bucket>/manifests/clips.csv"
strategy = "independent"
audio-format = "wav"

[[job]]
name = "chunk-sweep"
pacing = "afap"
chunk-seconds = [1, 2, 4]
audio-format = ["wav", "opus"]
repeats = 3

[[job]]
name = "live-2s"
pacing = "realtime"
chunk-seconds = 2
boundary = ["fixed", "silence"]
repeats = 5
  • Keys are flags. Every key is a CLI flag without its leading --. A list stands for a comma-separated value (chunk-seconds = [1, 2, 4]) or a repeated flag (where = ["duration_bucket=0-30s", "activity=Cooking"]). A single value is a list of one. Switches such as carry-prompt take true or false, and the positional input is input.
  • Run and job options. [run] holds what is set up once per target: targets, work directory, results, run ID, telemetry, network baseline and warm-up. [defaults] and each [[job]] hold the job options: the inputs (input and reference, or manifest with its columns, rewrite and selection), the sweep lists, repeats, max-window-seconds, boundary-search-seconds, bitrate, language, carry-prompt, temperature and request-timeout (full list). A run option in a job, or a job option in [run], is an error.
  • Inputs per job. A manifest in [defaults] is measured by every job; a job with its own manifest measures that one instead, with the selection it inherits or sets. A job that ends up with both an input and a manifest, or with manifest options and an input, is an error. Every job's clips are staged and decoded before the first target, and a clip in several jobs once, so a clip ID must name the same clip and reference in every manifest of the run. Jobs with the same input options share one manifest_loaded, whose jobs names them. If any job is left with no clip, the run stops before the first target.
  • Precedence. Built-in default, then [defaults], then the job, then the command line. A flag on the command line applies to every job, so --repeats 1 turns a plan into a quick check and --only g4dn picks one target. Relative paths resolve against the current directory, as they do for flags, not against the plan's directory.
  • Jobs. Each job needs a unique name and is one sweep, exactly as the flags make it (The sweep). After the warm-up, the jobs run in plan order, one at a time, and each runs on each of its inputs before the next starts. Concurrency happens inside a job (concurrency), never between jobs.
  • Targets per job. only in [defaults] or a [[job]] names the targets the job runs on (a name, or a list of names). Without it, a job runs on every target of the run. only in [run], or --only, picks the run's targets, and a job's own only then narrows them: --only never replaces a job's list. A job that none of the run's targets runs is left out, its clips unstaged. A target that no job runs, or a name the targets file doesn't have, is an error. On an on-host run, each host runs just the jobs that name its target.
  • Warm-up. One warm-up per target covers the configurations of every job that target runs. A configuration that two jobs share warms up once, with the first job's settings.
  • Checked first. Unknown sections or keys, misplaced keys, a list for a single-valued option and invalid values exit with status 2 before anything is staged or sent. --dry-run also loads the targets file, then prints each job's inputs, resolved settings and its loads and streams per input, and exits. It doesn't read the manifest or the media, so it can't tell how long the run will take.
  • Recorded. run_start.plan holds the plan's path and SHA-256, and run_start.options.jobs every job's resolved settings. Every load, stream and chunk event carries job.
  • Without --plan, the flags make one job, job is null, and the run is the same as before plans existed.

make bench PLAN=... and run-on-hosts.sh --plan ... take a plan too (Make targets, Through SSM). What's still open is in Limitations.

Accuracy (WER)

When an input has a reference transcript, the transcript of speaker 0 of each measured load is scored against it, and stream_end.word_errors records the reference and hypothesis word counts, substitutions, deletions, insertions and wer (errors over reference words). The stream's summary line adds WER x%. Warm-up streams aren't scored, and neither are speakers 1 and up: they start part-way into the clip (Concurrent load), so their transcripts don't line up with the reference. A load's WER therefore rests on one stream, whatever its concurrency.

References are read as:

Format Detected by Reference text
Plain text Not .json The whole file, for example a manual transcription
Ego4D AV JSON with videos (av_train.json, av_val.json) The transcription of every utterance of the clip whose clip_uid is the clip ID, ordered by start_time_sec. A whole-video row is refused, since only its 5-minute AV clips are transcribed.
Segments Any other JSON A list of segments (top level, or under segments, transcriptions, utterances, results or transcripts), each with a transcription, text, transcript, utterance or sentence, ordered by start_time_sec, start_time, start_sec, start or begin, or by position without one. Also a list of strings, a single object with a text key, or an object of segments keyed by ID when every segment has a start time. Segments with error: true are dropped.

An unrecognised JSON shape is a reference_error naming its top-level keys. A file named by many rows, such as Ego4D's av_train.json, is parsed once per run.

Normalization (wer.py, recorded as normalizer): NFKC, lowercase, annotation tags ([laughs], <unk>, #unintelligible) dropped, punctuation and hyphens turned into spaces, apostrophes kept only inside words. Numbers aren't spelled out, so 5 and five differ.

Scoring a run. snap-asr-bench-score events.jsonl [...] scores every measured stream again from the recorded transcripts and references, so older runs pick up a newer normalizer. It prints pooled WER (total errors over total reference words) and the mean per-stream WER per group, by default per target, configuration and concurrency level. It skips streams past speaker 0, as the run does. --by takes any stream field or manifest column, --csv writes the table and --streams-csv one row per stream. See Validate accuracy.

Concurrent load

--concurrency 1,4,16 runs each configuration with 1, then 4, then 16 simulated speakers at once. Each speaker is a stream of its own, with its own stream_id and speaker index (0 to N−1). All of a load's events carry the same load_id. --concurrency 1, the default, is the single-stream run.

Distinct audio. Every speaker replays the current input clip from a different point, and wraps round to the start. A load never mixes clips: with a manifest, each clip gets its own loads. Speaker i starts about i/N of the way through the clip, then is moved to its own offset within a chunk, so no two speakers send the same bytes. Every speaker still sends the whole clip, so all streams run for the same time and the load stays at N until the end. The offset is logged as stream_start.audio_offset_seconds. Only speaker 0's transcript lines up with the clip. The others start mid-clip and have a seam where it wraps, so only speaker 0 is scored.

Staggered starts. Speaker i starts i/N of a chunk after speaker 0 (stream_start.start_delay_seconds), so requests are spread across each chunk period, not sent in lockstep. Each stream's behind_realtime_seconds is measured from its own start.

Before sending. Every speaker's chunks are planned and encoded before any stream starts, so encoding takes no CPU from the load. Memory grows with N and with the clip's length: each speaker holds its encoded clip, about 32 KB per second of audio for wav independent, more for growing. A 10-minute manifest clip at --concurrency 64 holds about 1.2 GB.

Per stream, one request in flight. Each stream is still closed-loop (Pacing). N streams put at most N requests in flight. Open-loop sending, where a speaker sends on schedule even if its last answer hasn't come back, isn't implemented yet.

Client processes. One asyncio loop is one Python process on one core, and a single loop limits a load to a few dozen streams. So a load's streams are dealt out in turn to --client-processes worker processes (snap_asr_bench.loadworker), each with its own asyncio loop and its own httpx client with no connection pool cap. Threads wouldn't do: Python runs one thread's code at a time. The default, auto, is one process per CPU of the host running the load, and a load never uses more processes than streams, so a single stream runs in the main process as before. Each worker plans and encodes its own speakers, then all streams start together, so encoding still takes no CPU from the load. The workers' events go through the main process into the run's one events.jsonl, numbered as they arrive.

Client limits. load_end reports how many processes the load used (client_processes), the busiest one's CPU seconds per wall second (client_process_cpu_max_fraction), and the worst event loop's lag (how late a 100 ms timer fires) as loop_lag_p99_seconds and loop_lag_max_seconds. A busiest process near 1, or lag that grows with N, means the client, not the server, is the bottleneck. Check them, and host_cpu_busy_fraction when the harness shares a host with vLLM, before you read a level's results.

Steady-state throughput. load_end.rtfx divides the load's audio by its whole wall time, from the first stream's start to the last stream's end, so it includes the ramp-up and the tail where the slowest streams finish. At high concurrency it reads well below the rate the server sustains. To find where a target saturates, read the steady-state rate in the middle of each level instead: response_complete events, or audio seconds, per second while all N streams are running. The analysis scripts report it as steady_* throughput (Metrics and rules).

Chunk planning

Chunks are planned in whole samples, so boundaries don't drift. Each chunk has an audio window (start, end) and a ready time: when a live stream would have heard all the audio up to that request.

Strategy decides what audio each request carries:

independent
Back-to-back chunks, each sent once. The stream transcript is the chunk texts joined with spaces.
growing
Each request re-sends everything heard so far, capped to the last --max-window-seconds. The transcript is revised every chunk, and the stream transcript is the last successful response's text. Past the window, that text only covers the final window.

Boundary decides where each cut falls:

fixed
A cut every --chunk-seconds.
silence
Requests keep the same cadence, but each cut moves back to the quietest 10 ms frame (energy smoothed over 30 ms, ties to the latest) in the last --boundary-search-seconds of available audio. Audio after the cut is held back for the next chunk. Cuts never move forward, so no future audio is needed. The held-back time is extra latency, logged as held_back_seconds.

With growing, the boundary only changes where each window ends.

Short tail. Qwen3-ASR rejects audio shorter than about 20 ms. A final remainder under 100 ms is added to the previous chunk, so with fixed boundaries the last chunk can run up to 100 ms over --chunk-seconds. With silence, any chunk can be up to --boundary-search-seconds longer, from audio held back by the previous cut.

Encoding

Before a load's first request, each stream's chunks are encoded in parallel threads. Each encode is logged as chunk_encoded with its size and time, so encoding never shifts the request schedule and its cost can be added back in analysis.

Format Sent as Notes
wav chunk.wav, audio/wav 16-bit PCM, 32 KB/s. Built in process.
flac chunk.flac, audio/flac Lossless, about 60 to 70% of WAV for speech.
aac chunk.aac (ADTS), audio/aac Lossy, at --bitrate. About 0.1 s of padding per chunk.
opus chunk.ogg (Ogg), audio/ogg Lossy, at --bitrate. Smallest.
mp3 chunk.mp3, audio/mpeg Lossy, at --bitrate. About 0.09 s of padding per chunk.

AAC and MP3 padding is silence the model hears, and it can change the words at the cut. Prefer wav or flac for cross-platform comparisons.

Pacing

realtime
Each request waits until its ready time, measured from the start of the stream. If a response takes longer than a chunk, the next request goes late, and behind_realtime_seconds records by how much. This is closed-loop: a request never goes before the previous response finishes.
afap
Each request goes as soon as the previous response finishes. behind_realtime_seconds is negative while the server keeps ahead of real time.

The request

Each chunk is a multipart POST with the audio as file and these fields:

Field Value
model The target's model
response_format json
temperature --temperature (default 0.0)
stream, stream_include_usage, stream_continuous_usage_stats true
language --language (default en). Omitted with auto.
prompt With --carry-prompt and independent only: the last successful chunk's text

No output token limit is sent, so each server applies its own, which follows its --max-model-len.

The client logs every SSE line as it arrives and reads each response to the end of its body, so the HTTP connection is reused for the next chunk. If the server ignores stream=true and answers with plain JSON, that's handled too. There are no retries.

What the timings mean

Request timings are offsets in seconds from just before the request was sent, from time.perf_counter on the client host. They include hashing the payload and writing the request_sent line, which is well under a millisecond for normal chunks.

Measure Event and field From → to
Time to headers response_headers.seconds Request start → response status line
Time to first token response_complete.ttft_seconds Request start → first SSE delta with text
Inter-token gaps Successive sse_event.seconds Within one chunk
Request time response_complete.seconds Request start → end of the response body
Lateness chunk_start.behind_realtime_seconds ready time → actual send
Held-back audio chunk_start.held_back_seconds Cut → ready (silence boundaries only)
Stream speed stream_end.rtfx Audio seconds / stream wall seconds
Load throughput load_end.rtfx Audio seconds across every stream in the load / load wall seconds, ramp-up and tail included (steady state)

For a caption reader, a chunk's latency from when its audio was available is held_back_seconds + behind_realtime_seconds + response_complete.seconds. The client logs all three parts but doesn't compute the sum.

Under realtime pacing a stream lasts about as long as its audio, so rtfx is at most about 1 whatever the hardware. It is not a throughput figure.

Network baseline

Before a target's first stream and after its last, with no inference involved, the client measures tcp_connect (handshakes to ports 8000 and 8001), http_get (kept-alive round trips to vLLM /health and sidecar /ping) and upload (each --network-payload-kib size to sidecar /sink). The sidecar shares vLLM's host and network interface, so its upload times stand in for audio uploads.

Separately, every transcription request logs a request_trace with httpcore's connection phases, which shows whether it opened a new connection.

Clocks

ts and mono_ns come from the host the client runs on. Journal and telemetry timestamps inside server_log come from the inference host. On on-host runs they're the same machine.

Failure handling

Failure Effect
A chunk returns non-200 or the request raises Logged as response_error or request_exception, counted in stream_end.failures. The stream carries on.
/metrics scrape or sidecar stream fails Logged. Sidecar streams reconnect every second, and journal streams resume from the last cursor.
Network baseline fails network_error. The target still runs.
A warm-up request fails or a warm-up stream raises Counted in warmup_end, plus warmup_error for a stream that raised. The target is still measured.
/v1/models or sidecar /health fails, or anything else raises in a target target_error, and the client moves on to the next target.
Staging, probing or extraction fails for a manifest clip input_error. The clip is skipped and listed in run_end.skipped_inputs, and the exit code is non-zero.
A manifest clip's reference can't be loaded reference_error. The clip is measured but not scored.
The manifest can't be read or is invalid (a missing column, an empty ID or media cell, duplicate IDs, a bad --where or --rewrite), the filters leave no row, every clip is skipped, or a single input fails to stage, decode or load its --reference run_error, and the client exits with a traceback.
The warm-up input fails to stage or decode, is the same file as a measured input, or is shorter than the longest --chunk-seconds run_error, after the clips are prepared and before any target is contacted.
Ctrl-C (SIGINT), or SIGTERM (systemctl stop, docker stop) The run stops as it is: in-flight requests are cancelled and each load's worker processes are killed. run_end closes the log with stopped_by set and failed_targets ["run"], and the exit code is 128 plus the signal's number (130 or 143). Only the first SIGTERM counts. A worker killed part-way through a record leaves no partial line.

The exit code is 0 if every target completed and no input was skipped, and non-zero otherwise. Failed chunks don't change it.

In the container run-local.sh starts, stopping its systemd unit, or Ctrl-C when it runs in a terminal, stops that container: docker stop sends the client SIGTERM, then SIGKILL after 30 s, and every process in the container ends with it. It stops only the container it started.

Assumptions

  • The input is any file ffmpeg can read that has at least one audio stream. Only the first audio stream is used.
  • One clip's decoded audio (115 MB per hour) and each stream's encoded chunks fit in memory, along with the WER alignment of a transcript with its reference (about 80 MB for 30 minutes of speech). Every clip's source media and decoded audio fit on the work directory's disk.
  • Each target is a vLLM OpenAI-compatible server serving one ASR model, with /health, /version, /v1/models, /metrics and streamed /v1/audio/transcriptions.
  • The sidecar is optional. Without sidecar_url there is no journal, telemetry or upload baseline for that target. Journal lines below --log-level (by default, vLLM's per-request lines) are skipped as they arrive, and the resume cursor still moves past them. The telemetry commands are never filtered.
  • Host CPU, TCP settings and mount details come from /proc. Off Linux, CPU and mount are null and TCP settings are empty. EC2 identity comes from IMDSv2, and is null off EC2.
  • S3 access uses the default AWS credential chain (the instance role on EC2).
  • The work directory is on fast local storage. On EC2 that's the instance store at /mnt/nvme, which is wiped on stop and start.