Skip to main content

Auto-tune and benchmark llama.cpp / ik_llama.cpp inference on NVIDIA and Apple Silicon GPUs

Project description

🏎️ Dyno — llama.cpp Auto-Tuner & Benchmark

Dyno is an open-source CLI that auto-tunes and benchmarks llama.cpp / ik_llama.cpp inference on NVIDIA and Apple Silicon GPUs, producing reproducible, shareable results.

pipx install llama-dyno

dyno detect
dyno tune ~/models/mistral-7b.Q4_K_M.gguf --quick
dyno bench ~/models/mistral-7b.Q4_K_M.gguf --ngl 99 --fa
dyno report ~/models/mistral-7b.Q4_K_M.gguf
dyno submit ~/models/mistral-7b.Q4_K_M.gguf

30-Second Quickstart

# 1. Install
pipx install llama-dyno

# 2. Check your hardware
dyno detect

# 3. Auto-tune a model
dyno tune ~/Downloads/my-model.q4_k_m.gguf

# 4. Run the final benchmark
dyno bench ~/Downloads/my-model.q4_k_m.gguf --ngl 99 --fa

# 5. Generate a report
dyno report ~/Downloads/my-model.q4_k_m.gguf

Prerequisites

  • Python 3.11+
  • A GPU: NVIDIA (drivers + CUDA) or Apple Silicon (M-series, uses Metal + unified memory)
  • llama-bench binary from llama.cpp or ik_llama.cpp — built with the matching backend (CUDA or Metal)

Install llama.cpp:

brew install llama.cpp                        # macOS / Linux
# or build from source:
git clone https://github.com/ggml-org/llama.cpp
cd llama.cpp && cmake -B build && cmake --build build --config Release

ik_llama.cpp (optional, for MoE models):

git clone https://github.com/ikawrakow/ik_llama.cpp
cd ik_llama.cpp && cmake -B build && cmake --build build --config Release
# Symlink the ik binaries
ln -sf $(pwd)/build/bin/ik_llama-bench ~/.local/bin/

Commands

dyno detect

Fingerprint hardware: GPU model, VRAM, driver/CUDA version, CPU, RAM, and detect which llama.cpp backend is installed (with commit hash).

dyno tune <model.gguf>

Find the fastest config for your GPU + model.

Flag Default Description
--quick (default) ~10 trials, fast iteration
--thorough ~25 trials, best accuracy

Search strategy:

  1. Validate model loads correctly
  2. Coarse sweep — ngl (layer offload), flash attention on/off, KV cache quant (f16 / q8_0 / q4_0)
  3. Hill-climb — batch size (128–4096), threads (auto / half / full cores)
  4. ik_llama.cpp extras — -fmoe, -rtr, -amb toggles (thorough only)

OOM configs are discarded gracefully with ngl backoff. Live progress table shows every trial.

ik_llama.cpp Support

Dyno automatically detects ik_llama.cpp when ik_llama-bench is on your PATH. Extra flags tuned:

Flag Description Best for
-fmoe Fast MoE computation MoE models (Mixtral, DeepSeek)
-rtr Runtime tensor reorder Memory-bandwidth-bound scenarios
-amb Attention memory bound Large context / many KV heads

Dyno detects which flags your build supports and only searches those. MoE models get fmoe enabled by default; Dense models skip MoE flags entirely.

dyno bench <model.gguf>

Run a specific config 3× and report median tokens/sec with variance.

Flag Default Description
--ngl 99 GPU layers to offload
--fa/--no-fa true Flash attention
--ctk f16 K cache quant (f16, q8_0, q4_0)
--ctv f16 V cache quant (f16, q8_0, q4_0)
--batch 512 Batch size
--ubatch 512 Micro batch size
--threads 0 (auto) Thread count
--runs 3 Number of benchmark runs
--fmoe false Fast MoE (ik_llama.cpp)
--rtr false Runtime reorder (ik_llama.cpp)
--amb false Attention memory bound (ik_llama.cpp)

dyno report <model.gguf>

Generate a shareable report including:

  • Full hardware fingerprint
  • Model details (name, quant, SHA-256)
  • Winning config
  • Median scores with variance
  • Reproducible llama-server command
  • Shareable markdown snippet
  • JSON output

dyno submit <model.gguf>

Submit your results to the community results repo (llama-dyno-results):

  1. Opens a PR via gh CLI
  2. Falls back to a GitHub Gist
  3. Saves locally if neither works

Quality & Reproducibility

  • Fixed bench params: Every run uses pp=512 / tg=128 (fixed prompt/gen tokens) so results are comparable
  • 3-run median + variance reported
  • No fabricated numbers — real hardware detection, real subprocess results
  • OOM handling — graceful backoff of ngl
  • Clear install hints — suggests brew or git clone when binaries missing

Results Table (Example)

GPU Model Quant Backend TG tok/s
RTX 4090 Mixtral-8x7B Q4_K_M ik_llama.cpp 58.7
RTX 4090 Llama-3-70B Q4_K_M ik_llama.cpp 42.3
RTX 4090 Llama-3-70B Q4_K_M llama.cpp 35.1
RTX 3090 Mistral-7B Q4_K_M llama.cpp 112.8
RTX 4060 Phi-3-mini Q4_K_M llama.cpp 68.5

Shell Completions

Dyno supports shell completions via Typer/Click:

# Install completions for your shell
dyno --install-completion

# Show completion script (to manually install)
dyno --show-completion

Supported shells: bash, zsh, fish, powershell.

Architecture

src/llama_dyno/
├── __init__.py    # Package metadata
├── cli.py         # Typer CLI (detect, tune, bench, report, submit)
├── types.py       # Data types (BenchParams, TrialResult, etc.)
├── detect.py      # Hardware fingerprinting (pynvml, nvidia-smi, /proc)
├── bench.py       # llama-bench subprocess driver + parser
├── tune.py        # Search strategy (coarse sweep + hill climb)
├── report.py      # Report generation (JSON + markdown)
└── submit.py      # GitHub PR / Gist submission

Development

git clone https://github.com/lachy/llama-dyno
cd llama-dyno
pip install -e ".[dev]"
pytest

Out of Scope (v1)

  • GUI
  • Multi-GPU
  • AMD (ROCm) / Intel backends (planned)
  • Server hosting for results

License

Apache 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llama_dyno-1.2.0.tar.gz (41.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llama_dyno-1.2.0-py3-none-any.whl (35.5 kB view details)

Uploaded Python 3

File details

Details for the file llama_dyno-1.2.0.tar.gz.

File metadata

  • Download URL: llama_dyno-1.2.0.tar.gz
  • Upload date:
  • Size: 41.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for llama_dyno-1.2.0.tar.gz
Algorithm Hash digest
SHA256 52548dd279c54af32a5730e7c437d68fdbdefb04fe4b5e16ebe849122658620a
MD5 edbfd47e5158e2293696602f5b4a2c5a
BLAKE2b-256 366cee1b8694ef4f09eb94509e948b0bd60b783f484bad8a3d8fe08176f2bf91

See more details on using hashes here.

File details

Details for the file llama_dyno-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: llama_dyno-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 35.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for llama_dyno-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5b2626c33f6ee504470995514a2b267a01197fdb8385ca3d7a1857681f302fbd
MD5 2c81eb40ca822359d5d0283f479a3b6c
BLAKE2b-256 01258eb4290a2235e6686c3906649a040742e342c6f399eb1941f4f600206d6b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page