MadWeightsOpen weights research. The Raw Uncut.
TUTORIAL ·

Benchmark a local model so the numbers hold up

You produce a speed figure, an accuracy figure and an agent figure for a model on your own server, each with a range and a record of how it was taken. Use it whether you run llama.cpp, Strata, vLLM or any other server with an OpenAI-style API, on any hardware. Use the method more carefully than the tool. Most bad local benchmarks are not wrong because of the arithmetic. They are wrong because something else was happening during the run.

Requirements: Any inference server with an OpenAI-style API (llama.cpp's llama-server, Strata, vLLM or similar) · current llama.cpp build for llama-bench · Python 3 and the MMLU-Pro repository · Docker and Harbor for the agent test

Requirements

  • A running inference server and the exact model file you want to measure
  • A way to read the server's own counters or logs; for llama-server, start it with --metrics
  • Python 3 for the MMLU-Pro script
  • Docker and Harbor for the agent test, ideally on a separate machine or virtual machine
  • A text file for the run record, started before the first command

Steps

1. Separate prompt reading from generation

A server does two different jobs: it reads the prompt, then it generates the reply. They have different limits and can differ by a factor of ten or more (our comparison). One blended "tokens per second" hides both. For a kernel-level figure, llama-bench reports the two as separate rows:

llama-bench -m <models-dir>/model.gguf -p 512 -n 128 -r 5 -o json

-p sets prompt tokens, -n generated tokens, -r repetitions and -o the output format. All layers go to the GPU by default; add -ngl 0 and -t with your core count for a CPU-only run. Add -d 8192 to measure at a filled context instead of an empty one, which is closer to what an agent sees.

Through a server, take the server's own timings for each request rather than your stopwatch. In llama-server's response timings, prompt_n counts the prompt tokens actually processed and cache_n the tokens reused from cache, so a "fast read" with a large cache_n is a cache hit.

2. State warm or cold, and one request or several

Say which you measured. A cold read starts with nothing cached. A warm read reuses a cached prefix, which is what an agent sees on most turns. Load time is separate again; report it on its own.

Measure one request alone and then several at once, and report them apart. A total across four requests is not a per-user speed (our comparison shows both).

3. Check that nothing else used the server

Read the server's request counters before and after each measurement. If the difference is larger than what your own run sent, another client was there, and the figure is void. With llama-server started with --metrics:

curl -s http://<server-address>:<port>/metrics | grep -E 'llamacpp:(prompt_tokens_total|tokens_predicted_total|requests_processing)'

requests_processing should be zero before you start. For other servers, use their status or metrics endpoint the same way. Also check for open connections on the server port before you start. If you cannot make the machine quiet, mark the figure as taken on a shared machine.

4. Repeat, interleave, and report a range

One run is an anecdote. Identical runs can differ by several percent (why). So:

  • Run each configuration several times, in rounds.
  • Interleave the configurations, so slow periods hit both equally.
  • Run the baseline first and last. If the two baselines differ, that spread is your noise floor, and smaller differences are not evidence.
  • Report the median and the lowest and highest values, never the best run.

5. Measure accuracy on a fixed public test

Speed settings can change answers, so measure accuracy too, on a test others can run. MMLU-Pro's own script can query any OpenAI-style server. The form from the MMLU-Pro README:

python evaluate_from_apiX.py --url "http://<server-address>:<port>/v1" -m "<model-name>" -n 4 -o "eval_results/" \
  --retry 2 --max_tokens 16000 --retry_wrong 0

-n is the number of requests at once; match it to your server's slots. The README says to add your API key to the script before running. Set --retry_wrong to zero: retrying wrong answers inflates the score. The full set is about 12,000 questions and can take days on a local server (our run), so plan for it.

Report the score with a 95% interval, which covers the choice of questions, not run-to-run variation. Afterwards check the results: one result per question ID, no duplicates, and no empty or unparsed answers. The repository's compute_accuracy.py re-scores a results directory.

6. Run an agentic test

Multiple choice says little about agent work. For that, use Terminal-Bench through the Harbor harness, with the agent on a separate virtual machine. The documented form:

harbor run -d terminal-bench/terminal-bench@<version> -a terminus-2 -m <provider>/<model-name> -n 1 -k 3

-n sets concurrent trials and -k attempts per task; -i with a glob pattern limits the run to some tasks. Pass your server's address and sampling settings to the agent with --ak; harbor run --help and Harbor's agent pages list what each agent accepts. Keep each task's official time limit, fix the task order before the first run, and run several passes, because one pass at a nonzero temperature is noisy (our test). Count timeouts and harness failures separately from wrong answers.

7. Write down what someone needs to repeat it

  • Model file name, quant and size, and where it came from
  • Engine name, version and commit, and every non-default setting
  • Hardware, RAM, power limits, and what else ran on the machine
  • Sampling settings, context size, request slots, reasoning effort
  • The test's version or commit, any change to its script, and the command
  • Number of runs, the order, and what you discarded and why
  • The raw per-request or per-question results, kept with the write-up

Check it worked

For speed, the counters after a run should rise by exactly what your run sent, and the first and last baselines should agree within your stated range. For llama-bench, the output has separate prompt (pp) and generation (tg) rows with a mean and a spread, as the llama-bench README shows. For the accuracy run, the count of results should equal the number of questions, and re-scoring with compute_accuracy.py should land within a question or two of the script's own total. For the agent test, every task should have a result in each pass, with timeouts and errors recorded as such.

Common problems

  • A setting looks faster, but only in one run: rerun the baseline last. A quiet spell on the disk or the network can look like a gain.
  • Tokens per second swings by 10% or more between identical runs: look for disk stalls or other traffic, and judge by a measure the noise cannot touch, such as tokens per decode step for draft settings.
  • Agent runs end early with a context error: the conversation outgrew the server's window. Give the agent a fixed input limit so every model gets the same room.
  • Many agent timeouts: report them. They can be most of the gap between two models.
  • llama-bench repeats each test 5 times by default: set -r explicitly so your record says how many.

Our recommendation

We'd publish nothing from a single run. We'd take a median and a range for speed, a 95% interval for accuracy, and at least three passes for an agent test. We'd use the benchmark authors' script unchanged where we can, because a borrowed baseline only compares if the protocol matches. And we'd put the counter check in the runner, not in a checklist, because the run where you forget it is the one that goes into the article.

Further reading