> ## 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.

# Compare a change with its base

> Check correctness, quality and performance of two revisions on the same hardware.

`compare` serves two revisions on the same GPUs and checks their outputs, quality scores and performance against the limits below. Run it from the root of a checkout with the `eval` extra installed ([Evaluation](https://docs.m-star.org/evaluation.md)). The serving environment needs each selected model's dependencies, GPUs and checkpoint access, and `cargo`, since each revision builds its own `mstar-server`; without `cargo` a model is skipped.

Start with Kokoro, using the current commit as the candidate:

```bash theme={null}
python -m benchmark.eval compare --base main --head HEAD --models kokoro
```

The run writes `report/report.md`, `report/chart.png` and `report/summary.json` under its run directory (`--out`, default `eval-results/compare/<time>-<head>`). Read request errors and correctness verdicts before a performance difference. `HEAD` is the committed revision, so commit the changes you want to compare.

List the models and cases before widening the run:

```bash theme={null}
python -m benchmark.eval compare --list
python -m benchmark.eval compare --base main --head HEAD --models tag:tts,qwen3_omni --rp
```

## Choose revisions and environments

`--head` and `--base` take a branch (fetched fresh from the remote that points at `mstar-project/mstar`, or `--remote`, then from `origin`), a pull request number (`548` or `#548`), a commit, or a local ref such as `HEAD` or a tag.

Both trees are exported from the checkout running `compare`. Each arm imports its own tree and builds its own `rust/` extension and `mstar-server`, in one Python environment; the client, the checks and the report always come from this checkout, so `main` can be measured before it had this framework. Each model uses the GPU slots its `cases.yaml` entry declares (one by default). Base and head run back to back, arm order alternating from model to model, every case at each concurrency in its `conc` with `repeats` passes after warmup waves.

`--sessions 2` runs two server sessions per arm (ABBA). Each arm's first server start gets twice the model's `startup_timeout_s`, since it may compile from cold caches; later starts get it once.

The `rust/` extension is built with the environment's `pip`, or `uv pip` when it has none. If a tree both arms share cannot be built, both run the environment's `mstar_rust` and the report says so.

Exported trees, `rust/` builds, local jobs' outputs and the inputs live in `--work-dir` (default `$XDG_CACHE_HOME/mstar-eval`, else `~/.cache/mstar-eval`); `--data-dir` moves the inputs alone.

## Run on remote hosts

With `--hosts`, idle hosts take whatever models are still queued; a host that stops answering is dropped and its model requeued. Hosts need key-based `ssh`, `rsync` at both ends, an M\* environment (`--host-python`) and the Hugging Face Hub (with a login for gated repos such as Orpheus) or a warm cache; their work directory is `--host-dir`. Machines that must be started first are a launcher's job: `--host-provider module:factory` supplies the hosts and is told when the run ends (`benchmark/eval/e2e/hosts.py`). Replace these hostnames and GPU slots with your own:

```bash theme={null}
python -m benchmark.eval compare --base main --head HEAD --models kokoro \
    --hosts bench@gpu1,bench@gpu2:1
```

## Select models and cases

The models and cases are in `benchmark/eval/e2e/cases.yaml`: TTS, voice clone, ASR, duplex, text, image, audio and video in, speech out, image and video generation, streamed frames, VLA actions, and with `--rp` request-path cases and served invariants. Speech cases use the `tts`, `asr` and `duplex` suites; the rest use the `e2e` suite (`run e2e --kind chat_image|image|video|pi05|frames|world|...`). Inputs are built once into `--data-dir` (`python -m benchmark.eval data e2e --out DIR`).

`--models` takes `all`, names, `tag:<tag>`, and `-name` or `-tag:<tag>` exclusions, comma-separated. Entries marked `optional: true` are left out of `all` and of any tag a regular entry also carries. CosyVoice3 (`cosyvoice3`), VoxCPM2 (`voxcpm2`), Omnilingual ASR (`omnilingual_asr_ctc_300m`) and LingBot-World (`lingbot_world_1_3b`) are served, but their entries are optional, so name them or select them together:

```bash theme={null}
python -m benchmark.eval compare --base main --head HEAD --models tag:new-model
```

## Multi-GPU configs

Tensor parallel, sequence parallel and disaggregated deployments (`whisper_large_tp2`, `qwen3omni_thinker_tp2`, `cosmos3_nano_sp2`, `orpheus_pd_disaggregated`, `qwen3omni_pd_disaggregated`) are optional entries with `gpus: N`: select them with `--models tag:multi-gpu`. Such a model runs on N GPU slots of one host at once (`--hosts user@gpu8:0-7`), and a host with fewer slots never takes it. The same tag selects `qwen3tts_1p7b_split`, a split config whose two ranks share GPU 0, so it needs one GPU.

Each case has a wall cap (`case_timeout_s`; 3600 s by default, 900 s on these entries), which has to sit well above the slowest normal case on the host. A case still running then has hung: its server's Python stacks are saved (`py-spy dump` when installed) to `stacks.txt`, a hung head fails the row and a hung base reports it broken. py-spy shows threads, not coroutines, so a hang at an `await` in the API server shows an idle event loop. Where ptrace is restricted, `--stacks-sudo` retries the dump with `sudo -n`; it is off by default because a refused `sudo` is logged, and often mailed, on shared clusters.

## Worker-to-worker transport

The split and disaggregated configs also run over shared memory (`_shm`), Mooncake TCP (`_tcp`) and Mooncake RDMA (`_rdma`, skipped on a host without an RDMA device): select the first two with `--models tag:w2w` and RDMA with `tag:rdma`. Besides the multi-GPU cases, `cancel` drops a stream mid-transfer and `timeout` runs on a second server whose `--timeout` is shorter than one of its requests. After every case the server is checked: its processes still alive, no M\* `/dev/shm` entry left behind, no crash or transfer-failure line in its log. A finding head has and base does not fails the row; base crashing reports it broken.

## Read the verdict

The run directory holds every results file and `report/report.md` (a table for a pull request body, details in toggles), `report/chart.png` and `report/summary.json`. `compare` exits with 1 when any row is flagged, else with 2 when any row has no verdict (its job failed or was interrupted, the model was skipped or never got a GPU, base is broken, or base answered no request at some server session and concurrency), else 0. On Ctrl-C it prints one line instead of a traceback and exits with 130; a job it could not stop stops itself within 10 minutes. A row is **flagged** when:

* **correctness changed**: greedy text is neither identical (share at least `min_match`) nor close (median similarity 0.6 or more, length ratio 0.8 to 1.25), or any head reply is base's cut below 80% of its length (empty replies included); speech WER (Whisper large-v3 round trip for TTS) rose more than `max_increase` points; a seeded image, video or frame stream fell below `min_db` PSNR against base; VLA actions moved more than `tol`; duplex take-turn or yield rates dropped more than `tol`; a request-path status code changed; head had more request errors than base; or head answered no request at a server session and concurrency where base answered some. A greedy-text failure on its limit alone (no missing, cut-short, undecodable or reshaped outputs, no extra errors) whose `quality` scores all hold reads "changed, quality same" and is not flagged. A PSNR failure stays flagged whatever its CLIP score: a seed the server stops honouring changes the pixels, not their quality.
* **quality worse**: a `quality` score of the case (`mos`: UTMOS22 of the speech; `speaker_sim`: WavLM similarity to the reference clip; `clip`: CLIP score of the image or video against its prompt; each arm scored on its own c=1 outputs after the servers stop) is below base's by more than 1.5 times the row's A/A swing, and by at least 0.1 UTMOS, 0.02 similarity or 0.5 CLIP points.
* **a regression**: c=1 latency or c=max throughput is worse by more than 5%, by more than two combined standard deviations of the passes, and by more than 1.5 times the largest drift that row showed between two server processes of identical code in its last 8 A/A runs (its A/A noise floor). When base and head return different output lengths for the same requests, latency is compared over the requests whose lengths matched, else per token or audio second.
* **head does not build** (its `rust/` extension or `mstar-server`) while base does, or **head does not start** while base does.

A perf row flagged with one session per arm is rerun with two (ABBA) before it is reported, since a server process can settle at one of two speeds; `--no-rerun` turns that off.

## Calibrate with identical-code runs

Noise floors, correctness swings and quality-score swings come from A/A runs (base and head the same commit), per GPU type, in `benchmark/eval/e2e/calibration.yaml`. After a large change on `main`, a new model, or on a new GPU type, run `compare --base main --head main` for the models concerned, then `python -m benchmark.eval calibrate <run dir>`. Rows without a floor on the run's GPU are named in the report and judged on the passes' spread alone. A calibrated swing only widens a `cases.yaml` limit, never tightens it. Rows of the A/A run that failed or had request errors stay out of the floors; `calibrate` prints how many per model.

## Run request-lifecycle stress workloads

`--stress` replaces the cases with a workload for load-dependent races, on the models whose `cases.yaml` entry has a `stress:` block (`qwen3_5_2b`):

```bash theme={null}
python -m benchmark.eval compare --base main --head HEAD --stress                  # 20 runs per arm of 60 s
python -m benchmark.eval compare --base main --head HEAD --stress --stress-runs 60 --stress-clients 32
```

Each run has `--stress-clients` clients (32), each holding one pinned `request_id` on streamed `/generate` and mixing five patterns: close at a random chunk, close before reading, close then retry at once under the same id, reuse after a full read, and a second request while the first streams (one of the pair should get a 409). A run fails on a hang (no progress for `--stress-hang-s`, 30 s), a 5xx, unexpected 4xx, empty reply or in-band error, cross-talk (a reply holding another prompt's answer), the server's own M\* tensor files left in `/dev/shm` 30 s after the run, or a server process that exits.

Every 5 runs get a fresh server, arms alternated. Head is flagged when it crashes or shows cross-talk and base never does, or when its failed-run count beats base's at one-sided Fisher exact p \< 0.05; the report states N and the smallest gap N can detect. When base fails every run, no head count can beat it, so read the per-pattern request outcomes in the report's toggle instead. `--stress-patterns` picks a subset (`barge_in,drop,retry,reuse,overlap`). The code is `benchmark/eval/e2e/stress.py`.


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