Skip to main content

lmbench

CI PyPI Python License: MIT

Measure which of your local LLMs works best on your machine. lmbench benchmarks the models installed in Ollama: speed, memory, CPU offload, how performance changes as the context window grows, and answer quality on small tasks graded by code. Then it ranks them and recommends one for what you need ("best coding model that fits in 4 GB of VRAM").

lmbench demo

Why

Leaderboard scores come from datacenter GPUs. On a laptop GPU with 4 to 8 GB of VRAM, the interesting questions are different: does this 7B model fit, how much of it spills onto the CPU, what happens to speed at 8k context, and is it actually good enough at my tasks? lmbench answers those with measurements from your own hardware.

  • Fully local and free. No cloud APIs. Quality is graded by deterministic code, not by another model.
  • Small-VRAM aware. Reports peak RAM and VRAM, how much of each model is offloaded to the CPU, and a context-size sweep that shows where speed falls off a cliff.
  • One decision. Combines speed, memory and quality into a score with profiles (coding, interactive, ...) and hard limits (--max-vram, --min-tps, ...).

Install

uv tool install lmbench-llm        # recommended
# or: pipx install lmbench-llm
# or: pip install lmbench-llm

The package is called lmbench-llm on PyPI; the command it installs is lmbench. Requires Python 3.11+ and a running Ollama (ollama serve) with at least one model pulled.

From source:

git clone https://github.com/Pravir-005/lmbench && cd lmbench
uv sync && uv run lmbench --help

Quick start

lmbench hardware                         # what lmbench detects: CPU, RAM, NVIDIA GPU + VRAM
lmbench run --quick                      # fast trial of every installed model (a few minutes each)
lmbench run -o results.json              # full benchmark, saved
lmbench recommend results.json -p coding --max-vram 4

Example result (format only; run it to get your own numbers):

Recommended (coding): <model> scores NN/100 (quality NN%, NN.N tok/s, N.N GB loaded, NN% offloaded to the CPU).
Ruled out:
  <model>: needs N.N GB to fit entirely in VRAM (limit 4 GB)

Results measured on the author's machine are in RESULTS.md.

Commands

Command What it does
lmbench hardware Show detected CPU, RAM and NVIDIA GPU
lmbench models List models installed in Ollama
lmbench speed Tokens/sec, time to first token, peak RAM/VRAM, CPU offload
lmbench context Speed and memory at different context-window sizes
lmbench quality 25 tasks in 5 suites (coding, json, reasoning, instruct, summarize)
lmbench run All of the above for every model, then a ranking
lmbench report Rank models from saved result files (terminal, Markdown, HTML)
lmbench recommend Pick the best model for your needs, with the reasons

Every option, column and term is explained in the command reference. Result files from separate commands can be combined: lmbench report speed.json quality.json context.json.

How it measures

  • Speed comes from Ollama's own timing data: tokens/sec = output tokens / generation time (median of several runs after a discarded warm-up). Time to first token is measured on the streamed response.
  • Memory. Peak RAM is the resident memory of the Ollama processes; peak VRAM is the extra GPU memory used during the run (NVML). Offload comes from Ollama's /api/ps: the share of the loaded model that is not in VRAM.
  • Context scaling. The model is reloaded at each size and given a prompt that fills about 60% of the window. Each prompt is slightly different so Ollama's prompt cache cannot flatter the result.
  • Quality. Temperature 0, fixed seed. Coding answers run against hidden unit tests; JSON is validated; reasoning needs a final Answer: line; instruction and summary tasks are rule-checked. Scores have partial credit.

Scoring

score = weighted mean of quality, speed and memory, where speed is tok/s relative to a target (--target-tps, default 30) and memory compares the loaded size to your VRAM. Models below 60% quality are scaled down so a fast model that gets most tasks wrong cannot win. Profiles change the weights:

Profile Quality Speed Memory
balanced (default) 0.50 0.30 0.20
coding 0.65 0.25 0.10
interactive 0.35 0.50 0.15
tight-memory 0.40 0.20 0.40

The weights are defaults, not truths. Adjust --target-tps and the profile until the ranking matches your judgement.

Limitations

  • Ollama only for now, and VRAM sampling is NVIDIA only (AMD and Apple Silicon report RAM only).
  • The quality suites are small (25 tasks). One task moves a suite score by 20 points, so use them to compare models, not as an absolute grade. They are also fairly easy: strong models may all score near 100%.
  • Reasoning models (deepseek-r1, qwen3) can use many tokens thinking. Answers that hit the token limit are flagged and scores marked as lower bounds; raise --num-predict if you see the warning.
  • Results are only comparable on the same machine. report warns if files come from different hardware.
  • The coding suite executes model-written code on your machine. It runs in a separate process with a 10-second time limit and a memory limit where the OS allows, but it is not network-isolated. Run it on a machine you control.

lmbench measures models you have installed. If you want to know which models could run on your hardware before you download them, see whichllm, which estimates this from your specs and published benchmark results. Other Ollama benchmarking tools exist on PyPI, for example local-inferbench and ollama-spark; lmbench's focus is the context-scaling and offload view, deterministic task grading and a recommendation with explicit memory and speed limits.

Contributing

Bug reports, new quality tasks, new backends (llama.cpp, LM Studio) and AMD/Apple memory sampling are all welcome. See CONTRIBUTING.md. Sharing a results file from your hardware is a useful contribution too.

License

MIT. See LICENSE.

Metadata

Release files for lmbench-llm 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lmbench-llm 0.1.0
File Size Uploaded Provenance Actions
lmbench_llm-0.1.0.tar.gz 31.2 kB With provenance Details for lmbench_llm-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for lmbench-llm 0.1.0
File Interpreter ABI Platform Actions
lmbench_llm-0.1.0-py3-none-any.whl Python 3 none any Details for lmbench_llm-0.1.0-py3-none-any.whl

Total release size: 69.6 kB

Release files / lmbench_llm-0.1.0.tar.gz

Download URL lmbench_llm-0.1.0.tar.gz
Size 31.2 kB
Tags Source
SHA-256 checksum
How to use checksums
810f3570ec16390db4272071b1f0e0a33759d1ff6ef901909861af6056ba7047
BLAKE2b-256 checksum
How to use checksums
6c4420564b9fbfae78ac72dd087bf8e9d6f4119da9d4c431dd29af5af490539e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.

Transparency log

Release files / lmbench_llm-0.1.0-py3-none-any.whl

Download URL lmbench_llm-0.1.0-py3-none-any.whl
Size 38.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3963d6f20601fc0544d45746185931fe8f922112b0f524d7b7e256f87cad8472
BLAKE2b-256 checksum
How to use checksums
092d98856105577afa22faa1fb7524b72fc0564dbec5b9bc6c4e1e760b13f9f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.

Transparency log

Security for lmbench-llm 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for lmbench_llm-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page