anvil run qwen3.6-27b.gguf --ctx 131072

FORGE
ANYTHING.

A terminal-native LLM client built on TurboQuant — the Google Research KV-cache compression algorithm behind the paper’s benchmark tables below. No cloud. No API keys. No telemetry.

$ curl -fsSL https://anvil-llm.github.io/anvil/install.sh | sh
TurboQuant
Google Research KV cache
MTP+NextN
speculative decoding
0
cloud calls
anvil — zsh — 92×28
strike-it-yourself

Don't take our word for it. Type.

A live slice of the anvil REPL, right here in your browser. Try help, /stats, /ctx, anvil list, or just say something.

anvil — interactive demo
>

try: help · /stats · /model · /ctx · /temp 0.9 · anvil list · anvil pull · or any message

why local
Your model. Your metal. Your rules.

Every API call is a lease on someone else's forge. Your prompts cross the wire, your latency rides their traffic, your context window is a line item on their pricing page.

anvil runs the whole stack on hardware you own — weights loaded straight into your GPU, KV cache compressed with TurboQuant so long contexts actually fit, tokens streaming to your terminal at native speed. It works on a plane. It works offline. It works on a $200 used GPU and on a 128GB Mac.

The model never phones home, because there's no home to phone. Just a single binary, a GGUF file, and the anvil.

temper

Numbers don't lie.

Results straight from the TurboQuant paper (Google Research, arXiv:2504.19874). TurboQuant at 3.5 bits scores identically to the full-precision cache — same LongBench average, same needle-in-a-haystack recall.

needle-in-a-haystack · recall · llama-3.1-8b · 4k→104k context · 25% KV budget
method
recall
score
kv size
verdict
Full precisionuncompressed baseline
0.997
16 GB
reference
TurboQuant4× compressed · 3.5 bits
0.997
4 GB
identical
PolarQuantgoogle companion method
0.995
4 GB
near-lossless
KIVI2-bit asymmetric
0.981
4 GB
good
PyramidKVtoken eviction
0.895
4 GB
degrades
SnapKVtoken eviction
0.858
4 GB
degrades
longbench · average score · llama-3.1-8b-instruct
method
compression
score ↑
kv size
verdict
Full cachef16 · no compression
50.06
16 GB
baseline
TurboQuant 3.5-bitthe anvil default
50.06
~3.5 GB
equal
KIVI 5-bit
50.16
5 GB
+0.10
TurboQuant 2.5-bitmax compression
49.44
~2.5 GB
-0.62
PolarQuant
49.78
3.9 GB
-0.28
KIVI 3-bit
48.50
3 GB
-1.56
Source: Zandieh, Daliri, Hadian, Mirrokni — "TurboQuant: Online Vector Quantization with Near-optimal Distortion Rate", Google Research · arXiv:2504.19874. NIAH figure = Fig. 4, LongBench = Table 1. Google's research blog reports ≥6× KV memory reduction and up to 8× speedup computing attention logits on H100.
quantize

Why TurboQuant wins.

TurboQuant is a provably near-optimal vector quantizer from Google Research — within a factor of ≈2.7 of the information-theoretic Shannon lower bound, across every bit-width. Most KV quantizers just round numbers. TurboQuant proves it can't do better.

01 · Rotate

Each KV vector is hit with a random rotation (fast Walsh–Hadamard structure). Every coordinate now follows a concentrated Beta / Gaussian distribution — outliers spread out, no coordinate dominates.

02 · Quantize

Because rotated coordinates are nearly independent, optimal Lloyd-Max scalar codebooks are precomputed per bit-width. MSE-optimal, data-oblivious, online — no calibration, no training.

03 · Unbias

MSE quantizers bias attention. TurboQuant adds a 1-bit Quantized Johnson-Lindenstrauss (QJL) pass on the residual, making inner products unbiased — the reason accuracy survives at 3.5 bits.

Data-oblivious

No calibration, no training, no per-model tuning — the codebooks are precomputed and universal.

Accelerator-native

Backend kernels for CUDA, Metal (TurboFlash), Vulkan and HIP — quantization is free at decode time.

Peer-reviewed

Google Research paper with proofs of near-optimality — the benchmark tables below are straight from it.

Benchmark your own workload

Synthetic benches only tell you so much. Run your actual prompt through anvil and watch /stats for tokens-per-second and prompt-processing time. Then iterate on KV preset and context size until the numbers stop improving.

$ anvil run qwen3.6-27b.gguf --ctx 131072 --ngl 99 --flash-attn
> /stats
tokens/sec: 127.4 · prompt tokens: 842 · total tokens: 4 891 · KV: turbo4/turbo3
strike

One swing, many strikes.

anvil supports MTP and NextN speculative decoding — a draft head proposes several tokens at once, the main model verifies them in a single pass. More tokens per step, same quality.

+4 tokens / 1 step

amber = autoregressive token · dashed = drafted · green = verified in one pass

+30–50%
short-prompt throughput · accept ~85–88%

How it works

The model's extra prediction heads guess the next few tokens cheaply. anvil feeds all of them through the main model at once — if they're right, you get them all in a single decode step.

Quality is bit-identical to normal decoding. Rejected drafts are simply discarded and re-sampled.

read-the-metal

It finds your hardware. You don't.

anvil probes your system on launch — CPU, RAM, every GPU and its VRAM — and picks a sane layer count automatically. Override with --ngl if you know better.

🟢
CUDA
NVIDIA
🔺
Vulkan
cross-vendor
Metal
Apple Silicon · TurboFlash
🔴
ROCm
AMD
🔷
SYCL
Intel
⚙️
CPU
AVX2 / NEON
Hardware: AMD Ryzen 9 7950X | x86_64 | 64 GB RAM | 32 threads
GPU: NVIDIA GeForce RTX 4090 (NVIDIA) 24564 MB VRAM [discrete]
→ offloading 99 layers to GPU
anatomy

From keystroke to token.

Every prompt travels the same road through the forge. Here's what your hardware is actually doing, ~40 times a second.

⌨️
prompt
you type at the anvil
🔤
tokenize
vocab → token IDs
🗜️
KV cache
TurboQuant rotates + quantizes K/V
🔥
GPU decode
flash attention, all layers
🎲
sample
top-k + temperature
stream
markdown → your terminal
first-light

Your first run forges the config.

No YAML to hand-edit. The first time you launch, anvil opens a full TUI setup wizard — built with FTXUI — reads your hardware, and walks you through context, KV compression, flash attention, and temperature. Every model gets its own persisted profile.

   ░███                          ░██░██
  ░██░██                            ░██
 ░██  ░██  ░████████  ░██    ░██ ░██░██
░█████████ ░██    ░██ ░██    ░██ ░██░██
░██    ░██ ░██    ░██  ░██  ░██  ░██░██
░██    ░██ ░██    ░██   ░██░██   ░██░██
░██    ░██ ░██    ░██    ░███    ░██░██
First-time setup v0.6.0
Detected hardware:
CPU : AMD Ryzen 9 7950X · RAM : 64 GB
GPU : NVIDIA RTX 4090 (24564 MB)

Context size
· 8K tokens
▸ 32K tokens
· 128K tokens
KV cache compression
▸ Recommended (K=turbo4, V=turbo3) 4.2×
· Max Compress (K=turbo4, V=turbo2) 6.1×
Flash attention
▸ on (recommended)

Active: K=turbo4 V=turbo3
Tab switch ↑/↓ change Enter confirm q cancel
  • Hardware-aware defaultsIt reads your GPU's VRAM and suggests a layer count and context size that will actually fit.
  • KV presets with real numbersEvery compression option shows its factor and quality cost — no guessing.
  • Custom modePick K and V cache types independently, or type any context size by hand.
  • Per-model profilesEach model keeps its own settings in ~/.anvil/models.json, seeded from the GGUF's trained context. Change something in-chat with /temp or /ctx and it persists.
the-ledger

Every model, one ledger.

anvil keeps a model registry with friendly names and a persistent per-model profile. Pull models from Ollama's registry or Hugging Face, import local GGUFs, run them by nickname.

$ anvil list
qwen3.6-27b turbo4/turbo3 262K
lfm2.5-2.6b turbo4/turbo3 128K
bonsai-27b turbo3/turbo3 262K
$ anvil pull qwen3.6-27b
resolving qwen3.6-27b from ollama registry…
✓ downloaded · sha256 verified
$ anvil run qwen3.6-27b
KV : K=turbo4 V=turbo3 ctx : 128000 tokens flash : on
  • Friendly namesRun anvil run qwen3.6-27b — no paths, no hashes.
  • Pull from anywhereOllama registry and Hugging Face GGUF downloads, checksum-verified.
  • Import local filesPoint at any .gguf and anvil registers it with hardware probes.
  • Per-model profiles in models.jsonn_ctx, temp, flash_attn, type_k/type_v — seeded from the GGUF, editable in-chat, persisted forever.
capabilities

Read the fine print.

ANVIL(1)User CommandsANVIL(1)

NAME

anvil — forge-grade local LLM inference in your terminal

SYNOPSIS

anvil run model.gguf [--ctx N] [--ngl N]
    [--type-k T] [--type-v T] [--mtp]
    [--top-k 40] [--top-p 0.95] [--repeat-penalty 1.1]
    [--grammar f.gbnf] [-p "..."]

DESCRIPTION

anvil loads any GGUF model, auto-detects your hardware, and drops you into a streaming chat REPL. First run launches a TUI wizard; after that it just forges.

FEATURES

  • TurboQuant KV cache — 2/3/4-bit WHT-rotated, asymmetric K/V
  • MTP + NextN speculative decoding
  • Flash Attention on by default
  • GBNF grammars for structured output
  • Model registry — pull, import, nickname
  • Streaming markdown — thinking blocks, bold, code, tables
  • Hardware autodetect — CUDA · Vulkan · Metal · ROCm · CPU
  • Live stats — tokens/sec, context fill, session export
  • Single binary — zero telemetry, zero cloud
hammer-strokes

Commands at the anvil.

Everything you need mid-conversation, one keystroke away.

/stats

tokens generated, avg t/s, context fill, KV types

/undo

strike out the last turn and rebuild the cache

/export

save the session to markdown in ~/.anvil/sessions

/clear

quench the context and start fresh

/model

arch, trained context, encoder/decoder, GPU layers

/temp 0.9

retune sampling — persists to the model's profile

/ctx

context usage bar, color-coded by heat

/exit

put down the hammer

weigh

anvil vs. the field.

We respect the other tools. We also think you should know what you're giving up.

anvilollamallama.cpp CLILM Studio
TurboQuant KV cache✓ nativefork only
MTP / NextN spec decodefork only
First-run TUI wizardGUI
Per-model profilesModelfiles
Model registry + pullGUI
Streaming markdown + thinking blockspartial
Terminal-native✗ (app)
Session export / undopartial
Open source✓ MIT
Telemetrynonesomenoneyes
the-ledger

One config. Per-model profiles.

Global settings live in ~/.anvil/config.json. Every model gets its own profile in ~/.anvil/models.json — seeded from the GGUF, editable in-chat, persisted forever.

"qwen3.6-27b": { "path": "~/.anvil/models/qwen3.6-27b.gguf", "n_ctx": 131072, "temp": 0.8, "flash_attn": true, "type_k": "turbo4", "type_v": "turbo3", "top_k": 40, "top_p": 0.95 } "lfm2.5-2.6b": { "n_ctx": 128000, "temp": 0.7, "type_k": "turbo4", "type_v": "turbo3" }
  • Seeded from the GGUFn_ctx = the model's trained context, sampling params from its metadata. Filled only when unset.
  • Changes persistSet /temp 0.9 or /ctx 65536 in-chat and the profile is written back to models.json.
  • CLI always winsAny flag you pass overrides the file for that run.
  • Zero artificial capsn_batch tracks n_ctx, and context size is bounded only by the backend's int32 position counter — not by a hardcoded limit.
what-will-you-forge

One binary, many blades.

01

Offline copilot

Code review and generation on a plane, in a basement, behind a firewall. Your code never leaves the room.

anvil run qwen-coder.gguf --ngl 99
02

Long-document research

TurboQuant’s KV compression means whole papers and codebases fit in context on a single GPU.

anvil run model.gguf --ctx 131072 --type-k turbo4 --type-v turbo3
03

Structured output

GBNF grammars constrain the model to valid JSON, SQL, or your own format — guaranteed by the sampler.

anvil run model.gguf --grammar json.gbnf -p "list 3 colors"
04

Batch & scripts

Single-shot mode pipes cleanly into shell pipelines. Generate, grep, forge on.

anvil run model.gguf -p "summarize: $(cat notes.txt)"
ask-the-smith

Frequently struck questions.

Yes. TurboQuant: Online Vector Quantization with Near-optimal Distortion Rate is by Amir Zandieh, Majid Daliri, Majid Hadian and Vahab Mirrokni (Google Research / Google DeepMind / NYU), arXiv 2504.19874. It proves near-optimal distortion — within ≈2.7× of the Shannon lower bound — and shows quality-neutral KV compression at 3.5 bits. The anvil fork implements the WHT-rotated family (turbo2/3/4) with backend-native kernels.

anvil ships the WHT-rotated TurboQuant family (2/3/4-bit K and V cache types, selectable per side). How much memory you save depends on your model and context — see the benchmark tables above from the Google Research paper (arXiv:2504.19874), which show TurboQuant matching the full-precision cache on LongBench and needle-in-a-haystack.

No — anvil runs on CPU with AVX2/NEON. But with a GPU it auto-offloads layers, and TurboQuant's KV compression means even modest VRAM fits long contexts. An RTX 3060 12GB is a perfectly good anvil.

Any GGUF file that llama.cpp supports — Llama, Qwen, Gemma, DeepSeek, Mistral, Phi, and friends. MTP/NextN speculative decoding additionally needs a model with prediction heads (Gemma 4, Qwen 3.6 UDT).

ollama is a great general-purpose server. anvil is a terminal-first power tool built specifically on the TurboQuant fork — you get asymmetric KV compression, speculative decoding, a setup TUI, a model registry with per-model profiles, and streaming markdown. No daemon, no server, just a binary.

Nothing. No telemetry, no update checks, no crash reports, no network calls at runtime. The only time anvil touches the network is when you install it or pull a model.

Yes. Edit ~/.anvil/config.json or a model's entry in ~/.anvil/models.json directly, or pass CLI flags (--ctx, --type-k, --ngl, …) which override for that run. In-chat /temp and /ctx persist to the profile.

the-forge-ahead

What's heating up.

v0.1shipped

First light. Chat REPL, hardware detection, TUI wizard, TurboQuant KV.

v0.2shipped

Asymmetric K/V presets, MTP/NextN, /stats /undo /export, UTF-8 streaming, session persistence.

v0.3shipped

Ollama registry + local import for anvil pull, Hugging Face GGUF downloader.

v0.4shipped

Model registry with friendly names and persistent per-model profiles. Per-model settings schemas seeded from GGUF.

v0.5current

Streaming markdown renderer (mdtty) with live token redraw — thinking blocks, bold, code, tables. Zero artificial context caps.

v0.6next

anvil serve — OpenAI-compatible local server. Multimodal vision input.

v0.7planned

Conversation branching, context extension UI, grammar-driven function calling.

v0.8dreaming

Agent / tool-use loop, multi-model routing.

struck-so-far

Changelog.

v0.5.02026-08-09
  • Streaming markdown renderer (mdtty) with live token redraw
  • Thinking blocks formatted in dim grey; response markdown fully styled
  • n_batch tracks n_ctx; all artificial context caps removed
  • Per-model profiles persisted from in-chat /temp /ctx changes
v0.4.02026-08-09
  • Model registry with friendly names + persistent per-model profiles
  • Per-model settings schema seeded from GGUF metadata
  • anvil pull: Ollama registry + local ollama import + Hugging Face GGUF
  • Windows build fixes (NOMINMAX, portable TTY check)
v0.2.02026-07-26
  • Independent K/V cache type selection with presets (turbo4/turbo3 recommended)
  • MTP + NextN speculative decoding support
  • GBNF grammar-constrained output
  • REPL commands: /stats /undo /export /model /temp /ctx
  • Live tokens/sec + context usage bar
  • Safe UTF-8 streaming (no more split multi-byte chars)
  • Session export to markdown
  • Config v2 with automatic migration
v0.1.02026-07-01
  • Initial release — chat REPL + single-shot mode
  • FTXUI first-run setup wizard
  • Cross-platform hardware detection (macOS / Linux / Windows)
  • TurboQuant KV cache compression
get-it

One line. That's the whole install.

curl -fsSL https://anvil-llm.github.io/anvil/install.sh | sh

Detects your OS + arch, grabs a pre-built binary with checksum verification, falls back to building from source. Installs to ~/.local/bin and creates ~/.anvil.

On NVIDIA Linux it grabs the CUDA build (driver-only — no CUDA toolkit) via anvil-nvidia-install.sh — universal: any distro, any NVIDIA GPU, auto-picks the right driver branch and keeps it DKMS-rebuilt across kernel updates.

git clone https://github.com/Anvil-LLM/anvil.git
cd anvil
git submodule update --init --recursive
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j$(nproc)
sudo cp build/anvil /usr/local/bin/
Linux   cmake ≥ 3.18 · g++ / clang++ · git
macOS   xcode-select --install · cmake · git
Windows VS 2022 + CMake + Git

GPU backends auto-detected:
CUDA · Vulkan · Metal · ROCm · SYCL · CPU
start-forging

Put your model on the anvil.

One line installs it. One command runs it. Your GPU does the rest.

$ curl -fsSL https://anvil-llm.github.io/anvil/install.sh | sh