Skip to content
 
 

Latest commit

 

History

10,685 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

llama.cpp + TurboQuant+

llama

A fork of ggml-org/llama.cpp integrating the TurboQuant+ implementation of TheTom's TurboQuant+ codec. This fork adds KV-cache and weight quantization types, cross-backend kernel support, and model-family-specific fixes.

What this fork adds

KV-cache quantization (runtime, --cache-type-k / --cache-type-v)

Type Bits Use case
turbo4 ~4.5 Lightest compression; safe starting point
turbo3 ~3.5 Recommended: ~4.6× V compression at <1.5% PPL loss
turbo2 ~2.0 Aggressive; pair with Boundary V protection

Key insight: Asymmetric K/V compressionV tolerates aggressive compression, K does not. Always keep K at higher precision (f16 or q8_0) and compress V.

Recommended configs:

  • Safe start: --cache-type-k f16 --cache-type-v turbo4
  • Default: --cache-type-k q8_0 --cache-type-v turbo3
  • Long context: --cache-type-k q8_0 --cache-type-v turbo2

Weight quantization (offline, via llama-quantize)

Type Bits Notes
TQ4_1S ~4.5 Recommended: V2.1 fused Metal kernels, CUDA dp4a 3.5× faster
TQ3_1S ~3.5 Smaller VRAM than q8_0; accept ~1-2 PPL bump
llama-quantize model.f16.gguf model.tq4_1s.gguf TQ4_1S

Advanced features

  • Auto-asymmetric K/V — complementary codec selection when both sides are turbo/TQ types
  • Boundary V (layer-aware) — auto-enabled for turbo2-V; protects sensitive layers
  • Sparse V dequantization — Metal-only; skips dequant for low-attention positions
  • Flash Attention — auto-enabled with backend-specific kernels

Backend coverage

Backend Kernels Flash Attn Notes
Metal (Apple Silicon) V2.1 fused, TurboFlash Yes (dk=512 for Gemma 4) Sparse V across family
CUDA (NVIDIA) dp4a for TQ4_1S, warp-cooperative dequant Yes (turbo VEC FA +9%) Multi-GPU support
HIP/ROCm (AMD) Portable ggml_cuda_dp4a, scalar half fallback Yes (VEC FA forced) RDNA3/4, CDNA3/4
Vulkan TQ4_1S weights, SET_ROWS for turbo K/V coopmat flash attn Compute-shader path
SYCL (Intel) SET_ROWS, WHT rotation VEC FA for all combos Intel Arc A380/B70

Model-family support

  • Gemma 4 — MoE token routing, op-concurrency handling
  • Large MoE — up to 256-expert routing kernels
  • Hybrid architectures (Mamba/GDN) — speculative decoding integration
  • All existing llama.cpp models remain fully supported

Quick start

Build from source

# Clone this fork (not upstream!)
git clone https://github.com/eyalezer/llama.cpp.git

cd llama.cpp

# Build with your preferred backend
cmake -B build -DGGML_METAL=ON && cmake --build build -j
# or: cmake -B build -DGGML_CUDA=ON && cmake --build build -j
# or: cmake -B build -DGGML_VULKAN=ON && cmake --build build -j

# Run a model with turbo KV cache
llama-cli -m model.gguf --cache-type-k q8_0 --cache-type-v turbo3 -p "Hello!"

Why the +?

TurboQuant+ extends Google's original TurboQuant (ICLR 2026) paper with:

  • Asymmetric K/V policy (paper)
  • Layer-aware Boundary V protection (paper)
  • Attention-gated sparse V dequantization (paper)
  • TQ3_1S / TQ4_1S weight quantization (paper)
  • Cross-backend kernel coverage (CUDA dp4a, HIP RDNA/CDNA, Vulkan coopmat, Metal V2.1)

The trailing + denotes ongoing extension work; the original TurboQuant codec remains the foundation.


Quick start

A few options to get llama.cpp installed on your machine:

Once installed:

# Download and run a model directly from Hugging Face
llama cli -hf ggml-org/Qwen3.5-0.8B-GGUF

# Launch OpenAI-compatible API server
llama serve -hf ggml-org/Qwen3.5-0.8B-GGUF
VLM session with `llama cli` VLM session with llama cli Built-in web UI against `llama serve` running Qwen 3.6 Built-in web UI against llama serve

Description

The main goal of llama.cpp is to enable LLM (and VLM) inference with minimal setup and state-of-the-art performance on a wide range of hardware - locally and in the cloud.

  • Plain C/C++ implementation without any dependencies
  • Apple silicon is a first-class citizen - optimized via ARM NEON, Accelerate and Metal frameworks
  • AVX, AVX2, AVX512 and AMX support for x86 architectures
  • RVV, ZVFH, ZFH, ZICBOP and ZIHINTPAUSE support for RISC-V architectures
  • 1.5-bit, 2-bit, 3-bit, 4-bit, 5-bit, 6-bit, and 8-bit integer quantization for faster inference and reduced memory use
  • Custom CUDA kernels for running LLMs on NVIDIA GPUs (support for AMD GPUs via HIP and Moore Threads GPUs via MUSA)
  • Vulkan and SYCL backend support
  • CPU+GPU hybrid inference to partially accelerate models larger than the total VRAM capacity

The llama.cpp project is build on top of the ggml library.

Supported backends

Backend Target devices
BLAS All
BLIS All
CANN Ascend NPU
CUDA Nvidia GPU
HIP AMD GPU
Hexagon [In Progress] Snapdragon
IBM zDNN IBM Z & LinuxONE
MUSA Moore Threads GPU
Metal Apple Silicon
OpenCL Adreno GPU
OpenVINO [In Progress] Intel CPUs, GPUs, and NPUs
RPC All
SYCL Intel GPU
VirtGPU VirtGPU APIR
Vulkan GPU
WebGPU All
ZenDNN AMD CPU

Documentation

Tools

Development

Contributing

  • Contributors can open PRs
  • Collaborators will be invited based on contributions
  • Maintainers can push to branches in the llama.cpp repo and merge PRs into the master branch
  • Any help with managing issues, PRs and projects is very appreciated!
  • Read the CONTRIBUTING.md for more information

Acknowledgements

  • yhirose/cpp-httplib - Single-header HTTP server, used by llama-server - MIT license
  • nothings/stb - Single-header image format decoder, used by multimodal subsystem - Public domain
  • nlohmann/json - Single-header JSON library, used by various tools/examples - MIT License
  • mackron/miniaudio - Single-header audio format decoder, used by multimodal subsystem - Public domain
  • sheredom/subprocess.h - Single-header process launching solution for C and C++ - Public domain

About

LLM inference in C/C++

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages