Repository avatar
AI Tools
v1.0.0
active

gguf-fit

dev.nodebudget/gguf-fit

Zero-download GGUF VRAM/KV-cache fit calculator, hardware probe, and local LLM runtime doctor.

Documentation

gguf-fit

Zero-download GGUF v2/v3 header inspector, exact KV-cache & VRAM fit calculator, local LLM runtime doctor (Ollama, llama-server, vLLM), stdio MCP server, and GitHub Action.

Pure Python 3.10+ standard library — zero runtime dependencies, zero telemetry.

Why gguf-fit?

Running local coding and agent models fails in three predictable ways:

  1. 32k–128k context OOM surprises — a 7B/32B model fits at 4k context, then blows past VRAM once real coding-agent context kicks in.
  2. Silent Ollama truncation & CPU spill — Ollama defaults to num_ctx 2048/4096 (silently dropping prompts) or silently spills layers to host RAM (size_vram < size) with a 4–8× decode collapse.
  3. Guessing launch flags — manually calculating -ngl, -c, -ctk/-ctv, --max-model-len, and KV cache quantization across GQA, MHA, DeepSeek MLA, Gemma 2/3 SWA, and MoE models.

gguf-fit reads only the binary GGUF header via HTTP Range requests (typically 256 KiB, fast-skipping 150k+ token vocab arrays without decoding strings), aggregates multi-shard files automatically, probes your real GPU or Apple Silicon / Strix Halo unified memory, and emits exact copy-paste launch commands.

Quick Start

Run directly without installing via uvx, or install with pip:

uvx gguf-fit unsloth/Qwen2.5-Coder-7B-Instruct-GGUF --ctx 32k --kv q8_0
pip install gguf-fit

Common CLI Workflows

# Inspect all quantizations in a Hugging Face repo against an M4 Pro 48 GB
gguf-fit unsloth/Qwen3-30B-A3B-GGUF --gpu m4-pro-48g --ctx 64k --all-quants

# Inspect a local .gguf file (auto-aggregates multi-shard siblings)
gguf-fit ./DeepSeek-R1-Distill-Qwen-32B-Q4_K_M.gguf --ctx 32k --kv q8_0

# Generate paste-ready Markdown for GitHub PRs, HF Discussions, or r/LocalLLaMA
gguf-fit unsloth/Qwen2.5-Coder-7B-Instruct-GGUF --gpu rtx-4090 --ctx 64k --markdown

# Machine-readable JSON output
gguf-fit unsloth/Qwen2.5-Coder-7B-Instruct-GGUF --json

# Probe local hardware & list built-in --gpu presets
gguf-fit hardware --list-presets

gguf-fit doctor — Audit Local Runtimes (Localhost Only)

Connects strictly to 127.0.0.1 / localhost (1.5s timeout, zero external calls) to audit running Ollama, llama-server, and vLLM instances:

gguf-fit doctor

Detects:

  • Silent num_ctx truncation in Ollama (/api/ps + /api/show) and emits a copyable Modelfile + ollama create fix.
  • Silent partial CPU spill (size_vram < size) with exact GiB spilled to RAM.
  • Unquantized f16 KV cache with ready-to-run OLLAMA_FLASH_ATTENTION=1 and OLLAMA_KV_CACHE_TYPE=q8_0 commands.
  • llama-server slot-split context traps (/props + /slots) and vLLM max_model_len KV pre-allocation warnings.

MCP Server (dev.nodebudget/gguf-fit)

gguf-fit ships a pure-stdlib stdio JSON-RPC 2.0 MCP server exposing 3 lean tools (< 600 total schema tokens):

  • inspect_model_fit — zero-download GGUF/HF inspection, VRAM/KV breakdown, -ngl, tok/s, and launch flags
  • detect_local_hardware — Apple Silicon / NVIDIA / AMD ROCm Strix Halo / CPU probe
  • audit_local_llm_runtime — localhost Ollama / llama-server / vLLM runtime audit

Claude Code

claude mcp add gguf-fit -- uvx gguf-fit --mcp

Cursor / VS Code / Claude Desktop

{
  "mcpServers": {
    "gguf-fit": {
      "command": "uvx",
      "args": ["gguf-fit", "--mcp"]
    }
  }
}

GitHub Action

Validate local LLM model targets in CI and upsert a single <!-- gguf-fit-report --> PR comment:

name: Local LLM Fit Check
on: [pull_request]
permissions:
  contents: read
  pull-requests: write

jobs:
  gguf-fit:
    runs-on: ubuntu-latest
    steps:
      - uses: a895047059/gguf-fit@v1
        with:
          model: unsloth/Qwen2.5-Coder-7B-Instruct-GGUF
          gpu: rtx-4090
          ctx: "32768"
          kv: q8_0
          all-quants: "true"
          comment-pr: "true"
          fail-on-oom: "false"

Set comment-pr: "false" to write only to the GitHub Job Summary without commenting on PRs (only contents: read required).

Companion Browser Extension

Want inline FITS / TIGHT / OOM badges and 1-click launch commands directly inside Hugging Face /tree/main file tables and Ollama library pages?

  • Local LLM VRAM & GGUF Fit Checker (Chrome Web Store & Firefox Add-ons) — shares the exact same GGUF binary header parser and KV-cache math engine.
  • Source: nodebudget-chrome-extension

Architecture & Methodology

  • Binary GGUF v2/v3 parser: Incremental HTTP Range reads (256 KiB -> 1 MiB -> 2 MiB -> 4 MiB), fast-skipping tokenizer.* arrays by byte offset without decoding vocab strings, plus config.json / safetensors fallback.
  • Exact KV-cache equations: Supports MHA, GQA, DeepSeek MLA (kv_lora_rank + qk_rope_head_dim), Gemma 2/3 & Mistral Sliding Window Attention (sliding_window), and MoE active-parameter memory-bandwidth decode estimation (CUDA / Metal / ROCm / CPU).
  • Interactive web calculator & methodology: Local LLM VRAM & Mini PC Fit Checker and Local LLM vs Cloud GPU Break-Even Guide.

License

MIT

PYPI
gguf-fit
Install Command
pip install gguf-fit
Runtime: uvx