Find a file
Thiago Padilha 1464c62d88
metal: implement DSv4 Lightning Indexer (#25893)
* metal: implement F16 Lightning Indexer

- Implement GGML_OP_LIGHTNING_INDEXER for 128-dimensional, 64-head inputs
  with F32 queries and weights plus F16 keys and masks.
- Add tiled and tail kernels and test KV lengths around 8- and 64-element
  boundaries.

llama-bench (--mmap 1, -fa 1, -p 512, -n 128; d=0/10k/20k/30k):

Before:
- pp512: 153.73 ± 0.87 t/s
- tg128: 8.91 ± 0.04 t/s
- pp512 @ d10000: 73.90 ± 0.39 t/s
- tg128 @ d10000: 8.66 ± 0.03 t/s
- pp512 @ d20000: 45.83 ± 0.18 t/s
- tg128 @ d20000: 8.26 ± 0.03 t/s
- pp512 @ d30000: 33.40 ± 0.21 t/s
- tg128 @ d30000: 7.94 ± 0.01 t/s

After:
- pp512: 155.19 ± 0.91 t/s
- tg128: 8.95 ± 0.04 t/s
- pp512 @ d10000: 86.95 ± 0.69 t/s
- tg128 @ d10000: 9.00 ± 0.05 t/s
- pp512 @ d20000: 62.01 ± 0.45 t/s
- tg128 @ d20000: 8.68 ± 0.04 t/s
- pp512 @ d30000: 49.18 ± 0.33 t/s
- tg128 @ d30000: 8.60 ± 0.02 t/s

Assisted-by: Codex

* metal: stage Lightning Indexer K tiles

- Stage and dequantize K in F16 threadgroup memory before simdgroup matrix loads.
- Zero-fill partial tiles and guard stores so all KV segments use the same numerical path.
- Support F32, F16, BF16, Q4_0, Q4_1, Q5_0, Q5_1, and Q8_0 K caches.

llama-bench (--mmap 1, -fa on, -p 512, -n 128; d=0/10k/20k):

- pp512: 160.38 +/- 1.01 t/s
- tg128: 9.08 +/- 0.03 t/s
- pp512 @ d10000: 88.37 +/- 0.46 t/s
- tg128 @ d10000: 9.07 +/- 0.04 t/s
- pp512 @ d20000: 62.53 +/- 0.46 t/s
- tg128 @ d20000: 8.84 +/- 0.03 t/s

Assisted-by: Codex

* dedup Lightning Indexer constants, fix flaky test

* cont : fix whitespace

---------

Co-authored-by: forforever73 <690105611@qq.com>
Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
2026-08-03 07:33:37 +03:00
.devops devops : add llama in all docker images (#25035) 2026-06-26 15:15:48 +02:00
.gemini contributing: tighten AI usage policy (#18388) 2025-12-29 16:01:32 +01:00
.github vulkan: update vulkan sdk to 1.4.357.0 (#26303) 2026-07-31 07:27:03 -05:00
.pi/gg pi : remove docs from system prompt (#24791) 2026-06-19 09:34:00 +03:00
app app : allow --version, --licenses & --help (#25054) 2026-06-26 23:18:11 +02:00
benches benches : add Nemotron 3 Nano on DGX Spark (#20652) 2026-03-16 21:50:43 +02:00
ci common : fix env names to all have LLAMA_ARG_ prefix (#23778) 2026-05-27 14:52:47 +03:00
cmake cmake : do not check for bin install dir (#23234) 2026-05-18 02:33:14 +02:00
common common: support the DSpark sidecar resolution (#26458) 2026-08-02 19:25:27 +02:00
conversion convert: add option to create separate dspark GGUF (#26452) 2026-08-02 23:16:31 +08:00
docs SYCL: add oneMKL GEMM flash attention for XMX-accelerated prompt proc… (#25025) 2026-07-31 10:43:16 +03:00
examples args: refactor mlock/mmap/directio into load-mode (#20834) 2026-07-23 20:32:56 +08:00
ggml metal: implement DSv4 Lightning Indexer (#25893) 2026-08-03 07:33:37 +03:00
gguf-py convert: add option to create separate dspark GGUF (#26452) 2026-08-02 23:16:31 +08:00
grammars docs : fix typos in CUDA-FEDORA.md and grammars/README.md (#24459) 2026-06-15 01:33:38 +08:00
include llama : load MTP tensors only if they are really used (#26296) 2026-07-31 14:57:02 +02:00
licenses refactor : remove libcurl, use OpenSSL when available (#18828) 2026-01-14 18:02:47 +01:00
media media : add transparent icon svg and png [no ci] (#15891) 2025-09-10 14:51:28 +03:00
models common/chat: add specialized minimax m3 parser (#26210) 2026-07-28 04:27:20 -05:00
pocs libs : rename libcommon -> libllama-common (#21936) 2026-04-17 11:11:46 +03:00
requirements model: add Mellum architecture (#23966) 2026-06-02 22:11:12 +03:00
scripts sync : ggml 2026-07-30 15:44:24 +03:00
skills agents: clarify comment style and jinja knowledge (#26405) 2026-08-01 18:45:46 +02:00
src DeepseekV4 MTP + DSpark (#25784) 2026-08-02 20:55:34 +08:00
tests metal: implement DSv4 Lightning Indexer (#25893) 2026-08-03 07:33:37 +03:00
tools test: fix some CI errors (#26415) 2026-08-02 00:16:29 +02:00
vendor vendor : update BoringSSL to 0.20260730.0 (#26353) 2026-08-01 20:53:00 +02:00
.clang-format fix: apply clang-format to CUDA macros (#16017) 2025-09-16 08:59:19 +02:00
.clang-tidy clang-tidy : disable warning about performance enum size (#16127) 2025-09-22 19:57:46 +02:00
.dockerignore docker : prebuild web UI for s390x build [no release] (#24829) 2026-06-20 05:54:42 -05:00
.ecrc common : Update stb_image.h to latest version (#9161) 2024-08-27 08:58:50 +03:00
.editorconfig ui: Restructure repo to use tools/ui folder and ui / UI / llama-ui / LLAMA_UI naming (#23064) 2026-05-16 02:02:40 +02:00
.flake8 llama : move end-user examples to tools directory (#13249) 2025-05-02 20:27:13 +02:00
.gitignore ui: PWA support (#23871) 2026-06-12 15:53:26 +02:00
.gitmodules ggml : remove kompute backend (#14501) 2025-07-03 07:48:32 +03:00
.pre-commit-config.yaml convert.py : add python logging instead of print() (#6511) 2024-05-03 22:36:41 +03:00
AGENTS.md agents: clarify comment style and jinja knowledge (#26405) 2026-08-01 18:45:46 +02:00
AUTHORS authors : update (#19263) 2026-02-02 08:51:25 +02:00
build-xcframework.sh xcframework : disable mtmd video on i/tv/visionos (#25018) 2026-06-26 00:13:59 +02:00
CLAUDE.md contributing: tighten AI usage policy (#18388) 2025-12-29 16:01:32 +01:00
CMakeLists.txt common: add subproc.h wrapper, disabled on android/ios (#26102) 2026-07-26 20:54:25 +02:00
CMakePresets.json cmake : Add CMake presets for Linux and GCC (#14656) 2025-07-13 08:12:36 +03:00
CODEOWNERS HIP: remove rocWMMA FlashAttention (#26046) 2026-07-24 17:53:54 +02:00
CONTRIBUTING.md contrib : add guideline about the "merge ready" label (#26178) 2026-07-28 08:41:04 +03:00
convert_hf_to_gguf.py convert: add option to create separate dspark GGUF (#26452) 2026-08-02 23:16:31 +08:00
convert_hf_to_gguf_update.py Add support for Laguna XS.2 & M.1 (#25165) 2026-07-22 09:54:08 +08:00
convert_llama_ggml_to_gguf.py ci : switch from pyright to ty (#20826) 2026-03-21 08:54:34 +01:00
convert_lora_to_gguf.py convert : fix lora base model arch retrieval (#24621) 2026-06-15 00:55:26 +02:00
flake.nix fix(nix): remove non-functional llama-cpp cachix cache from flake.nix (#15295) 2025-08-13 11:21:31 -07:00
LICENSE docs : Minor cleanups (#19252) 2026-02-02 08:38:55 +02:00
Makefile make : remove make in favor of CMake (#15449) 2025-08-20 13:31:16 +03:00
mypy.ini convert : partially revert PR #4818 (#5041) 2024-01-20 18:14:18 -05:00
pyproject.toml model: add Mellum architecture (#23966) 2026-06-02 22:11:12 +03:00
pyrightconfig.json ci : switch from pyright to ty (#20826) 2026-03-21 08:54:34 +01:00
README.md readme : refresh (#26280) 2026-07-30 16:14:37 +03:00
requirements.txt tool-call: fix Qwen 2.5 Coder support, add micro benchmarks, support trigger patterns for lazy grammars (#12034) 2025-03-05 13:05:13 +00:00
SECURITY.md binaries : Improve rpc-server and export-graph-ops names. (#25045) 2026-06-27 10:31:29 +03:00
ty.toml mtmd : DeepSeek-OCR image processing fixes, img_tool::resize padding refactor (#23345) 2026-05-20 17:37:10 +02:00

llama.cpp

llama

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
  • stb-image - Single-header image format decoder, used by multimodal subsystem - Public domain
  • nlohmann/json - Single-header JSON library, used by various tools/examples - MIT License
  • miniaudio.h - Single-header audio format decoder, used by multimodal subsystem - Public domain
  • subprocess.h - Single-header process launching solution for C and C++ - Public domain