Hybrid Inference
Fork notice. This repository is a fork of llama.cpp with a proof of concept of hybrid prefill/decode inference: see HYBRID.md.
Prototype builds disable UI assets: configure with cmake -S . -B build -DLLAMA_BUILD_UI=OFF -DLLAMA_USE_PREBUILT_UI=OFF -DLLAMA_CURL=OFF, then build the named targets listed in the node guide. The M1 operator guide provides deployment, client setup and benchmark commands; its launchers always disable the unused UI download.
Prototype tools
The vLLM bridge guide lists the Python exporter/converter, native CPU reader test, exact entry points and .temp/ artifact locations. Its design contains the GPU-host plan; only CPU conversion and synthetic native import are qualified here.
The vLLM node protocol and B300 node runbook cover the HTTP adapter, aligned exports, local decoder tails and supervised deployment. Live CUDA extraction and heterogeneous numerical equivalence remain qualification gates.
Mirai S trellis support is ported from alesha-pro/llama.cpp-mirai-s; see format and provenance. CPU and CUDA kernels are included; Metal is unsupported.
Mirai prototype tools (CPU checks use existing local headers and never download weights):
| Tool | Command | Output |
|---|---|---|
| CMake and C++ compiler | cmake -S . -B build -DLLAMA_BUILD_UI=OFF -DLLAMA_USE_PREBUILT_UI=OFF -DLLAMA_CURL=OFF -DGGML_CUDA=OFF then cmake --build build --target test-backend-ops llama-hybrid-check-identity -j 2 |
build/bin/ |
| Backend tests | OMP_NUM_THREADS=2 nice -n 10 build/bin/test-backend-ops test -b CPU -o MIRAI_MUL_MAT |
Terminal |
| Fork/port parity | python3 tools/mirai-s/parity.py collect --help; python3 tools/mirai-s/parity.py compare --a .temp/mirai-parity/fork.json --b .temp/mirai-parity/port.json |
JSON and logs under .temp/mirai-parity/; full GPU gate in the r2 report |
| Parity gate CPU tests | python3 -m unittest discover -s tools/mirai-s -p test_parity.py -v |
Terminal; no GPU or model |
| Python identity fixtures | python3 tools/hybrid-bench/test_mirai_identity.py |
Terminal; native cases skipped without local headers |
| Native header fixtures (glibc) | python3 tools/hybrid-bench/test_mirai_identity.py --binary build/bin/llama-hybrid-check-identity --headers /path/to/headers --artifacts .temp/mirai-identity |
.temp/mirai-identity/ |
| Native model identity | build/bin/llama-hybrid-check-identity /path/to/model.gguf |
JSON layout and fingerprint, no weight allocation |
Set TMPDIR to an existing disk directory for builds and tests. The header hashes and metadata-only fixtures are recorded in tools/hybrid-bench/fixtures/mirai-s-headers.json.
Local-kept hybrid latency: python3 tools/hybrid-proxy/bench_local.py --help uses existing binaries and models, writes paired timing/token/replay evidence under the supplied --artifacts directory, and stops its recorded server PIDs. See the CPU measurements and GPU commands.
Everything below is the upstream llama.cpp README.
llama.cpp
LLM inference in C/C++
ggml / ops / maintainer PRs / dev stats / lib llama API / llama-server REST API
Quick start
A few options to get llama.cpp installed on your machine:
# curl
curl -LsSf https://llama.app/install.sh | sh
# powershell
irm https://llama.app/install.ps1 | iex
- Visit https://llama.app and follow the instructions
- Run with Docker - see our Docker documentation
- Download pre-built binaries from the releases page
- Build from source by cloning this repository - check out our build guide
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
|
|
|
| Backend | Target devices |
|---|---|
| BLAS | All |
| BLIS | All |
| CANN | Ascend NPU |
| CUDA | Nvidia GPU |
| HIP | AMD GPU |
| Hexagon | 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
- cli
- completion
- server
- hybrid client proxy prototype - Python proxy, stub, policy replay, captured-template tests, external Jinja2 oracle and mutation controls; exact commands in the linked guide, artifacts in
.temp/<run>/, oracle sources viaHYBRID_TEMPLATE_FIXTURES - hybrid benchmark prototype - Deployment, benchmark, tests and cleanup controls with exact commands and artifact locations
- GBNF grammars
Development
- How to build
- Running on Docker
- Build on Android
- Multi-GPU usage
- Performance troubleshooting
- GGML tips & tricks
- XCFramework
- Completions
- Models
- Release process
Contributing
- Contributors can open PRs
- Collaborators will be invited based on contributions
- Maintainers can push to branches in the
llama.cpprepo and merge PRs into themasterbranch - 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
Hybrid prefill prototype tools
The local CPU prefill node, shared state-delta codec, correctness checker, and HTTP isolation tests are documented in tools/hybrid/README.md, including exact CMake, flock, Python and run commands. Binaries go to build/bin/; logs and task-local tools go to .temp/; golden state fixtures go to ~/Werkstatt/hybrid-models/golden/.
Sliding-window transfer for Gemma 4 and Muse Glimmer is described in SWA-STATE-DESIGN.md. Build llama-hybrid-check-swa with the locked named-target command in the node guide, then run nice -n 19 build/bin/llama-hybrid-check-swa for model-free allocated-cache tests. Logs belong under .temp/; real-model GPU qualification commands are in the r16 report.
Reference-model teacher-forced scoring uses build/bin/llama-hybrid-score and python3 tools/hybrid-bench/hybrid_bench.py reference. Exact build/run/test commands and output paths are in the benchmark operator guide. References and logs belong in private task directories under .temp/; sanitized measurements are written to the requested JSON result and benchmark bundle.
Growing-session experiments use python3 tools/hybrid-bench/growing_session.py; the scenario/trace schema and CPU, CUDA and Mac commands document all outputs under a task’s .temp/ directory, live-state checkpoint checks and current qualification gates. The model-free snapshot streaming regression is python3 tools/hybrid-bench/test_snapshot_stream.py -v; temporary state goes under the on-disk TMPDIR and is removed after the test.
Growing-session qualification always captures private state-path controls; --state-probes remains an accepted compatibility flag. It captures the live node’s authenticated snapshots and deltas beside the trace and compares native restore, range roundtrips, append-chain replay, and separate attention/recurrent replacements. R41 gates all ten exact replay/component controls and L-H top-1>=63/64. L-H KL/p95/max/free divergence and the per-statistic fidelity_flag against schedule noise remain report-only; heterogeneous runs stay exit 5.
Delta import profiling uses python3 tools/hybrid/profile_import.py and build/bin/llama-hybrid-check-client --identity; commands and output locations are in the import profiling guide.
Combined SWA layout and final-state chunk CPU qualification, invariant checks and exact GPU operator commands are in the r27 report.
The vLLM node adapter uses the same HYBD v2 final-state chunk protocol with exact aligned exports, local tails and borrowed native-body readers; see its protocol and r11 merge evidence. CPU adapter/converter checks use a temporary NumPy-only venv; commands and artifacts are in the adapter tools guide.
MIT License
Copyright (c) 2023-2026 The ggml authors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.