A benchmark harness to measure, compare and understand LLM inference systems, using customer support as a production-representative workload.
Research Plan | Performance | Getting Started | Roadmap
-
[12/04] Input Length Scaling. Doubling a prompt from 4,096 to 8,192 tokens increased median time to first token by 2.28× on M3 Pro. A separate ablation removed 11.01 ms from the 46-token prompt by processing it in one model call. Read the report
-
[12/03] Pipelining Ablation: One Line of mlx-lm Costs 14 ms per Request — Changing one line of mlx-lm removes the 14 ms end-of-generation cost on max_tokens stops (tail 14.2 → 0.3 ms) with identical outputs and no per-token cost; end-of-sequence stops are unaffected. Read the report
-
[12/03] Output Length Scaling: Where Decode Time Goes in mlx-lm — Runtime Stability's 33 ms after the first token is one decode step (18.7 ms) plus a 14 ms fixed cost from mlx-lm's one-step-ahead pipelining; decode scales at 18.9 ms per token. Read the report
-
[12/03] Runtime Stability: Single-Request Latency on Apple M3 Pro — TTFT of 128 ms with a CV of ~1 % under good conditions; cold start costs 3.7×. Read the report
This repository is not a chatbot. It is an experimental environment for inference performance: every experiment has a written protocol, raw per-request data, captured environment (hardware, OS, library versions, model revision, git commit) and a report with reproducible figures.
Customer support is the workload because it is representative of production traffic: short prompts, short to medium outputs, and strict latency expectations.
Runtime Stability — Qwen3-4B INT4 · MLX · Apple M3 Pro · concurrency 1 · 48-token prompt
| Metric | Value |
|---|---|
| TTFT p50 | 128.0 ms ± 3.9 ms (3 runs) |
| TTFT p95 / p99 (300 requests) | 146.5 / 153.1 ms |
| E2E p50 | ~160 ms |
| Cold start (1st request) | 429–497 ms (≈ 3.7×) |
| Prefill share of TTFT | > 99 % |
| Prefill share of end-to-end latency | ~79 % |
| Accuracy | 100 % |
| Peak memory | 2.54 GB |
Two of three reference runs had a TTFT coefficient of variation of 1.1–1.3%. The third had a temporary slowdown of unknown cause. After model load, one warm-up request brought TTFT down to 125–139 ms for the next request.
Figure 1: Median latency breakdown of a single classification request. TTFT is almost entirely prefill; one decode step plus end-of-sequence handling costs 33.8 ms.
Output Length Scaling — same setup, N = 1–512 generated tokens, mlx-lm vs a non-pipelined control
| Metric | Value |
|---|---|
| Decode time model (mlx-lm) | 14.0 ms + (N − 1) × 18.88 ms (R² 0.9995) |
| Per-token cost (TPOT) | 18.9 ms (~53 tokens/s) |
| Fixed end-of-generation cost | 14.0 ms with mlx-lm, 0.3 ms without pipelining |
| Pipelining break-even | ~13 tokens (decode), ~28 tokens (end to end) |
| Classification (N = 2) | mlx-lm is 28 ms slower end to end (+22 %) than the non-pipelined control |
| One-line mlx-lm patch | Tail 14.2 → 0.3 ms on max_tokens stops, TPOT unchanged (+0.06 ms) |
Figure 2: The 33 ms after the first token in Runtime Stability are one decode step (18.7 ms) plus a 14.1 ms fixed cost caused by mlx-lm's one-step-ahead pipelining, confirmed by a one-line patch (Pipelining Ablation).
Input Length Scaling with 46 to 8,192 input tokens and 32 generated tokens per request. Prefill throughput reaches about 700 tokens/s at 256 to 1,024 input tokens and falls to 546 tokens/s at 8,192. The chart compares the primary run with the replication.
Figure 3. Prompt length versus time to first token, prefill time and throughput, peak active MLX memory, and decode latency.
Experiments are organized in three levels, from understanding the engine to optimizing it. Everything runs on a single Apple Silicon machine; serving infrastructure is out of scope.
| Level | Goal | Folder |
|---|---|---|
| 1. Characterization | Understand how the inference engine behaves | level-1-characterization |
| 2. Real-World Workloads | Build workloads representative of customer support | level-2-real-world-workloads |
| 3. Inference Optimization | Get better performance without changing hardware | level-3-inference-optimization |
| Experiment | Scientific question | Status |
|---|---|---|
| Runtime Stability | Is performance stable? | Done |
| Output Length Scaling | What does decoding cost? | Done |
| Pipelining Ablation | Does a one-line mlx-lm patch remove the 14 ms fixed cost? | Done |
| Input Length Scaling | How does prefill cost grow with prompt length? | Done |
| Cold Start Profiling | Why is the first request slow? | Upcoming |
| Memory Scaling | How does memory grow? | Upcoming |
| Experiment | Scientific question | Status |
|---|---|---|
| Concurrency Scaling | How do latency and throughput change when several requests arrive at the same time? | Planned |
uv sync # install dependencies (Python 3.12)
make bench # run Runtime Stability once → experiments/level-1-characterization/runtime-stability/runs/<timestamp>/
make bench-length # run Output Length Scaling (~12 min)
make bench-ablation # run Pipelining Ablation (~3 min)
make figures # regenerate figures (SVG + PNG) and the results table
make viz # interactive exploration with marimo (open in Safari or Chrome)
make test # unit testscustomer-support-inference/
├── src/customer_support_inference/
│ ├── backends/mlx_backend.py # Instrumented MLX backend (+ sync control loop)
│ └── benchmarks/ # One runner per experiment, shared env capture
├── analysis/
│ ├── explorer.py # Interactive marimo notebook
│ ├── plot_style.py # Shared figure style
│ └── figures_*.py # Figure and table generation per experiment
├── tests/ # Unit tests (make test)
└── experiments/
├── level-1-characterization/
│ ├── runtime-stability/ # README (protocol), report, figures/, runs/
│ └── output-length-scaling/
├── level-2-real-world-workloads/
│ └── concurrency-scaling/
└── level-3-inference-optimization/
- Instrumented in-process MLX backend
- Runtime Stability: single-request latency stability
- Output Length Scaling: per-token compute vs fixed engine costs (replicated on AC power)
- Pipelining Ablation: one-line mlx-lm patch removes the 14 ms fixed cost on max_tokens stops
- Report the pipelining finding upstream to ml-explore/mlx-lm
- Input Length Scaling: prefill cost and the remaining ~11 ms of the TTFT gap
- Long-context decode: TPOT and KV cache growth from 2K to 32K tokens
- Concurrency Scaling: concurrency sweep with
mlx_lm.server+ AIPerf - System telemetry (CPU/GPU load, frequency, temperature) in run metadata
- Additional backends (llama.cpp, vLLM)
