New Tool Radar

Local AI

How to Benchmark an MLX Model’s Speed with mlx_lm.benchmark

Run mlx_lm.benchmark with a prompt size and a generation size to measure time to first token and generation speed for one model on your Mac.

Schematic diagram with three steps: pick the Qwen 3.8 model from Apple's example, run mlx_lm.benchmark with a prompt and generation size, then read time to first token and tokens per second.

Two models can both “run on your Mac” and feel very different: one answers quickly, the other keeps you waiting. Guessing from parameter counts does not settle it, because quantization, context size, and your machine all change the result. mlx_lm.benchmark measures it directly — prompt processing speed, generation speed, and time to first token — for one model on your own machine.

Run the benchmark

Apple’s own ML research team uses mlx_lm.benchmark for its MLX performance posts, and gives this exact command for Qwen 3.8 with 8,192 tokens of context and 128 generated tokens:

mlx_lm.benchmark --model Qwen/Qwen3.8-27B -p 8192 -g 128 -b 1

The flags are the size of the job: -p is the prompt in tokens, -g is how many tokens to generate, and -b is the batch size. A smaller job runs faster and is fine for a first check — the same post’s method works with any values, for example -p 256 -g 128 for a short chat-style run.

Read the three numbers

The post says its evaluation “measures three metrics across a range of context sizes: time to first token (TTFT, in seconds), generation throughput (in tokens/second), and peak power usage (in watts)”, and that decode speed was measured over 128 generated tokens. Compare runs only on the same machine: a number from another Mac, or from a different prompt size, is not comparable.

Check What you should see If you do not see it
Prompt -p matches the context size you care about (8192 for long documents, 256 for short chats) A benchmark at one size says nothing about another — rerun it
Generation -g sets how many tokens are generated (128 in Apple’s example) Generation speed is measured over the tokens you generate
Compare Two runs on the same Mac, same flags, different models or quants Numbers from another machine are not comparable — rerun on yours

Expected result. We checked Apple’s ML research post for the benchmark command and the three metrics it reports. We did not run mlx_lm.benchmark.

Limits

The command and metrics come from Apple’s post, which measured large models on Mac Studio hardware — the Qwen 3.8 example needs far more memory than a small laptop model, so pick a model that fits your own Mac. mlx-lm is an Apple silicon package; install it with pip install mlx-lm per its README. The post’s own numbers describe its machines, not yours, and no benchmark was run for this guide. We did not run mlx_lm.benchmark, so no figure here is a recorded result.

Sources

See all