Rhonstin/beellama-cmp90hx

beellama.cpp fork with CMP 90HX (GA102, sm_86) optimizations: DP4A→IMAD, FP32→HFMA2 — +58-87% decode speed

12

stars

9,798

commits

C++

primary language

Sep 3, 2026

updated

Browse cluster: Local LLM Inference Optimization

README

Anbeeld's BeeLlama.cpp — CMP 90HX Edition

BeeLlama.cpp logo

BeeLlama.cpp (or just Bee) is a performance-focused llama.cpp fork for squeezing more speed and context out of local GGUF inference. It adds variance-normalized KV-cache quantization (KVarN), KV cache precision tail for recent tokens, low-bit cache types, adaptive draft control for speculative decoding, reasoning-loop protection, and more.

This fork additionally patches the CUDA backend for NVIDIA CMP 90HX (GA102, sm_86), replacing firmware-throttled instructions (DP4A, FP32 FFMA) with unthrottled equivalents (IMAD, HFMA2).

Not quite a pegasus, but close enough.


CMP 90HX Optimizations

The CMP 90HX (GA102, sm_86) has a firmware that throttles certain CUDA instructions:

InstructionLatencyStatus
FFMA / FADD / FMUL17.8 nsthrottled 14–15×
DP4A35.6 nsthrottled 29×
IMAD / IADD1.4 nsunthrottled
HFMA2 / HADD21.3–1.4 nsunthrottled
Tensor cores284.5 nsseverely throttled — disabled

Applied patches

PatchFileImpact
DP4A → PTX IMAD (4×mad.lo.s32)ggml/src/ggml-cuda/common.cuh+47.6% decode (42→62 tok/s)
FP32 dequant → HFMA2 (Q4_K, Q5_K)ggml/src/ggml-cuda/vecdotq.cuh+7.1% additional
FP32 dequant → HFMA2 (Q6_K, Q2_K)ggml/src/ggml-cuda/vecdotq.cuh+4.2% additional
fattn DKQ=512 → tile kernelggml/src/ggml-cuda/fattn.cucrash fix for Gemma4

Cumulative gain vs unpatched: ~+58% on Q4_K models, ~+87% on dense Q4_K_XL models.

Benchmark data in bench/cmp90hx/. Future patch roadmap in FUTURE_PATCHES.md.

Build for CMP 90HX

cmake -B build -DGGML_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=86 \
  -DGGML_CUDA_FA=ON -DGGML_CUDA_FA_ALL_QUANTS=ON \
  -DCMAKE_BUILD_TYPE=Release
cmake --build build -j$(nproc) --target llama-bench llama-server

Support my work!

Fork Features

  • Variance-normalized KV-cache quantization (KVarN): provides higher precision at similar memory costs. Independent K and V bit widths at kvarn2, kvarn3, kvarn4, kvarn5, kvarn6, and kvarn8, set with --cache-type-k and --cache-type-v.
  • KV cache precision tail: keep most of the KV cache quantized while storing recent tokens in F16/BF16, enabled with --kv-tail-tokens. A single global softmax merges the quantized body and the precision tail under FlashAttention, without materializing the whole cache.
  • Standard low-bit KV cache types: q2_0, q2_1, q3_0, q3_1, q6_0, and q6_1, usable for either target or draft caches alongside the upstream q4/q5/q8 types.
  • Adaptive draft-max for DFlash: adjusts the active DFlash draft horizon at runtime instead of using a fixed --spec-draft-n-max, comparing speculative throughput against a no-spec baseline.
  • Reasoning-loop protection: the server detects repeated hidden reasoning output and intervenes.

For the full feature and public-repo comparison, read docs/beellama-features.md. For the complete argument reference, read docs/beellama-args.md.

KV Cache Quantization

K and V cache types are set independently with --cache-type-k and --cache-type-v. The research is covered in articles: KVarN KV Cache: Implementation and Benchmarks, KV Cache Precision Tail: Implementation and Benchmarks, and KV Cache Quantization Benchmarks: KVarN, Precision Tail.

KV Cache Recommenation Ladder

The measurements come from Qwen 3.6 27B Q5_K_S at 64K context on Wikitext-2 raw with -b 2048 -ub 512 on an RTX 3090. Median KLD is the primary quality metric; lower is better.

K / VTailSizeSize vs bf16Median KLD99.9% KLDWhat it is for
bf16 / bf1604096 MiB100.0%00.000050Reference
q8_0 / q8_010242272 MiB55.5%0.0008970.087699Standard fidelity with a precision tail
kvarn8 / kvarn810242256 MiB55.1%0.0008710.087639Best measured quality below BF16
q8_0 / q8_002176 MiB53.1%0.0009090.093029Standard fidelity
q8_0 / q6_010242016 MiB49.2%0.0008940.091098q8_0 quality within noise, 256 MiB less
kvarn6 / kvarn610241744 MiB42.6%0.0008790.084629High-end value pick
kvarn6 / kvarn510241616 MiB39.5%0.0008860.092778Much cheaper, almost as good
kvarn5 / kvarn510241488 MiB36.3%0.0008970.087666Highest value in the mid-range
q5_0 / q4_110241440 MiB35.2%0.0009660.089128Standard option when VRAM-constrained
kvarn5 / kvarn410241360 MiB33.2%0.0009360.089469Balanced default
q4_0 / q4_010241248 MiB30.5%0.0010570.104486Compact standard cache
kvarn4 / kvarn410241232 MiB30.1%0.0009940.090391Cleaner than q4_0 for less memory
kvarn4 / kvarn310241104 MiB27.0%0.0011120.113968Smallest recommended tier
kvarn3 / kvarn31024976 MiB23.8%0.0013160.139558When the context must fit
kvarn3 / kvarn21024848 MiB20.7%0.0024240.238780Emergency compression
kvarn2 / kvarn21024720 MiB17.6%0.0038110.450496Last resort

A 1024-token tail is a useful starting point for low-bit Qwen caches. Prefer more body precision when old and recent tokens matter equally; consider 2048 only when the newest two thousand tokens are genuinely the privileged working set. Standard caches generally have slightly faster prefill.

Gemma 4 needs a separate decision. Its 1024-token sliding window makes a 1024 tail exact across most layers, sharply changing memory and throughput. Standard q8_0 / q8_0 without a tail is the safer Gemma default when throughput and older-context coverage matter, and the benchmark results recommend avoiding quantized KV cache when Gemma quality is non-negotiable.

Standard-Only KV Cache Ladder

Use this generic fallback ladder when KVarN or precision tails are unavailable. It is based on the same Qwen 3.6 27B benchmark, with every standard cache row using tail 0.

K / VSizeSize vs bf16Median KLD99.9% KLDWhat it is for
bf16 / bf164096 MiB100.0%00.000050Reference
q8_0 / q8_02176 MiB53.1%0.0009090.093029Compression with minimal losses
q8_0 / q6_01920 MiB46.9%0.0009370.093575256 MiB below q8_0
q6_0 / q6_01664 MiB40.6%0.0009600.091134High-end value pick
q6_0 / q5_01536 MiB37.5%0.0010540.094670Balanced default
q5_0 / q5_01408 MiB34.4%0.0011540.097070Last tier before the cliff
q5_0 / q4_11344 MiB32.8%0.0014330.122096Default when VRAM-constrained
q5_0 / q4_01280 MiB31.3%0.0015160.12106864 MiB cheaper, worse median
q4_0 / q4_01152 MiB28.1%0.0018460.154408Smallest recommended tier
q4_0 / q3_01024 MiB25.0%0.0033130.218912When the context must fit
q3_0 / q3_0896 MiB21.9%0.0046960.304186Emergency compression
q2_0 / q2_0640 MiB15.6%0.0193741.198902Last resort

KV Cache Type Reference

All KV cache types available in BeeLlama
TypeOriginbpvSize vs bf16
q8_0upstream8.553.1%
kvarn8Huawei / fork8.37552.3%
q6_1fork7.043.8%
q6_0fork6.540.6%
kvarn6Huawei / fork6.37539.8%
q5_1upstream6.037.5%
q5_0upstream5.534.4%
kvarn5Huawei / fork5.37533.6%
q4_1upstream5.031.3%
q4_0upstream4.528.1%
iq4_nlupstream4.528.1%
kvarn4Huawei / fork4.37527.3%
q3_1fork4.025.0%
q3_0fork3.521.9%
kvarn3Huawei / fork3.37521.1%
q2_1fork3.018.8%
q2_0fork2.515.6%
kvarn2Huawei / fork2.37514.8%

Standard ratios come directly from each block format. KVarN ratios describe the compressed record body, including scale and zero-point metadata; the permanent exact sink, exact suffix, staging, and alignment add overhead.

Installation

Prebuilt

Current release binaries are on the releases page.

PlatformBackendAsset suffix
macOS arm64Metalbin-macos-arm64.tar.gz
Ubuntu x64CPUbin-ubuntu-x64.tar.gz
Ubuntu arm64CPUbin-ubuntu-arm64.tar.gz
Ubuntu x64CUDA 12.4bin-ubuntu-cuda-12.4-x64.tar.gz
Ubuntu x64CUDA 13.3bin-ubuntu-cuda-13.3-x64.tar.gz
Ubuntu x64Vulkanbin-ubuntu-vulkan-x64.tar.gz
Ubuntu x64ROCm 7.2bin-ubuntu-rocm-7.2-x64.tar.gz
Ubuntu x64SYCLbin-ubuntu-sycl-x64.tar.gz
Windows x64CPUbin-win-cpu-x64.zip
Windows x64Vulkanbin-win-vulkan-x64.zip
Windows x64SYCLbin-win-sycl-x64.zip
Windows x64CUDA 12.4bin-win-cuda-12.4-x64.zip
Windows x64CUDA 13.3bin-win-cuda-13.3-x64.zip
Windows x64HIP/Radeonbin-win-hip-radeon-x64.zip

Windows CUDA archives contain a ggml-cuda.dll backend; download the matching beellama-<version>-cudart-win-cuda-*-x64.zip runtime archive and extract it into the same folder. Windows SYCL and HIP archives ship as standalone packages with all required runtime DLLs bundled.

Docker images are published to ghcr.io/anbeeld/beellama.cpp:

ImageAccelerationPlatforms
server, server-cpuCPUlinux/amd64, linux/arm64
server-cuda, server-cuda12CUDA 12.4linux/amd64
server-cuda13CUDA 13.3linux/amd64
server-rocmROCmlinux/amd64
server-vulkanVulkanlinux/amd64
server-syclSYCLlinux/amd64

Building from source with -DGGML_NATIVE=ON may result in a tiny bit better performance, so it might still be a good idea to do that if/when you decide to use this fork long-term.

CUDA Build

# Linux (GCC + CUDA)
cmake -B build -DGGML_CUDA=ON -DGGML_NATIVE=ON \
  -DGGML_CUDA_FA=ON \
  -DCMAKE_BUILD_TYPE=Release
cmake --build build -j

# Windows (MSVC + CUDA)
cmake -B build -DGGML_CUDA=ON -DGGML_NATIVE=ON ^
  -DGGML_CUDA_FA=ON ^
  -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release --parallel

# macOS (Metal)
cmake -B build -DGGML_METAL=ON -DCMAKE_BUILD_TYPE=Release
cmake --build build -j

The default CUDA FlashAttention build covers 50 standard cache pairs and 15 KVarN fast-decode pairs, including the homogeneous F16 and BF16 pairs needed by precision tails. Add -DGGML_CUDA_FA_ALL_QUANTS=ON to compile all 169 standard and 36 KVarN pairs, or -DGGML_CUDA_KVARN=OFF to build without KVarN kernels.

Other Backends

Bee inherits llama.cpp backend support, including Metal, HIP, Vulkan, SYCL, BLAS, CANN, MUSA, OpenVINO, OpenCL, and RPC. Use the upstream-style build docs in docs/build.md and backend-specific pages under docs/backend.

Common Commands

Local CLI

llama-cli -m model.gguf
llama-cli -m model.gguf -cnv --chat-template chatml
llama-cli -m model.gguf -n 256 --grammar-file grammars/json.gbnf -p "Request: schedule a call at 8pm; Command:"

OpenAI-Compatible Server

llama-server -m model.gguf --port 8080
llama-server -m model.gguf -c 16384 -np 4
llama-server -m model.gguf -md draft.gguf

DFlash Speculative Decoding

llama-server -m target.gguf --spec-type draft-dflash \
  --spec-draft-model drafter.gguf \
  --spec-draft-ngl all \
  --spec-dm-controller profit \
  --flash-attn on --cache-type-k q5_0 --cache-type-v q4_1

Keep the draft context on a standard cache type; KVarN is target-cache only.

KVarN Target Cache

# Balanced general starting point from the benchmark ladder
llama-server -m model.gguf --flash-attn on \
  --cache-type-k kvarn5 --cache-type-v kvarn4 \
  --kv-tail-tokens 1024

Router Mode With Presets

llama-server --models-dir /path/to/models
llama-server --models-preset presets.ini

Documentation

Contributing

Keep PRs small and scoped. Run the narrowest relevant tests or benchmarks before opening a PR, and include the exact commands. For fork-specific changes, update the corresponding docs when behavior or args change.

Read CONTRIBUTING.md for inherited llama.cpp contribution conventions and this fork's AI usage policy.

Dependencies

  • yhirose/cpp-httplib - HTTP client/server library used by llama-server - MIT
  • stb-image - single-header image decoder used by multimodal code - public domain
  • nlohmann/json - single-header JSON library - MIT
  • miniaudio.h - single-header audio decoder - public domain
  • subprocess.h - process launching helper - public domain
  • Intel OpenVINO - frontend header used in OpenVINO backend (ggml/src/ggml-openvino/openvino/frontend.h) - Apache-2.0
  • Intel SYCL/oneAPI - SYCL backend (ggml/src/ggml-sycl/) - Apache-2.0 WITH LLVM-exception

See the licenses/ directory for full license texts.

Support my work!

Contributors

(top 30 of 441)

ggerganov

1,937 commits

ngxson

587 commits

Anbeeld

571 commits

JohannesGaessler

392 commits

Rhonstin/beellama-cmp90hx

beellama.cpp fork with CMP 90HX (GA102, sm_86) optimizations: DP4A→IMAD, FP32→HFMA2 — +58-87% decode speed

12

stars

9,798

commits

C++

primary language

Sep 3, 2026

updated

Browse cluster: Local LLM Inference Optimization

README

Anbeeld's BeeLlama.cpp — CMP 90HX Edition

BeeLlama.cpp logo

BeeLlama.cpp (or just Bee) is a performance-focused llama.cpp fork for squeezing more speed and context out of local GGUF inference. It adds variance-normalized KV-cache quantization (KVarN), KV cache precision tail for recent tokens, low-bit cache types, adaptive draft control for speculative decoding, reasoning-loop protection, and more.

This fork additionally patches the CUDA backend for NVIDIA CMP 90HX (GA102, sm_86), replacing firmware-throttled instructions (DP4A, FP32 FFMA) with unthrottled equivalents (IMAD, HFMA2).

Not quite a pegasus, but close enough.


CMP 90HX Optimizations

The CMP 90HX (GA102, sm_86) has a firmware that throttles certain CUDA instructions:

InstructionLatencyStatus
FFMA / FADD / FMUL17.8 nsthrottled 14–15×
DP4A35.6 nsthrottled 29×
IMAD / IADD1.4 nsunthrottled
HFMA2 / HADD21.3–1.4 nsunthrottled
Tensor cores284.5 nsseverely throttled — disabled

Applied patches

PatchFileImpact
DP4A → PTX IMAD (4×mad.lo.s32)ggml/src/ggml-cuda/common.cuh+47.6% decode (42→62 tok/s)
FP32 dequant → HFMA2 (Q4_K, Q5_K)ggml/src/ggml-cuda/vecdotq.cuh+7.1% additional
FP32 dequant → HFMA2 (Q6_K, Q2_K)ggml/src/ggml-cuda/vecdotq.cuh+4.2% additional
fattn DKQ=512 → tile kernelggml/src/ggml-cuda/fattn.cucrash fix for Gemma4

Cumulative gain vs unpatched: ~+58% on Q4_K models, ~+87% on dense Q4_K_XL models.

Benchmark data in bench/cmp90hx/. Future patch roadmap in FUTURE_PATCHES.md.

Build for CMP 90HX

cmake -B build -DGGML_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=86 \
  -DGGML_CUDA_FA=ON -DGGML_CUDA_FA_ALL_QUANTS=ON \
  -DCMAKE_BUILD_TYPE=Release
cmake --build build -j$(nproc) --target llama-bench llama-server

Support my work!

Fork Features

  • Variance-normalized KV-cache quantization (KVarN): provides higher precision at similar memory costs. Independent K and V bit widths at kvarn2, kvarn3, kvarn4, kvarn5, kvarn6, and kvarn8, set with --cache-type-k and --cache-type-v.
  • KV cache precision tail: keep most of the KV cache quantized while storing recent tokens in F16/BF16, enabled with --kv-tail-tokens. A single global softmax merges the quantized body and the precision tail under FlashAttention, without materializing the whole cache.
  • Standard low-bit KV cache types: q2_0, q2_1, q3_0, q3_1, q6_0, and q6_1, usable for either target or draft caches alongside the upstream q4/q5/q8 types.
  • Adaptive draft-max for DFlash: adjusts the active DFlash draft horizon at runtime instead of using a fixed --spec-draft-n-max, comparing speculative throughput against a no-spec baseline.
  • Reasoning-loop protection: the server detects repeated hidden reasoning output and intervenes.

For the full feature and public-repo comparison, read docs/beellama-features.md. For the complete argument reference, read docs/beellama-args.md.

KV Cache Quantization

K and V cache types are set independently with --cache-type-k and --cache-type-v. The research is covered in articles: KVarN KV Cache: Implementation and Benchmarks, KV Cache Precision Tail: Implementation and Benchmarks, and KV Cache Quantization Benchmarks: KVarN, Precision Tail.

KV Cache Recommenation Ladder

The measurements come from Qwen 3.6 27B Q5_K_S at 64K context on Wikitext-2 raw with -b 2048 -ub 512 on an RTX 3090. Median KLD is the primary quality metric; lower is better.

K / VTailSizeSize vs bf16Median KLD99.9% KLDWhat it is for
bf16 / bf1604096 MiB100.0%00.000050Reference
q8_0 / q8_010242272 MiB55.5%0.0008970.087699Standard fidelity with a precision tail
kvarn8 / kvarn810242256 MiB55.1%0.0008710.087639Best measured quality below BF16
q8_0 / q8_002176 MiB53.1%0.0009090.093029Standard fidelity
q8_0 / q6_010242016 MiB49.2%0.0008940.091098q8_0 quality within noise, 256 MiB less
kvarn6 / kvarn610241744 MiB42.6%0.0008790.084629High-end value pick
kvarn6 / kvarn510241616 MiB39.5%0.0008860.092778Much cheaper, almost as good
kvarn5 / kvarn510241488 MiB36.3%0.0008970.087666Highest value in the mid-range
q5_0 / q4_110241440 MiB35.2%0.0009660.089128Standard option when VRAM-constrained
kvarn5 / kvarn410241360 MiB33.2%0.0009360.089469Balanced default
q4_0 / q4_010241248 MiB30.5%0.0010570.104486Compact standard cache
kvarn4 / kvarn410241232 MiB30.1%0.0009940.090391Cleaner than q4_0 for less memory
kvarn4 / kvarn310241104 MiB27.0%0.0011120.113968Smallest recommended tier
kvarn3 / kvarn31024976 MiB23.8%0.0013160.139558When the context must fit
kvarn3 / kvarn21024848 MiB20.7%0.0024240.238780Emergency compression
kvarn2 / kvarn21024720 MiB17.6%0.0038110.450496Last resort

A 1024-token tail is a useful starting point for low-bit Qwen caches. Prefer more body precision when old and recent tokens matter equally; consider 2048 only when the newest two thousand tokens are genuinely the privileged working set. Standard caches generally have slightly faster prefill.

Gemma 4 needs a separate decision. Its 1024-token sliding window makes a 1024 tail exact across most layers, sharply changing memory and throughput. Standard q8_0 / q8_0 without a tail is the safer Gemma default when throughput and older-context coverage matter, and the benchmark results recommend avoiding quantized KV cache when Gemma quality is non-negotiable.

Standard-Only KV Cache Ladder

Use this generic fallback ladder when KVarN or precision tails are unavailable. It is based on the same Qwen 3.6 27B benchmark, with every standard cache row using tail 0.

K / VSizeSize vs bf16Median KLD99.9% KLDWhat it is for
bf16 / bf164096 MiB100.0%00.000050Reference
q8_0 / q8_02176 MiB53.1%0.0009090.093029Compression with minimal losses
q8_0 / q6_01920 MiB46.9%0.0009370.093575256 MiB below q8_0
q6_0 / q6_01664 MiB40.6%0.0009600.091134High-end value pick
q6_0 / q5_01536 MiB37.5%0.0010540.094670Balanced default
q5_0 / q5_01408 MiB34.4%0.0011540.097070Last tier before the cliff
q5_0 / q4_11344 MiB32.8%0.0014330.122096Default when VRAM-constrained
q5_0 / q4_01280 MiB31.3%0.0015160.12106864 MiB cheaper, worse median
q4_0 / q4_01152 MiB28.1%0.0018460.154408Smallest recommended tier
q4_0 / q3_01024 MiB25.0%0.0033130.218912When the context must fit
q3_0 / q3_0896 MiB21.9%0.0046960.304186Emergency compression
q2_0 / q2_0640 MiB15.6%0.0193741.198902Last resort

KV Cache Type Reference

All KV cache types available in BeeLlama
TypeOriginbpvSize vs bf16
q8_0upstream8.553.1%
kvarn8Huawei / fork8.37552.3%
q6_1fork7.043.8%
q6_0fork6.540.6%
kvarn6Huawei / fork6.37539.8%
q5_1upstream6.037.5%
q5_0upstream5.534.4%
kvarn5Huawei / fork5.37533.6%
q4_1upstream5.031.3%
q4_0upstream4.528.1%
iq4_nlupstream4.528.1%
kvarn4Huawei / fork4.37527.3%
q3_1fork4.025.0%
q3_0fork3.521.9%
kvarn3Huawei / fork3.37521.1%
q2_1fork3.018.8%
q2_0fork2.515.6%
kvarn2Huawei / fork2.37514.8%

Standard ratios come directly from each block format. KVarN ratios describe the compressed record body, including scale and zero-point metadata; the permanent exact sink, exact suffix, staging, and alignment add overhead.

Installation

Prebuilt

Current release binaries are on the releases page.

PlatformBackendAsset suffix
macOS arm64Metalbin-macos-arm64.tar.gz
Ubuntu x64CPUbin-ubuntu-x64.tar.gz
Ubuntu arm64CPUbin-ubuntu-arm64.tar.gz
Ubuntu x64CUDA 12.4bin-ubuntu-cuda-12.4-x64.tar.gz
Ubuntu x64CUDA 13.3bin-ubuntu-cuda-13.3-x64.tar.gz
Ubuntu x64Vulkanbin-ubuntu-vulkan-x64.tar.gz
Ubuntu x64ROCm 7.2bin-ubuntu-rocm-7.2-x64.tar.gz
Ubuntu x64SYCLbin-ubuntu-sycl-x64.tar.gz
Windows x64CPUbin-win-cpu-x64.zip
Windows x64Vulkanbin-win-vulkan-x64.zip
Windows x64SYCLbin-win-sycl-x64.zip
Windows x64CUDA 12.4bin-win-cuda-12.4-x64.zip
Windows x64CUDA 13.3bin-win-cuda-13.3-x64.zip
Windows x64HIP/Radeonbin-win-hip-radeon-x64.zip

Windows CUDA archives contain a ggml-cuda.dll backend; download the matching beellama-<version>-cudart-win-cuda-*-x64.zip runtime archive and extract it into the same folder. Windows SYCL and HIP archives ship as standalone packages with all required runtime DLLs bundled.

Docker images are published to ghcr.io/anbeeld/beellama.cpp:

ImageAccelerationPlatforms
server, server-cpuCPUlinux/amd64, linux/arm64
server-cuda, server-cuda12CUDA 12.4linux/amd64
server-cuda13CUDA 13.3linux/amd64
server-rocmROCmlinux/amd64
server-vulkanVulkanlinux/amd64
server-syclSYCLlinux/amd64

Building from source with -DGGML_NATIVE=ON may result in a tiny bit better performance, so it might still be a good idea to do that if/when you decide to use this fork long-term.

CUDA Build

# Linux (GCC + CUDA)
cmake -B build -DGGML_CUDA=ON -DGGML_NATIVE=ON \
  -DGGML_CUDA_FA=ON \
  -DCMAKE_BUILD_TYPE=Release
cmake --build build -j

# Windows (MSVC + CUDA)
cmake -B build -DGGML_CUDA=ON -DGGML_NATIVE=ON ^
  -DGGML_CUDA_FA=ON ^
  -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release --parallel

# macOS (Metal)
cmake -B build -DGGML_METAL=ON -DCMAKE_BUILD_TYPE=Release
cmake --build build -j

The default CUDA FlashAttention build covers 50 standard cache pairs and 15 KVarN fast-decode pairs, including the homogeneous F16 and BF16 pairs needed by precision tails. Add -DGGML_CUDA_FA_ALL_QUANTS=ON to compile all 169 standard and 36 KVarN pairs, or -DGGML_CUDA_KVARN=OFF to build without KVarN kernels.

Other Backends

Bee inherits llama.cpp backend support, including Metal, HIP, Vulkan, SYCL, BLAS, CANN, MUSA, OpenVINO, OpenCL, and RPC. Use the upstream-style build docs in docs/build.md and backend-specific pages under docs/backend.

Common Commands

Local CLI

llama-cli -m model.gguf
llama-cli -m model.gguf -cnv --chat-template chatml
llama-cli -m model.gguf -n 256 --grammar-file grammars/json.gbnf -p "Request: schedule a call at 8pm; Command:"

OpenAI-Compatible Server

llama-server -m model.gguf --port 8080
llama-server -m model.gguf -c 16384 -np 4
llama-server -m model.gguf -md draft.gguf

DFlash Speculative Decoding

llama-server -m target.gguf --spec-type draft-dflash \
  --spec-draft-model drafter.gguf \
  --spec-draft-ngl all \
  --spec-dm-controller profit \
  --flash-attn on --cache-type-k q5_0 --cache-type-v q4_1

Keep the draft context on a standard cache type; KVarN is target-cache only.

KVarN Target Cache

# Balanced general starting point from the benchmark ladder
llama-server -m model.gguf --flash-attn on \
  --cache-type-k kvarn5 --cache-type-v kvarn4 \
  --kv-tail-tokens 1024

Router Mode With Presets

llama-server --models-dir /path/to/models
llama-server --models-preset presets.ini

Documentation

Contributing

Keep PRs small and scoped. Run the narrowest relevant tests or benchmarks before opening a PR, and include the exact commands. For fork-specific changes, update the corresponding docs when behavior or args change.

Read CONTRIBUTING.md for inherited llama.cpp contribution conventions and this fork's AI usage policy.

Dependencies

  • yhirose/cpp-httplib - HTTP client/server library used by llama-server - MIT
  • stb-image - single-header image decoder used by multimodal code - public domain
  • nlohmann/json - single-header JSON library - MIT
  • miniaudio.h - single-header audio decoder - public domain
  • subprocess.h - process launching helper - public domain
  • Intel OpenVINO - frontend header used in OpenVINO backend (ggml/src/ggml-openvino/openvino/frontend.h) - Apache-2.0
  • Intel SYCL/oneAPI - SYCL backend (ggml/src/ggml-sycl/) - Apache-2.0 WITH LLVM-exception

See the licenses/ directory for full license texts.

Support my work!

Contributors

(top 30 of 441)

ggerganov

1,937 commits

ngxson

587 commits

Anbeeld

571 commits

JohannesGaessler

392 commits

Languages

C++

56.6%

C

14.6%

Python

7.3%

Cuda

6.6%

TypeScript

4.0%

Svelte

2.1%

HTML

2.0%

Metal

1.4%

Jinja

1.1%