> ## Documentation Index
> Fetch the complete documentation index at: https://docs.m-star.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Evaluation and benchmarks

> Measure a served model's latency, throughput and output quality with repeatable runs and reports.

`python -m benchmark.eval` measures a served model's latency, throughput and output quality from the same requests. Each results file records the commit, hardware, versions, load and judge settings, so another run can be compared on the same terms. The client can drive M\*, vLLM-Omni and SGLang-Omni. Two more pages cover [comparing a change with its base](https://docs.m-star.org/evaluation/compare.md) and [Full-Duplex-Bench v1.5](https://docs.m-star.org/evaluation/full-duplex.md).

The runner lives in `benchmark/eval/` and is not installed as a package, even by an editable install, so run it from the root of a checkout ([Install from source](https://docs.m-star.org/installation.md#install-from-source)); from any other directory Python cannot find `benchmark`. Install its dependencies in the client environment:

```bash theme={null}
uv pip install --torch-backend=auto -e ".[eval]"
```

## Measure a Kokoro deployment

This example uses the bundled `benchmark/assets/t2s.txt` sentences, so it needs no dataset download. Install Kokoro's dependencies first ([Kokoro](https://docs.m-star.org/models/kokoro.md#serve)); the `eval` extra does not include them. The default round-trip WER judge loads `openai/whisper-large-v3` and runs after the timed requests.

From the repository root:

```bash theme={null}
python -m benchmark.eval run tts --serve kokoro --voice af_heart \
    --data benchmark/assets/t2s.txt --concurrency 1,4,16 --repeats 3 --out results/kokoro

python -m benchmark.eval report results/kokoro --md kokoro.md \
    --chart kokoro.png --chart-metrics ttfa_ms_p50,audio_s_per_s,wer
```

Each load point writes a results JSON file under `results/kokoro`, and the report writes `kokoro.md` and `kokoro.png`. Read request errors, judge identity and quality scores next to latency and throughput: a faster run with failed or truncated outputs is not an equivalent result.

`--serve MODEL` runs `mstar serve MODEL` with its own port, socket prefix and upload directory, waits for `GET /health`, logs to `<out>/server-<label>.log` and stops the whole process group afterwards. `--serve-python` names the serving environment's Python when the client runs in another one. `--url` measures a server that is already running, and `--serve-cmd "<command with {port}>"` launches anything else, for example another engine for a side-by-side run. `--asr-judge none` skips the WER judge; that run makes no quality claim.

## How a run is measured

A run is one suite at one or more load points. For each point the runner sends `--warmup` untimed requests at the measured concurrency, then `--repeats` passes over the items, scoring each pass on its own. A results file holds one point.

* **Closed loop** (`--mode closed`, default): `--concurrency` requests in flight at all times. `--concurrency 1,4,16` sweeps; each level writes its own file.
* **Open loop** (`--mode open --rate 1,2,4`): Poisson arrivals at each rate, seeded (`--arrival-seed`) so every system sees the same schedule. `--concurrency N` caps in-flight requests. Latency is measured from the scheduled arrival, so time spent waiting for a slot counts (`slot_wait_s`). Each request also records how late the client was against the schedule (`arrival_lateness_s`); a large `arrival_lateness_s_p99` means the client, not the server, set the pace, and the point should not be used.
* **Repeats**: every metric is one number per repeat (a p50 over that repeat's requests, a corpus WER); the summary is the mean and sample standard deviation over repeats. Three repeats is the default.

## Results and reports

Each results file (`schema: "mstar-eval/1"`) has `config` (everything that decides the numbers: data slice, load, repeats, request fields, judges), `meta` (git commit and dirty flag, GPUs, driver, Python, torch and CUDA versions, the `MSTAR_*` environment, the server's `/v1/models` identity and launch settings, the CLI command), `repeats` (per-repeat metrics and per-request rows) and `summary` (mean, std, min, max and n per metric).

The serializer redacts values under secret-looking keys and non-loopback hosts under host-like keys and scrubs home-directory names, remote URLs and non-loopback IP addresses from strings. It records a fingerprint for `--serve-cmd`, and flag names and a fingerprint for `--serve-arg`. Inspect transcripts before sharing results. Names, private text and credentials in free text can survive scrubbing.

A failed request keeps only an error category (`HTTP 503` or an exception type). The message goes to `<out>/errors-<suite>-<label>-<load>.log` next to the server log.

`report` turns any set of files into one markdown table per suite, headed by a provenance line, plus optional PNG charts of metrics against concurrency or rate. `--metrics` picks the columns.

`rescore` recomputes WER or CER from the transcripts a `tts` or `asr` results file holds, with another normalizer, and records that it did, so runs scored differently can be compared without a GPU. It refuses a file whose transcripts were redacted when written:

```bash theme={null}
python -m benchmark.eval rescore results/tts --data eval-data/fleurs_en/manifest.jsonl \
    --normalizer seedtts --out results/tts_seedtts
```

## Suites

### `tts`

Streaming `/v1/audio/speech`. Per request: time to first audio (first PCM byte after the WAV header), end-to-end latency, audio seconds, RTF, and the playback stalls a real-time player fed by the stream would hit (`--stall-prebuffer-ms`, `--stall-min-ms`). Per repeat, optionally: round-trip WER (`--asr-judge`, Whisper large-v3 by default; CER for zh, ja, ko and th), speaker similarity to each item's reference clip (`--clone` sends it as `ref_audio`; `--sim-judge`) and UTMOS (`--mos`).

`--engine vllm-omni` and `--engine sglang-omni` read those servers' raw PCM streams. `--engine nanovllm-voxcpm` posts to Nano-vLLM-VoxCPM's `/generate` in the mode M\*'s VoxCPM2 runs for the same item; send `--extra cfg_value=2.0` to match M\*'s VoxCPM2 default.

### `asr`

`/v1/audio/transcriptions`. Corpus WER (CER for character languages) against the manifest, latency percentiles, RTFx (audio seconds per wall second), and with `--stream` the time to the first transcript delta. A failed request scores as an empty transcript, so errors never lower the WER.

### `duplex`

Streamed `/generate` for frame-synchronous speech-to-speech models (`nemotron_duplex`). The output is time-aligned with the input, so latencies are measured in interaction time from a replay: response latency after the user stops, whether the agent took the turn, and on barge-in clips the stop latency and whether it yielded, plus wall time per frame and whether each session kept up with real time. `data duplex-synth` builds turn-taking and barge-in clips from a 16 kHz ASR manifest.

### `e2e`

The request kinds `compare` needs beyond speech (`--kind`): greedy chat with text, image, audio or video in and optionally speech out, seeded image and video generation, voice-clone uploads, VLA actions and streamed world-model frames. It reports latency percentiles, time to first output and requests per second, and saves the kept repeat's outputs for `compare` to diff. It builds its own prompts, so `--data` is optional, and `--media` points at the `media/` directory `data e2e` builds.

### `fdb`

[Full-Duplex-Bench](https://github.com/DanielLin94144/Full-Duplex-Bench) v1.5 on the same streamed `/generate` client: stop and response latency, LLM-judged behavior labels, semantic quality, and agreement between judges. Its data is non-commercial only; see [Full-Duplex-Bench v1.5](https://docs.m-star.org/evaluation/full-duplex.md).

## Datasets

A dataset is a JSONL manifest, one item per line, with paths relative to the manifest. A `.txt` file of sentences also works for `tts`.

```text theme={null}
{"id": "1089-134686-0000", "text": "...", "audio_path": "audio/1089-134686-0000.wav", "lang": "en"}
```

`ref_audio` and `ref_text` add a voice-clone prompt, and `extra` carries suite fields (duplex `category`, `speech_end_s`, `interrupt_s`). An `id` names the item's saved audio, so it must be a plain name (letters, digits, `.`, `_`, `-`). To evaluate ASR, build LibriSpeech and point the `asr` suite at a running ASR server ([Speech recognition](https://docs.m-star.org/asr.md)):

```bash theme={null}
python -m benchmark.eval data librispeech --out ~/eval-data/ls_clean --n 200

# in another terminal: mstar serve whisper_large_v3_turbo
python -m benchmark.eval run asr --url http://127.0.0.1:8000 \
    --model-name whisper_large_v3_turbo --data ~/eval-data/ls_clean/manifest.jsonl \
    --concurrency 1,4,16 --repeats 3 --out results/whisper
```

| `data` kind | Source | Terms |
| - | - | - |
| `librispeech` | `openslr/librispeech_asr` (`--split test.clean`) | CC BY 4.0 |
| `fleurs` | `google/fleurs` (`--lang en_us`, `cmn_hans_cn`, ...) | CC BY 4.0 |
| `seedtts` | Seed-TTS-eval test set (target text plus prompt clip, `--locale en` or `zh`), from the Hugging Face mirror `zhaochenyang20/seed-tts-eval`, else the official Google Drive archive via gdown | research use; the EN prompts come from Common Voice, whose terms forbid trying to identify speakers |
| `duplex-synth` | composed from an ASR manifest (`--from`) | the source's terms |
| `fdb-v15` | Full-Duplex-Bench v1.5 (498 pairs) from the official Google Drive via gdown (`--per-category N` takes the first N of each category) | CC BY-NC 4.0, non-commercial use only; never vendored |
| `e2e` | every input `compare` sends: Seed-TTS and LibriSpeech sets plus generated media | those of `seedtts` and `librispeech` |

Downloads go to the Hugging Face cache, so set `HF_HOME` to a large disk on GPU hosts and reuse it across runs.

[Judge inputs and agreement metrics](#quality-judges).

## Quality judges

Model-based scores depend on the judge, so every results file names it. Compare only runs scored by the same judge and normalizer.

* WER normalizers (`--normalizer`): `whisper` (default; Whisper's English normalizer for English items and items with no language, its basic normalizer for every other language), `whisper_en` (English only; a run with items in another language is refused before it starts), `seedtts` (the Seed-TTS-eval recipe: punctuation removed except the apostrophe), `whisper_basic`, `basic`. Both the corpus rate (`wer`) and the per-utterance mean (`wer_utt_mean`, what Seed-TTS-eval publishes) are kept.
* Speaker similarity uses `microsoft/wavlm-base-plus-sv` x-vectors. Seed-TTS-eval's published SIM uses a WavLM-large ECAPA checkpoint, so absolute values differ.
* UTMOS is UTMOS22 strong from `tarepan/SpeechMOS` on torch.hub.

Judges run between repeats, after the load has finished, so they never compete with measured requests. `--judge-device` moves them to another GPU or the CPU.

## Other benchmark tools

The checkout also has single-purpose clients. Like `benchmark.eval`, they are not in the wheel.

| Command | What it measures | Route |
| - | - | - |
| `python -m benchmark.runner` | Load by request type (`--request-type text_to_text`, `text_to_speech`, `image_to_text`, ...) on its dataset loaders (`--dataset`), in waves, closed loop or at a Poisson rate (`--profiling-type offline`, `closed_loop`, `online`). `--model` takes the runner's own model names; `--inference-system` also drives vLLM-Omni, SGLang-Omni and VoxServe. | `/generate` (`--inference-system ours`) or the OpenAI routes (`ours_openai`) |
| `python -m benchmark.tts_speech_bench` | Streaming TTS from a sentence file such as `benchmark/assets/t2s.txt`: time to first audio, end-to-end latency, RTF and audio seconds per second at one `--concurrency`, for `--engine mstar`, `vllm-omni` or `sglang-omni`. | `/v1/audio/speech` |
| `python -m benchmark.asr_bench` | ASR RTFx, p50 and p95 latency and WER per concurrency, plus one long file with `--long-form`, on the set `python -m benchmark.asr_data --out data/asr` builds. | `/v1/audio/transcriptions` |
| `python -m benchmark.asr_realtime_bench` | Streaming ASR: partial-result latency, end-of-utterance latency and WER, with `--sessions` concurrent sessions played at `--speed`. Serve `qwen3_asr` or `qwen3_asr_realtime`. | `/v1/realtime` |

Each prints its flags with `--help`.

## Adding a suite

Subclass `benchmark.eval.suites.base.Suite`: declare its CLI flags in `add_args`, send one request in `request` (return a row dict; keys starting with `_` stay in memory, for example decoded audio for scoring), compute one number per metric in `score`, list it in `benchmark/eval/suites/__init__.py`, and add its default table columns to `benchmark/eval/report.py`. `test/modular/test_eval_framework.py` runs every suite against a stdlib fake server on CPU; add a case there.

### Compare a change

Use the [base versus head comparison](https://docs.m-star.org/evaluation/compare.md) to run the same suite against two revisions.

### Evaluate a conversation

Use [Full-Duplex-Bench](https://docs.m-star.org/evaluation/full-duplex.md) to score interruptions, backchannels and turn-taking.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.