specbench
Benchmark speculative decoding in llama.cpp across draft lengths and task domains, push results to Hugging Face Hub, and plot dashboards to find the fastest setup for your hardware.
https://github.com/user-attachments/assets/771ae1b8-5b28-4af5-a71e-c80f75fcf209
What It Measures
For every (model, speculator, capability, draft_n_max) run:
- Acceptance rate — pooled and per-sample token acceptance straight from
llama-servertimings. - Real speedup — decode/prefill throughput (
tok/s), latency, andspeedup_vs_baselinevs.draft_n_max = 0. - Memory overhead — peak GPU VRAM and extra memory added by the drafter (works on discrete NVIDIA GPUs and unified-memory systems like DGX Spark).
- Effective draft length & quant metadata — tracks requested vs. clamped
effective_draft_n_max(e.g., DFlash block size) plus target and drafter quantizations.
Installation
Requires llama.cpp (llama serve or llama-server on PATH) and Python 3.11+.
# Install from PyPI (provides the `specbench` CLI)
pip install specbench-cli
# Or install globally with uv
uv tool install specbench-cli
# Or run without installing
uvx --from specbench-cli specbench --help
# Needed for gated models or pushing results to Hugging Face Hub
hf auth login
Install from source (for development)
git clone https://github.com/merveenoyan/specbench.git
cd specbench
uv sync
uv run specbench --help
Quick Start
Single HF repo (auto-discovered drafter: DFlash, MTP, EAGLE-3, DSpark)
Modern llama.cpp automatically picks up dflash-*, mtp-*, eagle3-*, and dspark-* sidecar GGUFs from the same repo based on --spec-type:
# 1) Benchmark Q4_K_M with its matched Q4_K_M DFlash drafter
specbench run \
-m meta-models/Muse-Glimmer-30B-GGUF:Q4_K_M \
--spec-type draft-dflash \
--suite coding,multimodal,knowledge_work \
--ctx-size 32768 \
--max-tokens 2048 \
--hf-dataset merve/drafter-bench
# 2) Benchmark Q4_K_XL reusing the same Q4_K_M DFlash drafter from the repo
specbench run \
-m meta-models/Muse-Glimmer-30B-GGUF:Q4_K_XL \
--spec-type draft-dflash \
--suite coding,multimodal,knowledge_work \
--ctx-size 32768 \
--max-tokens 2048 \
--hf-dataset merve/drafter-bench
Tips: Pass
--no-mmprojto skip loading the vision encoder for text-only suites,--speculator-file <file.gguf>to pin a specific drafter, or--dry-runto save locally underresults/without pushing to the Hub.
Separate target & drafter repos
specbench run \
-m unsloth/Qwen3-32B-GGUF:Q4_K_M \
-s unsloth/Qwen3-0.6B-GGUF:Q8_0 \
--spec-type draft-simple \
--suite coding,multimodal \
--hf-dataset <your-username/drafter-bench>
YAML config
specbench run --config config.example.yaml
Prompt Suites
Select built-in suites with --suite (comma-separated or repeated; defaults to 20 samples via --limit 20):
| Flag | Dataset | Focus |
|---|---|---|
coding |
ArtificialAnalysis/SWE-Atlas-QnA-AA |
Software engineering Q&A (Go/Python/C/TS) |
multimodal |
MMMU/MMMU_Pro |
Image + question reasoning |
knowledge_work |
ArtificialAnalysis/AA-Briefcase-Lite |
Long-context commercial due diligence |
coding=preset:livecodebench |
livecodebench/code_generation_lite |
Competitive coding (v6) |
coding=preset:smoke-coding |
Bundled offline smoke suite | Fast offline check (preset:smoke-multimodal also included) |
Bring your own dataset
Point --suite at any Hugging Face dataset or local .jsonl/.json file. Splits (test → validation → train), prompt/image columns, and messages/conversations turn lists are auto-detected, and llama-server applies the model's own GGUF chat template:
# Zero-config HF dataset
specbench run -m <repo:quant> --suite math=hf:org/my-math-prompts
# Optional overrides for multi-config datasets or custom columns
specbench run -m <repo:quant> \
--suite math="hf:openai/gsm8k?config=main&split=test&prompt_column=question"
# Local JSONL (supports optional "images": ["relative/path.png"])
specbench run -m <repo:quant> --suite coding=./my_prompts.jsonl
Preview any suite before launching a server:
specbench inspect-suite preset:coding --capability coding --limit 5
Draft Token Sweeps
By default, specbench sweeps --draft-tokens default = [0, 4, 8, 12] (including 0 computes baseline speedup and memory delta automatically).
--draft-tokens spec-only→[4, 8, 12]--draft-tokens fine→[0, 1, 2, 4, 8, 12, 16]--draft-tokens 0,2,6,10,15→ custom list
How llama.cpp block-size clamping is handled
Some speculators cap the maximum draft length internally:
- DFlash (
draft-dflash) clamps todflash.block_size - 1(e.g.,block_size=16caps at15). - Chained multi-head MTP (
draft-mtp) clamps ton_mtp_layers. ngram-cacheis fixed at8tokens.- Standalone draft (
draft-simple) & EAGLE-3 (draft-eagle3) accept arbitrary lengths.
When llama.cpp clamps a value, specbench logs a warning and records both draft_n_max (requested) and effective_draft_n_max (actual).
Plotting Results
Generate the 2×2 dashboard (dashboard.png) plus standalone charts from a HF Hub dataset or local results/<run_id> folder:
specbench plot merve/drafter-bench --output-dir ./charts
specbench plot merve/drafter-bench --model Muse-Glimmer --theme light --format svg
Cloud GPUs via Hugging Face Jobs
No local GPU (or want to compare L40S, A100, H200)? specbench hf-job runs the same benchmark on Hugging Face Jobs using ghcr.io/ggml-org/llama.cpp:server-cuda and pushes results straight to your dataset:
specbench hf-job \
--flavor l40sx1 \
--timeout 2h \
--detach \
-m meta-models/Muse-Glimmer-30B-GGUF:Q4_K_M \
--spec-type draft-dflash \
--suite coding,multimodal,knowledge_work \
--limit 15 \
--ctx-size 32768 \
--hf-dataset <your-username/drafter-bench>
Check hardware flavors with hf jobs hardware, preview commands with --print-command, and monitor runs with hf jobs ps / hf jobs logs <job_id> --follow.
Dataset Output
Runs write local Parquet + JSON checkpoints to results/<run_id>/ and append to two HF dataset configs (summary and samples):
from datasets import load_dataset
summary = load_dataset("merve/drafter-bench", "summary", split="train")
samples = load_dataset("merve/drafter-bench", "samples", split="train")
Full schema columns
summary(one row per run, capability, anddraft_n_max):run_id,timestamp_utc,backend,llama_version,hardware,model_repo,model_file,model_quant,is_quantized,speculator_repo,speculator_file,speculator_quant,speculator_is_quantized,speculator_mode,spec_type,draft_n_max,effective_draft_n_max,capability,source_datasets,samples_total,samples_ok,samples_failed,total_prompt_tokens,total_predicted_tokens,total_draft_n,total_draft_n_accepted,acceptance_rate,mean_sample_acceptance_rate,avg_prompt_per_second,avg_predicted_per_second,avg_latency_s,speedup_vs_baseline,gpu_memory_peak_mib,speculator_extra_gpu_memory_mib,max_tokens,temperature.samples(one row per prompt):draft_n,draft_n_accepted,acceptance_rate,prompt_tokens,predicted_tokens,prompt_per_second,predicted_per_second,latency_s,finish_reason,ok,error, plus model/speculator/quant metadata.
Custom llama-server & Tests
Point to a custom llama-server binary with --llama-cmd /path/to/llama-server, list presets with specbench list-presets, and run tests with:
uv run pytest -v
Metadata
Release files for specbench-cli 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| specbench_cli-0.1.0.tar.gz | 69.9 kB | With provenance | Details for specbench_cli-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| specbench_cli-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for specbench_cli-0.1.0-py3-none-any.whl |
Total release size: 136.2 kB
Release files / specbench_cli-0.1.0.tar.gz
| Download URL | specbench_cli-0.1.0.tar.gz |
|---|---|
| Size | 69.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
39db45380367be8da6ed0ec1a44c01631dcea8da7fcda63665545cc34a784aa8
|
|
BLAKE2b-256 checksum How to use checksums |
57b691d84dc88db1f2db75d172579e389fb72a28dad0ad13fddef6b21eb6fa91
|
| 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 1, 2026.
Transparency logRelease files / specbench_cli-0.1.0-py3-none-any.whl
| Download URL | specbench_cli-0.1.0-py3-none-any.whl |
|---|---|
| Size | 66.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a3ad2a65f0e37c1ba5a9dc1f96e9da0de1fddf284925c6bba4612dc305cfd0d8
|
|
BLAKE2b-256 checksum How to use checksums |
6e11401b6e0952e9088c46b328306f81ab2da1d435adeda19b5dfcf3a86b9bb8
|
| 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 1, 2026.
Transparency logSecurity for specbench-cli 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.
Attestation for specbench_cli-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 1, 2026.
Transparency logA 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.