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-server timings.
- Real speedup — decode/prefill throughput (
tok/s), latency, and speedup_vs_baseline vs. 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
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-mmproj to skip loading the vision encoder for text-only suites, --speculator-file <file.gguf> to pin a specific drafter, or --dry-run to save locally under results/ 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):
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
Some speculators cap the maximum draft length internally:
- DFlash (
draft-dflash) clamps to dflash.block_size - 1 (e.g., block_size=16 caps at 15).
- Chained multi-head MTP (
draft-mtp) clamps to n_mtp_layers.
ngram-cache is fixed at 8 tokens.
- 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")
summary (one row per run, capability, and draft_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