简报·YT
← 返回 GitHub 动态
ggerganov/llama.cpp · 📌 手动指定 已完成

ggerganov/llama.cpp v0.4.0

2026-09-04 19:56 · ⭐ 12.7万 · GitHub Release 原文 ↗
#大版本更新 #新模型 #推理引擎

ggerganov/llama.cpp v0.4.0

llama.cpp 0.4.0 是向 1.0 迈进的一个重要版本,首次引入 Qwen3.8-Flash-Next(qwen4exp)和 Nemotron-3-Puzzle 架构支持,带来按需张量读取、服务器每槽位上下文限制、视频输入选项,并将底层 ggml 升级至 0.23.0(包含稀疏 Flash Attention 与 Apple RDMA 等重大底层改进)。

▸ Release Notes 英文原文(21005 字符)
## Overview llama.cpp 0.4.0 adds initial Qwen3.8-Flash-Next and Nemotron-3-Puzzle support, on-demand tensor reading, per-slot server context limits, video input options, and a ggml update to 0.23.0 with major sparse flash attention and RDMA work. ### API changes - Added `llama_lazy_mode` and `lazy_mode` ([#27794](https://github.com/ggml-org/llama.cpp/pull/27794)). - Added `max_buf_size` to quantize params ([#27795](https://github.com/ggml-org/llama.cpp/pull/27795)). - Bumped session/state versions for KV-cell token tracking ([#27762](https://github.com/ggml-org/llama.cpp/pull/27762)). - Added `mtmd_input_part` and `mtmd_tokenize_from_parts()` ([#28250](https://github.com/ggml-org/llama.cpp/pull/28250)). - Made `mtmd_tokenize` const-correct ([#28310](https://github.com/ggml-org/llama.cpp/pull/28310)). - Made `mtmd_bitmap_init_lazy` const-correct ([#28307](https://github.com/ggml-org/llama.cpp/pull/28307)). - Added mtmd helper video/init options ([#24318](https://github.com/ggml-org/llama.cpp/pull/24318)). - Server multimodal helpers accept `mtmd_helper_init_opt` ([#24318](https://github.com/ggml-org/llama.cpp/pull/24318)). ### New models - Added initial Qwen3.8-Flash-Next (`qwen4exp`) architecture support; optimization improvements are still pending ([#27742](https://github.com/ggml-org/llama.cpp/pull/27742)). - Added NVIDIA Nemotron-3-Puzzle-75B-A9B support ([#25444](https://github.com/ggml-org/llama.cpp/pull/25444)). - Added DSpark support for Nemotron 3.5 ([#27804](https://github.com/ggml-org/llama.cpp/pull/27804)). - Added support for nanbeige4.2-3B ([#27730](https://github.com/ggml-org/llama.cpp/pull/27730)). ### Core changes - Added lazy tensor reading ([#27794](https://github.com/ggml-org/llama.cpp/pull/27794)). - Renamed option to `--lazy-mode` ([#27969](https://github.com/ggml-org/llama.cpp/pull/27969)). - Added `--n-cpu-ffn` ([#26622](https://github.com/ggml-org/llama.cpp/pull/26622)). - Added per-layer expert routing/FFN ([#28323](https://github.com/ggml-org/llama.cpp/pull/28323)). - Added KV-cell token tracking ([#27762](https://github.com/ggml-org/llama.cpp/pull/27762)). - Added n-gram history lookup ([#28040](https://github.com/ggml-org/llama.cpp/pull/28040)). - Optimized KV cache restore ([#27991](https://github.com/ggml-org/llama.cpp/pull/27991)). - Stopped early sequence scans ([#28011](https://github.com/ggml-org/llama.cpp/pull/28011)). - Added quantizer RAM cap ([#27795](https://github.com/ggml-org/llama.cpp/pull/27795)). - Added quantizer row-slab streaming ([#27830](https://github.com/ggml-org/llama.cpp/pull/27830)). - Prevented RAM peaking during load ([#27483](https://github.com/ggml-org/llama.cpp/pull/27483)). - Autoscaled YaRN training context ([#28030](https://github.com/ggml-org/llama.cpp/pull/28030)). - Disabled non-fused GDN/LID ([#27877](https://github.com/ggml-org/llama.cpp/pull/27877)). - Simplified MiniMax-01 graph ([#27790](https://github.com/ggml-org/llama.cpp/pull/27790)). - Added DFlash2 support ([#27816](https://github.com/ggml-org/llama.cpp/pull/27816)). - Fused DFlash encoder into KV injection ([#27310](https://github.com/ggml-org/llama.cpp/pull/27310)). - Added sparse flash attention for DeepSeek-V4/GLM and Qwen4exp ([#27970](https://github.com/ggml-org/llama.cpp/pull/27970)). - Added Apple RDMA as an RPC transport ([#26421](https://github.com/ggml-org/llama.cpp/pull/26421)). - Added RPC event/async backend APIs ([#18626](https://github.com/ggml-org/llama.cpp/pull/18626)). - Fixed Qwen4exp graph issues ([#27941](https://github.com/ggml-org/llama.cpp/pull/27941)). - Added Qwen4exp recurrent rollback ([#28123](https://github.com/ggml-org/llama.cpp/pull/28123)). - Summed Qwen4exp indexer heads ([#28023](https://github.com/ggml-org/llama.cpp/pull/28023)). - Reduced Qwen4exp graph splits ([#27880](https://github.com/ggml-org/llama.cpp/pull/27880)). - Fixed DeepSeek-V4 input vision ([#28154](https://github.com/ggml-org/llama.cpp/pull/28154)). - Fixed Gemma-4 vision handling ([#28335](https://github.com/ggml-org/llama.cpp/pull/28335)). - Fixed Gemma-4 assistant ([#28183](https://github.com/ggml-org/llama.cpp/pull/28183)). - Added synthetic spec acceptance options ([#27711](https://github.com/ggml-org/llama.cpp/pull/27711)). - Made build info stream configurable ([#28322](https://github.com/ggml-org/llama.cpp/pull/28322)). - Fixed JSON-schema empty object grammar ([#28279](https://github.com/ggml-org/llama.cpp/pull/28279)). ### Multi-modality changes - Added `mtmd_tokenize_from_parts()` ([#28250](https://github.com/ggml-org/llama.cpp/pull/28250)). - Added DeepSeek-V4-Flash-Vision-Exp ([#28133](https://github.com/ggml-org/llama.cpp/pull/28133)). - Added DeepSeek-V4 input vision handling ([#28154](https://github.com/ggml-org/llama.cpp/pull/28154)). - Fixed Gemma-4 vision handling ([#28335](https://github.com/ggml-org/llama.cpp/pull/28335)). - Fixed Idefics3 preprocessing ([#28273](https://github.com/ggml-org/llama.cpp/pull/28273)). - Fixed Qwen3-TTS ([#28231](https://github.com/ggml-org/llama.cpp/pull/28231)). - Added video parameters/`--video-*` ([#24318](https://github.com/ggml-org/llama.cpp/pull/24318)). - Made image preprocessors const-correct ([#28310](https://github.com/ggml-org/llama.cpp/pull/28310)). - Made audio preprocessors const-correct ([#28307](https://github.com/ggml-org/llama.cpp/pull/28307)). ### Server changes - Added per-slot context limit ([#24124](https://github.com/ggml-org/llama.cpp/pull/24124)). - Accept `data:` URLs for media ([#27735](https://github.com/ggml-org/llama.cpp/pull/27735)). - Enabled `preserve_reasoning` by default ([#28174](https://github.com/ggml-org/llama.cpp/pull/28174)). - Reject prefilled assistant tool calls ([#27626](https://github.com/ggml-org/llama.cpp/pull/27626)). - Added synthetic spec acceptance options ([#27711](https://github.com/ggml-org/llama.cpp/pull/27711)). - Added pytest-xdist server tests ([#28298](https://github.com/ggml-org/llama.cpp/pull/28298)). ### UI changes - Improved Chat Form Actions UI/UX ([#27746](https://github.com/ggml-org/llama.cpp/pull/27746)). - Replaced MCP overrides with tool policy ([#27745](https://github.com/ggml-org/llama.cpp/pull/27745)). - Moved Settings/MCP routes to dialogs ([#27744](https://github.com/ggml-org/llama.cpp/pull/27744)). - Updated dialog styling ([#27743](https://github.com/ggml-org/llama.cpp/pull/27743)). - Copy grouped agentic response text ([#27832](https://github.com/ggml-org/llama.cpp/pull/27832)). - Updated ESLint config ([#27700](https://github.com/ggml-org/llama.cpp/pull/27700)). - Updated package scripts ([#28270](https://github.com/ggml-org/llama.cpp/pull/28270)). ### ggml changes - Bumped ggml from v0.22.0 to v0.23.0 ([release](https://github.com/ggml-org/ggml/releases/tag/v0.23.0)). Version 0.23.0 adds new operators and backend scheduling APIs for sparse attention, asynchronous execution, and allocation-dependency tracking. The most notable additions are sparse flash attention (`ggml_flash_attn_ext_set_n_kv_max`), RPC event/async APIs, and Apple RDMA transport support. It also includes broad correctness and performance work across CPU, GPU, and accelerator backends. ## Assets **Nightly build:** [b10809](https://github.com/ggml-org/llama.cpp/releases/tag/b10809) ## More info - [Releases and versioning of `ggml-org` projects](https://github.com/ggml-org/ggml/discussions/1579) ## Changelog since v0.3.0 5266f24da llama.cpp : bump version to 0.4.0 (#28386) 64a155d24 sync : ggml (#28379) 163a40796 model, mtmd: fix gemma4 vision handling (#28335) 8f83678fd metal : add remaining fa-vec tunings for M3 Max (#28373) 86b351fd6 ggml : replace compile definitions with version.h.in (#28364) d509cb1e8 Don't use npx inside a package.json script (#28270) 4cbe8b070 ggml : don't crash when backend search path can't be read (#28271) 24f5bf8a4 ggml : remove GGML_CUDA_PEER_MAX_BATCH_SIZE (#28177) a529af96e docs : update maintainer PRs link and regenerate AUTHORS (#28365) 38521ec33 vendor: update BoringSSL to 0.20260903.0 (#28354) 0ef4d560e ci : disable failing openvino tests (#28347) c390d0abb common : make build info output stream configurable (#28322) 832fd6f17 ggml-cpu(s390x) : fix q5_1 uninitialized v_acc (#28332) 9a4843cf2 src : add n_expert_used_max function (#28323) 6703d7894 sycl: fuse rms_norm+mul+add and add+add residual chains (#27610) f9f09f02c SYCL: Refactor GGML_SYCL_ENABLE_MKL_FA to global var (#26863) d230ddd76 llama: fix whole source code rebuilt on each new commit (#28278) c5a5535e6 common/json-schema : fix GBNF grammar generation for empty object schemas (#28279) 95ef7fc16 opencl: quant lm_head / decode GEMV and medium-batch GEMM optimizations (speculative decoding/MTP) (#26477) 8c1a25166 tune MMVQ to MMQ crossover for SM87 (#28285) d30500b83 snapdragon: ci updates to use new run script (#28293) e107984bc ops: add Hexagon to ops.md and update main README.md (#28263) 42f0225fe server : use pytest-xdist for server tests (#28298) de8656bd9 mtmd: propagate const to preproc class (#28310) 7bb0fc18f metal : add sparse FA (#28098) 0df017d6d metal : fix glu dispatch with ne00 = 1 (#28306) f45576aa8 mtmd : add `const` in various places (#28307) 0ba6499c3 CUDA: Allow concurrent streams per split for multi-GPU (#28198) c7bda030e vulkan: fix FA dequant path engagement (#28190) 0df974d77 sycl : enhance the api to support peer-to-peer copy (#27550) d646c9d15 convert : skip bias_vl tensor in DeepSeek-V4 DSpark conversion (#28294) 5ec4eab69 misc : prevent RAM peaking at model loading stage (#27483) 4aa6ffba2 sycl: reduce redundant work in Q4_K multi-column MMVQ (#27062) c61b98b87 model: add NVIDIA Nemotron-3-Puzzle-75B-A9B (NemotronHPuzzle) support (#25444) 67a17c17c mtmd: fix idefics3 preproc (#28273) 159b74142 finetune: fix no KV cache (#27199) 9cffdcc80 server : accept data: URLs for input_video and input_audio (#27735) f027c4f1b ggml-hexagon: add F16 support for unary ops (#28228) 733905474 mtmd: add mtmd_tokenize_from_parts() (#28250) 9cc33944f metal : add fa-vec tunings for M3 (#28236) 8c0b9cd04 metal : fix memory query under low-memory conditions (#27701) 03dbcc53e ci : check for missing autoreleasepools (#27884) cff184438 Update ROCm to 10.0.0 release (#27803) 9400c8946 model: correctly support input vision for deepseek4 (#28154) d5fec32a8 ci : enable hf-jobs on server-cuda (#28258) 3d3d7c818 ggml-cuda : remove unused vars (#28235) e750b887a common, server : enable preserve_reasoning kwarg by default, log its effective state (#28174) 7798007a2 mtmd: support DeepSeek-V4-Flash-Vision-Exp (#28133) 8e93a9773 CUDA + ggml: add sparse-fa for DSV4/GLM (#27970) 0f3a71be1 mtmd: Fix Qwen3-tts-0.6b (#28231) b81c99b47 ggml: avoid KleidiAI buffer type init on dispatch (#27891) 960dffab0 hexagon: MUL_MAT and MUL_MAT_ID fusion and fixes (#28202) ba8818cbf vulkan: handle larger batch sizes (>4) efficiently for IQ3_S mat-vec (#27449) 56dd8150c vulkan : only request VK_KHR_shader_bfloat16 extension if supported (#28155) 2637dfe37 ggml-cpu : conditionally add SpacemiT IME kernel sources (#27961) 43d87ff2d opencl: fix out‐of‐bound reads in the Adreno image kernels (#27632) 69320fef1 hexagon: add missing FARF logs for cpy/get_rows/set_rows/gdn ops (#28217) b96806d96 metal : add metallib build support for xcframework (#28163) 3466812d1 cuda: fuse MoE weighted expert reduction (#25952) b356fa262 kv-cells: look up the n-gram history in the sequence position index (#28040) dfc29b64e context : autoscale n_ctx_train when yarn scaling specified (#28030) f28493c78 models : appropriately flag noscan ssm_a tensors (#28121) 73159c303 model : fix gemma4-assistant (#28183) d11b3cc7e model : load relevant arrays with n_layer_all (#28173) c845263f8 Revert "sycl : add Kronecker product FWHT support for sizes 384, 640, 768, 12…" (#28184) 1f3d31873 sycl : add Kronecker product FWHT support for sizes 384, 640, 768, 1280 (#28016) 8887a48f0 metal : add fa-vec tuning for M2 Pro (#28122) be789c344 metal : add fa-vec tunings for A18 Pro (MacBook Neo) (#28152) 9d817213a model : load hparams.n_layer_nextn before n_layer() calls (#28159) fe2120bc9 metal : fix more leaks due to missing autoreleasepools (#27883) d08c7872d metal : add fa-vec tuning for M2 Max (#28015) 5eec3ad01 sycl : support limit max alloc memory within 2GB for host-pinned memory (#27559) 36b101543 qwen4exp: fix seq_cp, block position keying, mtmd input, cuda abort, add tests (#27941) d086dbb34 tests : fix log verbosity for test-llama-archs (#28147) 1b89a43e3 quantize: row-slab stream to avoid thread starvation (#27830) d5d993a09 metal: enable Metal 4.0 tensor API on M5+/A19+ (#27461) 234a6ebaa ci: Bump ggml-org/ccache-action to v1.2.24 (#28083) 518b76236 kleidiai : Update KleidiAI Documentation (#26078) 0eadefebd qwen4exp: support recurrent state rollback (#28123) 09412af38 qwen4exp: sum the indexer heads by slices (#28023) 458681e1d metal : add fa-vec tunings for M1 Ultra (#28088) e4b9af007 CUDA: XOR swizzle flash attn K,V smem fp16 tiles (#25635) ab0b3bd3c metal : add concat support for quantized types (#28116) 85c55223c AVX2: Speed up large batch size prompt processing of IQ models (#27402) 2a74817f9 metal : add top-k radix implementation (#28073) 2d8d612e4 kv-cache : optimize restoring non-contiguous cells (#27991) 010be9683 opencl: tune the quant paths for Intel Xe-LP GPUs to improve its TG and PP performance (#26438) 774ee0e20 ui: copy the displayed text of grouped agentic responses (#27832) 8e53fcefd webgpu : avoid crash when offset is not multiple of 4 in WebGPU ggml_backend_tensor_get() implementation (#28045) f8dbcd618 ROCm: add radix TOP_K for long rows (#27466) 5d4a3be26 metal : add fa-vec tunings for M1 (#28078) 41ef91f7c CUDA: extend MOE fusion to specdec, earlier MOE glu fusion and topk-router fusion were restricted to 1 token (#27621) a32af33de sycl : Enhance to get the free memory of Intel GPU (#27968) 580e88d8b ci : add check for unzip (#28082) 662a0b012 spec : fuse the DFlash encoder into the KV cache injection (#27310) 2cdae802e vulkan: tune mat-vec rows for batched inference on Strix Halo (#27909) 557614e02 ggml : add MUL_MAT to the list of ops that may need additional memory (for WebGPU) (#28071) daef7b687 vulkan: top_k radix select for k >= 1024 for Qwen 3.8 Flash Next (#28032) 9723942ad hexagon: fix CPY fence bug (#28033) bd55e6aae metal : add remaining Q4_1/Q5_0/Q5_1 fa-vec tunings for M2 (#28017) a7cc83bba rpc: avoid serializing buffers from other servers (#26500) 6d1479c14 ggml : fix ggml_backend_buft_get_alloc_size() guard (#28038) 62acc89c2 kv-cells: stop the sequence scan once all sequences are seen (#28011) 0190529ec ggml: add SWIGLU_CLAMP (#27930) 257813839 llama: improve TENSOR_READ_LAZY handling (#27837) f1793c1c4 CUDA: use the fast mm_ids_helper path for any n_expert_used (#27978) 0b5be7e4a hip: tune rdna 3 mmq config (#26284) e42214804 hip : optimize Q2_0 dot-product path for gfx1201 (#26753) cc231cb0d dflash: pass missing NVFP4 scales to attention operations (#28000) bebc9350e common: rename --tensor-read-lazy to --lazy-mode, add -lzm shorthand (#27969) 73f56d105 ggml : add ggml_backend_op_alloc_size_may_expand, use it in RPC (#27960) 742347b2e rpc: fix apple rdma error spew on teardown (#27908) 093adb242 metal: add fa-vec tunings for M3 Ultra (#27999) b8b743c3c metal : Add fa-vec tuning for M3 Pro (#27963) dc7aecf70 vendor : update cpp-httplib to 0.54.0 (#27919) 2bf041515 rpc : fix pre-rdma macOS versions (#27815) 9e54e687c hexagon: support for device discovery and create sessions on demand (#27785) 370cb12e8 sycl: split long rows in TOP_K instead of one work-group per row (#27847) d882575cc metal : fix null-pipeline crash for F16 src1 mul_mat/mul_mat_id (#25648) bdf395515 memory : copy Hadamard matrix to k_rot tensor only if it has buffer assigned to prevent crashes during context shift of unquantized K cache (#27967) 57291f264 ggml: allow passing alloc dependencies in graph_optimize (#27301) c589f0ed1 metal : add fa-vec tunings for M2 (#27940) c841aeeb8 opencl: use a better matmul path on two Adreno GPU generations (#27640) 3173a5647 metal : assert shared memory padding (#27951) 17252c769 metal : add remaining fa-vec tunings for M4 Pro (#27915) cc83d7b48 sycl: make --fit respect --fit-target better (#27629) c9ca51c1f vulkan: combine duplicated fastdiv functions, rename the one optimizing small divs (#27526) 5ea1b124e metal : add fa-vec tunings for M1 Max (#27932) 77f132cb1 vulkan: Change mul_mat_id to pad K rather than N (#27925) d7bd3bfca snapdragon: python SDK setup (Windows) (#27903) 50f068fff bench: add --tensor-read-lazy (#27881) 6fe749801 model: qwen4exp: reduce number of graph splits (#27880) b387ddfd8 vulkan: fix missing view-alias dependencies in ggml_vk_graph_optimize (#27812) a43c3986b ggml : fix conv_transpose_2d for multiple batches (#26132) 90c26fcd4 Vulkan: add hoisting support for row IDs and expert count in shaders (#26686) 866322481 context : disable non-fused GDN and LID ops (#27877) f5e85d43a metal : add fa-vec tunings for M4 (#27875) 511f9c137 OpenVINO: Update OV to 2026.3.1, whisper.cpp support, Qwen3.5 on NPU, and new ops (#27843) b19cbe925 convert: prevent ndarray conversion in LazyChunkedTensor (#27869) d077b4c21 sycl: use TILE for quantized KV decode on BMG (#26689) be876204a sycl: bind the f16 KV cache in place for the oneDNN SDPA path (#27468) 8963a9bdc metal : add fa-vec tunings for M3 Max, M5 and M5 Pro (#27863) 6d6b697cd metal : add fa-vec tunings for M4 Pro (#27824) 4e97ac86e tests : run test-save-load-state across all architectures (#27755) ca3d5a3e1 model: add DSpark support for Nemotron3.5 (#27804) e70802a01 ggml-hexagon: add HTP unary ops for ABS and LOG (#27786) 83d855c5a hex-unary: fix RMS_NORM_MUL weight-offset bugs for grouped/broadcast norms (#27798) 18443257a server: add ctx-per-slot (--kv-unified-per-slot) (#24124) 32176338a ci : build only the ggml-hip backend for windows-rocm release (#27753) 6c84c7d5d model: add Qwen3.8-Flash-Next (qwen4exp) (#27742) 6fdd0ac89 ci : bundle HIP runtime DLLs with Windows ROCm release (#26973) b10f9ca58 spec : add DFlash2 support (local convolution + candidate selector) (#27342) (#27816) 58546250c opencl: add bin kernels `kernel_gemm_moe_q4_0_q8_1_dp4a_bin`, `kernel_gemm_moe_mxfp4_q8_1_dp4a_bin` (#27768) 732707dff quantize: cap working memory size to avoid loading big tensors onto RAM (#27795) cb300598d Feature: Added LIGHTNING_INDEXER support for Deepseek V4 ops on Vulkan Backend (#27453) 1a946ec74 pr2wt : use ssh/https remote in worktree depending on base (#27800) fac889fb3 llama: model_loader: add TENSOR_READ_LAZY (#27794) cae63579b ui: Improve Chat Form Actions UI/UX (models selector, add panel) (#27746) bcb6084a4 convert : fix Nemotron-H LoRA GGUF conversion (#27356) fe235f434 ui: Replace per-conversation MCP overrides with per-conversation tool policy (#27745) 2bb9bddaf spec: Add benchmark-only synthetic speculative acceptance options (#27711) deae5ee13 model : simplify MiniMax-01 graph (#27790) f29551215 args: add --video-* CLI arguments (#24318) 915dc6d38 metal : fix memory leaks due to missing autoreleasepools (#27758) c5fc7e348 llama : add --n-cpu-ffn option (#26622) d7a207411 models : support nanbeige4.2-3B (#27730) 192067b72 hexagon: support for multi-NPU devices (IQ9, IQ10) and fully asynchronous backend (#26501) 925e11799 llama: add token ID tracking to KV cell (#27762) 539f24529 ui: Move Settings and MCP Servers routes to dialog-based views (#27744) 0379a19f0 ui: Update Dialog component styling (#27743) 5e6a37cb1 vulkan: warptiles currently assume warp sizes <= 64, clamp to work around larger warps (#27726) bf9421646 Implemented vulkan cross_entropy_loss and cross_entropy_loss_back (#27216) d0132a680 rpc : implement event and async backend APIs (#18626) 4d19b2876 ci: Clean up UI builds from releases (#27706) fc35562ba cuda: unblock mmq for MoE on sm_60 (#26264) da9b5d68c ci : make cache bucket public (#27728) dac869b0a conversion : fix Nemotron 3.5 Lightning layers (#27729) 11cd98842 ggml-metal: add chunked SSD MMA for Mamba-2 prefill optimization (#26647) 5d5cb4c3a ggml-meta: propagate buffer usage and call init on the new tensors (#27586) d222767c7 kleidiai: Rework KleidiAI Build System/Integration (#26077) eab8ee41f ci : update OS used for ROCM to Ubuntu 24.04 (#27681) b114b4739 rpc: support apple RDMA as an RPC transport (#26421) 0a5ac49bc devops: use GGML_NATIVE=OFF for OpenVINO (#27338) 1729ed537 server : reject prefilled assistant messages with tool calls (#27626) 0cc5b1495 chat : scope qwen3-coder workarounds (#27679) 790b5713c ci : store ccache on HF buckets (test with cuda-ubuntu for now) (#27699) f1357e499 ui: ESLint config updates (#27700) 3737e4137 metal : null-check buffer alloc to fix OOM crash (#25371)
▸ 主项目介绍 · ggerganov/llama.cpp
▸ README 原文(同步于 2026-07-19 13:24)
# llama.cpp ![llama](https://raw.githubusercontent.com/ggml-org/llama.brand/refs/heads/master/cover/llama-cpp/cover-llama-cpp-dark.svg) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT) [![Release](https://img.shields.io/github/v/release/ggml-org/llama.cpp)](https://github.com/ggml-org/llama.cpp/releases) [![Server](https://github.com/ggml-org/llama.cpp/actions/workflows/server.yml/badge.svg)](https://github.com/ggml-org/llama.cpp/actions/workflows/server.yml) [![Docker](https://github.com/ggml-org/llama.cpp/actions/workflows/docker.yml/badge.svg)](https://github.com/ggml-org/llama.cpp/actions/workflows/docker.yml) [![Winget](https://github.com/ggml-org/llama.cpp/actions/workflows/winget.yml/badge.svg)](https://github.com/ggml-org/llama.cpp/actions/workflows/winget.yml) [Manifesto](https://github.com/ggml-org/llama.cpp/discussions/205) / [ggml](https://github.com/ggml-org/ggml) / [ops](https://github.com/ggml-org/llama.cpp/blob/master/docs/ops.md) / [maintainer PRs](https://github.com/ggml-org/llama.cpp/issues?q=is%3Apr%20is%3Aopen%20draft%3AFalse%20(author%3Argerganov%20OR%20author%3AKitaitiMakoto%20OR%20author%3Adanbev%20OR%20author%3Aaldehir%20OR%20author%3Amax-krasnyansky%20OR%20author%3ACISC%20OR%20author%3Aggerganov%20OR%20author%3Aam17an%20OR%20author%3Abartowski1182%20OR%20author%3Ahipudding%20OR%20author%3AServeurpersoCom%20OR%20author%3Apwilkin%20OR%20author%3Areeselevine%20OR%20author%3Angxson%20OR%20author%3Ajeffbolznv%20OR%20author%3A0cc4m%20OR%20author%3Aangt%20OR%20author%3AIMbackK%20OR%20author%3Aarthw%20OR%20author%3AJohannesGaessler%20OR%20author%3AORippler%20OR%20author%3Aruixiang63%20OR%20author%3Axctan%20OR%20author%3Aallozaur%20OR%20author%3Ayomaytk%20OR%20author%3Aaendk%20OR%20author%3Agaugarg-nv%20OR%20author%3Ataronaeo%20OR%20author%3Aforforever73%20OR%20author%3Alhez%20OR%20author%3Anetrunnereve%20OR%20author%3Afairydreaming)%20sort%3Aupdated-desc) LLM inference in C/C++ ## Recent API changes - [Changelog for `libllama` API](https://github.com/ggml-org/llama.cpp/issues/9289) - [Changelog for `llama-server` REST API](https://github.com/ggml-org/llama.cpp/issues/9291) ## Hot topics - **Hugging Face cache migration: models downloaded with `-hf` are now stored in the standard Hugging Face cache directory, enabling sharing with other HF tools.** - **[guide : using the new WebUI of llama.cpp](https://github.com/ggml-org/llama.cpp/discussions/16938)** - [guide : running gpt-oss with llama.cpp](https://github.com/ggml-org/llama.cpp/discussions/15396) - [[FEEDBACK] Better packaging for llama.cpp to support downstream consumers 🤗](https://github.com/ggml-org/llama.cpp/discussions/15313) - Support for the `gpt-oss` model with native MXFP4 format has been added | [PR](https://github.com/ggml-org/llama.cpp/pull/15091) | [Collaboration with NVIDIA](https://blogs.nvidia.com/blog/rtx-ai-garage-openai-oss) | [Comment](https://github.com/ggml-org/llama.cpp/discussions/15095) - Multimodal support arrived in `llama-server`: [#12898](https://github.com/ggml-org/llama.cpp/pull/12898) | [documentation](./docs/multimodal.md) - VS Code extension for FIM completions: https://github.com/ggml-org/llama.vscode - Vim/Neovim plugin for FIM completions: https://github.com/ggml-org/llama.vim - Hugging Face Inference Endpoints now support GGUF out of the box! https://github.com/ggml-org/llama.cpp/discussions/9669 - Hugging Face GGUF editor: [discussion](https://github.com/ggml-org/llama.cpp/discussions/9268) | [tool](https://huggingface.co/spaces/CISCai/gguf-editor) - WebGPU support is now available in the browser, see a blog/demo introducing it [here](https://reeselevine.github.io/llamas-on-the-web/). ---- ## Quick start Getting started with llama.cpp is straightforward. Here are several ways to install it on your machine: - Install `llama.cpp` using [brew, nix, winget, or conda-forge](docs/install.md) - Run with Docker - see our [Docker documentation](docs/docker.md) - Download pre-built binaries from the [releases page](https://github.com/ggml-org/llama.cpp/releases) - Build from source by cloning this repository - check out [our build guide](docs/build.md) Once installed, you'll need a model to work with. Head to the [Obtaining and quantizing models](#obtaining-and-quantizing-models) section to learn more. Example command: ```sh # Use a local model file llama-cli -m my_model.gguf # Or download and run a model directly from Hugging Face llama-cli -hf ggml-org/gemma-3-1b-it-GGUF # Launch OpenAI-compatible API server llama-server -hf ggml-org/gemma-3-1b-it-GGUF ``` ## Description The main goal of `llama.cpp` is to enable LLM 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 the main playground for developing new features for the [ggml](https://github.com/ggml-org/ggml) library. <details> <summary>Models</summary> Typically finetunes of the base models below are supported as well. Instructions for adding support for new models: [HOWTO-add-model.md](docs/development/HOWTO-add-model.md) #### Text-only - [X] LLaMA 🦙 - [x] LLaMA 2 🦙🦙 - [x] LLaMA 3 🦙🦙🦙 - [X] [Mistral 7B](https://huggingface.co/mistralai/Mistral-7B-v0.1) - [x] [Mixtral MoE](https://huggingface.co/models?search=mistral-ai/Mixtral) - [x] [DBRX](https://huggingface.co/databricks/dbrx-instruct) - [x] [Jamba](https://huggingface.co/ai21labs) - [X] [Falcon](https://huggingface.co/models?search=tiiuae/falcon) - [X] [Chinese LLaMA / Alpaca](https://github.com/ymcui/Chinese-LLaMA-Alpaca) and [Chinese LLaMA-2 / Alpaca-2](https://github.com/ymcui/Chinese-LLaMA-Alpaca-2) - [X] [Vigogne (French)](https://github.com/bofenghuang/vigogne) - [X] [BERT](https://github.com/ggml-org/llama.cpp/pull/5423) - [X] [Koala](https://bair.berkeley.edu/blog/2023/04/03/koala/) - [X] [Baichuan 1 & 2](https://huggingface.co/models?search=baichuan-inc/Baichuan) + [derivations](https://huggingface.co/hiyouga/baichuan-7b-sft) - [X] [Aquila 1 & 2](https://huggingface.co/models?search=BAAI/Aquila) - [X] [Starcoder models](https://github.com/ggml-org/llama.cpp/pull/3187) - [X] [Refact](https://huggingface.co/smallcloudai/Refact-1_6B-fim) - [X] [MPT](https://github.com/ggml-org/llama.cpp/pull/3417) - [X] [Bloom](https://github.com/ggml-org/llama.cpp/pull/3553) - [x] [Yi models](https://huggingface.co/models?search=01-ai/Yi) - [X] [StableLM models](https://huggingface.co/stabilityai) - [x] [Deepseek models](https://huggingface.co/models?search=deepseek-ai/deepseek) - [x] [Qwen models](https://huggingface.co/models?search=Qwen/Qwen) - [x] [PLaMo-13B](https://github.com/ggml-org/llama.cpp/pull/3557) - [x] [Phi models](https://huggingface.co/models?search=microsoft/phi) - [x] [PhiMoE](https://github.com/ggml-org/llama.cpp/pull/11003) - [x] [GPT-2](https://huggingface.co/gpt2) - [x] [Orion 14B](https://github.com/ggml-org/llama.cpp/pull/5118) - [x] [InternLM2](https://huggingface.co/models?search=internlm2) - [x] [CodeShell](https://github.com/WisdomShell/codeshell) - [x] [Gemma](https://ai.google.dev/gemma) - [x] [Mamba](https://github.com/state-spaces/mamba) - [x] [Grok-1](https://huggingface.co/keyfan/grok-1-hf) - [x] [Xverse](https://huggingface.co/models?search=xverse) - [x] [Command-R models](https://huggingface.co/models?search=CohereForAI/c4ai-command-r) - [x] [SEA-LION](https://huggingface.co/models?search=sea-lion) - [x] [GritLM-7B](https://huggingface.co/GritLM/GritLM-7B) + [GritLM-8x7B](https://huggingface.co/GritLM/GritLM-8x7B) - [x] [OLMo](https://allenai.org/olmo) - [x] [OLMo 2](https://allenai.org/olmo) - [x] [OLMoE](https://huggingface.co/allenai/OLMoE-1B-7B-0924) - [x] [Granite models](https://huggingface.co/collections/ibm-granite/granite-code-models-6624c5cec322e4c148c8b330) - [x] [GPT-NeoX](https://github.com/EleutherAI/gpt-neox) + [Pythia](https://github.com/EleutherAI/pythia) - [x] [Snowflake-Arctic MoE](https://huggingface.co/collections/Snowflake/arctic-66290090abe542894a5ac520) - [x] [Smaug](https://huggingface.co/models?search=Smaug) - [x] [Poro 34B](https://huggingface.co/LumiOpen/Poro-34B) - [x] [Bitnet b1.58 models](https://huggingface.co/1bitLLM) - [x] [Flan T5](https://huggingface.co/models?search=flan-t5) - [x] [Open Elm models](https://huggingface.co/collections/apple/openelm-instruct-models-6619ad295d7ae9f868b759ca) - [x] [ChatGLM3-6b](https://huggingface.co/THUDM/chatglm3-6b) + [ChatGLM4-9b](https://huggingface.co/THUDM/glm-4-9b) + [GLMEdge-1.5b](https://huggingface.co/THUDM/glm-edge-1.5b-chat) + [GLMEdge-4b](https://huggingface.co/THUDM/glm-edge-4b-chat) - [x] [GLM-4-0414](https://huggingface.co/collections/THUDM/glm-4-0414-67f3cbcb34dd9d252707cb2e) - [x] [SmolLM](https://huggingface.co/collections/HuggingFaceTB/smollm-6695016cad7167254ce15966) - [x] [EXAONE-3.0-7.8B-Instruct](https://huggingface.co/LGAI-EXAONE/EXAONE-3.0-7.8B-Instruct) - [x] [FalconMamba Models](https://huggingface.co/collections/tiiuae/falconmamba-7b-66b9a580324dd1598b0f6d4a) - [x] [Jais](https://huggingface.co/inceptionai/jais-13b-chat) - [x] [Bielik-11B-v2.3](https://huggingface.co/collections/speakleash/bielik-11b-v23-66ee813238d9b526a072408a) - [x] [RWKV-7](https://huggingface.co/collections/shoumenchougou/rwkv7-gxx-gguf) - [x] [RWKV-6](https://github.com/BlinkDL/RWKV-LM) - [x] [QRWKV-6](https://huggingface.co/recursal/QRWKV6-32B-Instruct-Preview-v0.1) - [x] [GigaChat-20B-A3B](https://huggingface.co/ai-sage/GigaChat-20B-A3B-instruct) - [X] [Trillion-7B-preview](https://huggingface.co/trillionlabs/Trillion-7B-preview) - [x] [Ling models](https://huggingface.co/collections/inclusionAI/ling-67c51c85b34a7ea0aba94c32) - [x] [Liquid LFM2 models](https://huggingface.co/collections/LiquidAI/lfm2) - [x] [Liquid LFM2.5 models](https://huggingface.co/collections/LiquidAI/lfm25) - [x] [Liquid Nanos](https://huggingface.co/collections/LiquidAI/liquid-nanos) - [x] [Hunyuan models](https://huggingface.co/collections/tencent/hunyuan-dense-model-6890632cda26b19119c9c5e7) - [x] [BailingMoeV2 (Ring/Ling 2.0) models](https://huggingface.co/collections/inclusionAI/ling-v2-68bf1dd2fc34c306c1fa6f86) - [x] [Mellum models](https://huggingface.co/JetBrains/models?search=mellum) #### Multimodal - [x] [LLaVA 1.5 models](https://huggingface.co/collections/liuhaotian/llava-15-653aac15d994e992e2677a7e), [LLaVA 1.6 models](https://huggingface.co/collections/liuhaotian/llava-16-65b9e40155f60fd046a5ccf2) - [x] [BakLLaVA](https://huggingface.co/models?search=SkunkworksAI/Bakllava) - [x] [Obsidian](https://huggingface.co/NousResearch/Obsidian-3B-V0.5) - [x] [ShareGPT4V](https://huggingface.co/models?search=Lin-Chen/ShareGPT4V) - [x] [MobileVLM 1.7B/3B models](https://huggingface.co/models?search=mobileVLM) - [x] [Yi-VL](https://huggingface.co/models?search=Yi-VL) - [x] [Mini CPM](https://huggingface.co/models?search=MiniCPM) - [x] [Moondream](https://huggingface.co/vikhyatk/moondream2) - [x] [Bunny](https://github.com/BAAI-DCAI/Bunny) - [x] [GLM-EDGE](https://huggingface.co/models?search=glm-edge) - [x] [Qwen2-VL](https://huggingface.co/collections/Qwen/qwen2-vl-66cee7455501d7126940800d) - [x] [LFM2-VL](https://huggingface.co/collections/LiquidAI/lfm2-vl-68963bbc84a610f7638d5ffa) </details> <details> <summary>Bindings</summary> - Python: [ddh0/easy-llama](https://github.com/ddh0/easy-llama) - Python: [abetlen/llama-cpp-python](https://github.com/abetlen/llama-cpp-python) - Go: [go-skynet/go-llama.cpp](https://github.com/go-skynet/go-llama.cpp) - Node.js: [withcatai/node-llama-cpp](https://github.com/withcatai/node-llama-cpp) - JS/TS (llama.cpp server client): [lgrammel/modelfusion](https://modelfusion.dev/integration/model-provider/llamacpp) - JS/TS (Programmable Prompt Engine CLI): [offline-ai/cli](https://github.com/offline-ai/cli) - JavaScript/Wasm (works in browser): [tangledgroup/llama-cpp-wasm](https://github.com/tangledgroup/llama-cpp-wasm) - Typescript/Wasm (nicer API, available on npm): [ngxson/wllama](https://github.com/ngxson/wllama) - Ruby: [yoshoku/llama_cpp.rb](https://github.com/yoshoku/llama_cpp.rb) - Ruby: [docusealco/rllama](https://github.com/docusealco/rllama) - Rust (more features): [edgenai/llama_cpp-rs](https://github.com/edgenai/llama_cpp-rs) - Rust (nicer API): [mdrokz/rust-llama.cpp](https://github.com/mdrokz/rust-llama.cpp) - Rust (more direct bindings): [utilityai/llama-cpp-rs](https://github.com/utilityai/llama-cpp-rs) - Rust (automated build from crates.io): [ShelbyJenkins/llm_client](https://github.com/ShelbyJenkins/llm_client) - C#/.NET: [SciSharp/LLamaSharp](https://github.com/SciSharp/LLamaSharp) - C#/VB.NET (more features - community license): [LM-Kit.NET](https://docs.lm-kit.com/lm-kit-net/index.html) - Scala 3: [donderom/llm4s](https://github.com/donderom/llm4s) - Clojure: [phronmophobic/llama.clj](https://github.com/phronmophobic/llama.clj) - React Native: [mybigday/llama.rn](https://github.com/mybigday/llama.rn) - Java: [kherud/java-llama.cpp](https://github.com/kherud/java-llama.cpp) - Java: [QuasarByte/llama-cpp-jna](https://github.com/QuasarByte/llama-cpp-jna) - Zig: [deins/llama.cpp.zig](https://github.com/Deins/llama.cpp.zig) - Flutter/Dart: [netdur/llama_cpp_dart](https://github.com/netdur/llama_cpp_dart) - Flutter: [xuegao-tzx/Fllama](https://github.com/xuegao-tzx/Fllama) - PHP (API bindings and features built on top of llama.cpp): [distantmagic/resonance](https://github.com/distantmagic/resonance) [(more info)](https://github.com/ggml-org/llama.cpp/pull/6326) - Guile Scheme: [guile_llama_cpp](https://savannah.nongnu.org/projects/guile-llama-cpp) - Swift [srgtuszy/llama-cpp-swift](https://github.com/srgtuszy/llama-cpp-swift) - Swift [ShenghaiWang/SwiftLlama](https://github.com/ShenghaiWang/SwiftLlama) - Delphi [Embarcadero/llama-cpp-delphi](https://github.com/Embarcadero/llama-cpp-delphi) - Go (no CGo needed): [hybridgroup/yzma](https://github.com/hybridgroup/yzma) - Android: [llama.android](/examples/llama.android) </details> <details> <summary>UIs</summary> *(to have a project listed here, it should clearly state that it depends on `llama.cpp`)* - [AI Sublime Text plugin](https://github.com/yaroslavyaroslav/OpenAI-sublime-text) (MIT) - [BonzAI App](https://apps.apple.com/us/app/bonzai-your-local-ai-agent/id6752847988) (proprietary) - [cztomsik/ava](https://github.com/cztomsik/ava) (MIT) - [Dot](https://github.com/alexpinel/Dot) (GPL) - [eva](https://github.com/ylsdamxssjxxdd/eva) (MIT) - [iohub/collama](https://github.com/iohub/coLLaMA) (Apache-2.0) - [janhq/jan](https://github.com/janhq/jan) (AGPL) - [johnbean393/Sidekick](https://github.com/johnbean393/Sidekick) (MIT) - [KanTV](https://github.com/zhouwg/kantv?tab=readme-ov-file) (Apache-2.0) - [KodiBot](https://github.com/firatkiral/kodibot) (GPL) - [llama.vim](https://github.com/ggml-org/llama.vim) (MIT) - [LARS](https://github.com/abgulati/LARS) (AGPL) - [Llama Assistant](https://github.com/vietanhdev/llama-assistant) (GPL) - [LlamaLib](https://github.com/undreamai/LlamaLib) (Apache-2.0) - [LLMFarm](https://github.com/guinmoon/LLMFarm?tab=readme-ov-file) (MIT) - [LLMUnity](https://github.com/undreamai/LLMUnity) (MIT) - [LMStudio](https://lmstudio.ai/) (proprietary) - [LocalAI](https://github.com/mudler/LocalAI) (MIT) - [LostRuins/koboldcpp](https://github.com/LostRuins/koboldcpp) (AGPL) - [MindMac](https://mindmac.app) (proprietary) - [MindWorkAI/AI-Studio](https://github.com/MindWorkAI/AI-Studio) (FSL-1.1-MIT) - [Mobile-Artificial-Intelligence/maid](https://github.com/Mobile-Artificial-Intelligence/maid) (MIT) - [Mozilla-Ocho/llamafile](https://github.com/Mozilla-Ocho/llamafile) (Apache-2.0) - [nat/openplayground](https://github.com/nat/openplayground) (MIT) - [nomic-ai/gpt4all](https://github.com/nomic-ai/gpt4all) (MIT) - [ollama/ollama](https://github.com/ollama/ollama) (MIT) - [oobabooga/text-generation-webui](https://github.com/oobabooga/text-generation-webui) (AGPL) - [PocketPal AI](https://github.com/a-ghorbani/pocketpal-ai) (MIT) - [psugihara/FreeChat](https://github.com/psugihara/FreeChat) (MIT) - [ptsochantaris/emeltal](https://github.com/ptsochantaris/emeltal) (MIT) - [pythops/tenere](https://github.com/pythops/tenere) (AGPL) - [ramalama](https://github.com/containers/ramalama) (MIT) - [semperai/amica](https://github.com/semperai/amica) (MIT) - [withcatai/catai](https://github.com/withcatai/catai) (MIT) - [Autopen](https://github.com/blackhole89/autopen) (GPL) </details> <details> <summary>Tools</summary> - [akx/ggify](https://github.com/akx/ggify) – download PyTorch models from Hugging Face Hub and convert them to GGML - [akx/ollama-dl](https://github.com/akx/ollama-dl) – download models from the Ollama library to be used directly with llama.cpp - [crashr/gppm](https://github.com/crashr/gppm) – launch llama.cpp instances utilizing NVIDIA Tesla P40 or P100 GPUs with reduced idle power consumption - [gpustack/gguf-parser](https://github.com/gpustack/gguf-parser-go/tree/main/cmd/gguf-parser) - review/check the GGUF file and estimate the memory usage - [Styled Lines](https://marketplace.unity.com/packages/tools/generative-ai/styled-lines-llama-cpp-model-292902) (proprietary licensed, async wrapper of inference part for game development in Unity3d with pre-built Mobile and Web platform wrappers and a model example) - [unslothai/unsloth](https://github.com/unslothai/unsloth) – 🦥 exports/saves fine-tuned and trained models to GGUF (Apache-2.0) </details> <details> <summary>Infrastructure</summary> - [Paddler](https://github.com/intentee/paddler) - Open-source LLMOps platform for hosting and scaling AI in your own infrastructure - [GPUStack](https://github.com/gpustack/gpustack) - Manage GPU clusters for running LLMs - [llama_cpp_canister](https://github.com/onicai/llama_cpp_canister) - llama.cpp as a smart contract on the Internet Computer, using WebAssembly - [llama-swap](https://github.com/mostlygeek/llama-swap) - transparent proxy that adds automatic model switching with llama-server - [Kalavai](https://github.com/kalavai-net/kalavai-client) - Crowdsource end to end LLM deployment at any scale - [llmaz](https://github.com/InftyAI/llmaz) - ☸️ Easy, advanced inference platform for large language models on Kubernetes. - [LLMKube](https://github.com/defilantech/llmkube) - Kubernetes operator for llama.cpp with multi-GPU and Apple Silicon Metal support" </details> <details> <summary>Games</summary> - [Lucy's Labyrinth](https://github.com/MorganRO8/Lucys_Labyrinth) - A simple maze game where agents controlled by an AI model will try to trick you. </details> ## Supported backends | Backend | Target devices | | --- | --- | | [Metal](docs/build.md#metal-build) | Apple Silicon | | [BLAS](docs/build.md#blas-build) | All | | [BLIS](docs/backend/BLIS.md) | All | | [SYCL](docs/backend/SYCL.md) | Intel GPU | | [OpenVINO [In Progress]](docs/backend/OPENVINO.md) | Intel CPUs, GPUs, and NPUs | | [MUSA](docs/build.md#musa) | Moore Threads GPU | | [CUDA](docs/build.md#cuda) | Nvidia GPU | | [HIP](docs/build.md#hip) | AMD GPU | | [ZenDNN](docs/build.md#zendnn) | AMD CPU | | [Vulkan](docs/build.md#vulkan) | GPU | | [CANN](docs/build.md#cann) | Ascend NPU | | [OpenCL](docs/backend/OPENCL.md) | Adreno GPU | | [IBM zDNN](docs/backend/zDNN.md) | IBM Z & LinuxONE | | [WebGPU](docs/build.md#webgpu) | All | | [RPC](https://github.com/ggml-org/llama.cpp/tree/master/tools/rpc) | All | | [Hexagon [In Progress]](docs/backend/snapdragon/README.md) | Snapdragon | | [VirtGPU](docs/backend/VirtGPU.md) | VirtGPU APIR | ## Obtaining and quantizing models The [Hugging Face](https://huggingface.co) platform hosts a [number of LLMs](https://huggingface.co/models?library=gguf&sort=trending) compatible with `llama.cpp`: - [Trending](https://huggingface.co/models?library=gguf&sort=trending) - [LLaMA](https://huggingface.co/models?sort=trending&search=llama+gguf) You can either manually download the GGUF file or directly use any `llama.cpp`-compatible models from [Hugging Face](https://huggingface.co/) or other model hosting sites, by using this CLI argument: `-hf <user>/<model>[:quant]`. For example: ```sh llama-cli -hf ggml-org/gemma-3-1b-it-GGUF ``` By default, the CLI would download from Hugging Face, you can switch to other options with the environment variable `MODEL_ENDPOINT`. The `MODEL_ENDPOINT` must point to a Hugging Face compatible API endpoint. After downloading a model, use the CLI tools to run it locally - see below. `llama.cpp` requires the model to be stored in the [GGUF](https://github.com/ggml-org/ggml/blob/master/docs/gguf.md) file format. Models in other data formats can be converted to GGUF using the `convert_*.py` Python scripts in this repo. The Hugging Face platform provides a variety of online tools for converting, quantizing and hosting models with `llama.cpp`: - Use the [GGUF-my-repo space](https://huggingface.co/spaces/ggml-org/gguf-my-repo) to convert to GGUF format and quantize model weights to smaller sizes - Use the [GGUF-my-LoRA space](https://huggingface.co/spaces/ggml-org/gguf-my-lora) to convert LoRA adapters to GGUF format (more info: https://github.com/ggml-org/llama.cpp/discussions/10123) - Use the [GGUF-editor space](https://huggingface.co/spaces/CISCai/gguf-editor) to edit GGUF meta data in the browser (more info: https://github.com/ggml-org/llama.cpp/discussions/9268) - Use the [Inference Endpoints](https://ui.endpoints.huggingface.co/) to directly host `llama.cpp` in the cloud (more info: https://github.com/ggml-org/llama.cpp/discussions/9669) To learn more about model quantization, [read this documentation](tools/quantize/README.md) ## [`llama-cli`](tools/cli) #### A CLI tool for accessing and experimenting with most of `llama.cpp`'s functionality. - <details open> <summary>Run in conversation mode</summary> Models with a built-in chat template will automatically activate conversation mode. If this doesn't occur, you can manually enable it by adding `-cnv` and specifying a suitable chat template with `--chat-template NAME` ```bash llama-cli -m model.gguf # > hi, who are you? # Hi there! I'm your helpful assistant! I'm an AI-powered chatbot designed to assist and provide information to users like you. I'm here to help answer your questions, provide guidance, and offer support on a wide range of topics. I'm a friendly and knowledgeable AI, and I'm always happy to help with anything you need. What's on your mind, and how can I assist you today? # # > what is 1+1? # Easy peasy! The answer to 1+1 is... 2! ``` </details> - <details> <summary>Run in conversation mode with custom chat template</summary> ```bash # use the "chatml" template (use -h to see the list of supported templates) llama-cli -m model.gguf -cnv --chat-template chatml # use a custom template llama-cli -m model.gguf -cnv --in-prefix 'User: ' --reverse-prompt 'User:' ``` </details> - <details> <summary>Constrain the output with a custom grammar</summary> ```bash llama-cli -m model.gguf -n 256 --grammar-file grammars/json.gbnf -p 'Request: schedule a call at 8pm; Command:' # {"appointmentTime": "8pm", "appointmentDetails": "schedule a a call"} ``` The [grammars/](grammars/) folder contains a handful of sample grammars. To write your own, check out the [GBNF Guide](grammars/README.md). For authoring more complex JSON grammars, check out https://grammar.intrinsiclabs.ai/ </details> ## [`llama-server`](tools/server) #### A lightweight, [OpenAI API](https://github.com/openai/openai-openapi) compatible, HTTP server for serving LLMs. - <details open> <summary>Start a local HTTP server with default configuration on port 8080</summary> ```bash llama-server -m model.gguf --port 8080 # Basic web UI can be accessed via browser: http://localhost:8080 # Chat completion endpoint: http://localhost:8080/v1/chat/completions ``` </details> - <details> <summary>Support multiple-users and parallel decoding</summary> ```bash # up to 4 concurrent requests, each with 4096 max context llama-server -m model.gguf -c 16384 -np 4 ``` </details> - <details> <summary>Enable speculative decoding</summary> ```bash # the draft.gguf model should be a small variant of the target model.gguf llama-server -m model.gguf -md draft.gguf ``` </details> - <details> <summary>Serve an embedding model</summary> ```bash # use the /embedding endpoint llama-server -m model.gguf --embedding --pooling cls -ub 8192 ``` </details> - <details> <summary>Serve a reranking model</summary> ```bash # use the /reranking endpoint llama-server -m model.gguf --reranking ``` </details> - <details> <summary>Constrain all outputs with a grammar</summary> ```bash # custom grammar llama-server -m model.gguf --grammar-file grammar.gbnf # JSON llama-server -m model.gguf --grammar-file grammars/json.gbnf ``` </details> ## [`llama-perplexity`](tools/perplexity) #### A tool for measuring the [perplexity](tools/perplexity/README.md) [^1] (and other quality metrics) of a model over a given text. - <details open> <summary>Measure the perplexity over a text file</summary> ```bash llama-perplexity -m model.gguf -f file.txt # [1]15.2701,[2]5.4007,[3]5.3073,[4]6.2965,[5]5.8940,[6]5.6096,[7]5.7942,[8]4.9297, ... # Final estimate: PPL = 5.4007 +/- 0.67339 ``` </details> - <details> <summary>Measure KL divergence</summary> ```bash # TODO ``` </details> [^1]: [https://huggingface.co/docs/transformers/perplexity](https://huggingface.co/docs/transformers/perplexity) ## [`llama-bench`](tools/llama-bench) #### Benchmark the performance of the inference for various parameters. - <details open> <summary>Run default benchmark</summary> ```bash llama-bench -m model.gguf # Output: # | model | size | params | backend | threads | test | t/s | # | ------------------- | ---------: | ---------: | ---------- | ------: | ------------: | -------------------: | # | qwen2 1.5B Q4_0 | 885.97 MiB | 1.54 B | Metal,BLAS | 16 | pp512 | 5765.41 ± 20.55 | # | qwen2 1.5B Q4_0 | 885.97 MiB | 1.54 B | Metal,BLAS | 16 | tg128 | 197.71 ± 0.81 | # # build: 3e0ba0e60 (4229) ``` </details> ## [`llama-simple`](examples/simple) #### A minimal example for implementing apps with `llama.cpp`. Useful for developers. - <details> <summary>Basic text completion</summary> ```bash llama-simple -m model.gguf # Hello my name is Kaitlyn and I am a 16 year old girl. I am a junior in high school and I am currently taking a class called "The Art of ``` </details> ## 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! - See [good first issues](https://github.com/ggml-org/llama.cpp/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) for tasks suitable for first contributions - Read the [CONTRIBUTING.md](CONTRIBUTING.md) for more information - Make sure to read this: [Inference at the edge](https://github.com/ggml-org/llama.cpp/discussions/205) - A bit of backstory for those who are interested: [Changelog podcast](https://changelog.com/podcast/532) ## Other documentation - [cli](tools/cli/README.md) - [completion](tools/completion/README.md) - [server](tools/server/README.md) - [GBNF grammars](grammars/README.md) #### Development documentation - [How to build](docs/build.md) - [Running on Docker](docs/docker.md) - [Build on Android](docs/android.md) - [Multi-GPU usage](docs/multi-gpu.md) - [Performance troubleshooting](docs/development/token_generation_performance_tips.md) - [GGML tips & tricks](https://github.com/ggml-org/llama.cpp/wiki/GGML-Tips-&-Tricks) #### Seminal papers and background on the models If your issue is with model generation quality, then please at least scan the following links and papers to understand the limitations of LLaMA models. This is especially important when choosing an appropriate model size and appreciating both the significant and subtle differences between LLaMA models and ChatGPT: - LLaMA: - [Introducing LLaMA: A foundational, 65-billion-parameter large language model](https://ai.facebook.com/blog/large-language-model-llama-meta-ai/) - [LLaMA: Open and Efficient Foundation Language Models](https://arxiv.org/abs/2302.13971) - GPT-3 - [Language Models are Few-Shot Learners](https://arxiv.org/abs/2005.14165) - GPT-3.5 / InstructGPT / ChatGPT: - [Aligning language models to follow instructions](https://openai.com/research/instruction-following) - [Training language models to follow instructions with human feedback](https://arxiv.org/abs/2203.02155) ## XCFramework The XCFramework is a precompiled version of the library for iOS, visionOS, tvOS, and macOS. It can be used in Swift projects without the need to compile the library from source. For example: ```swift // swift-tools-version: 5.10 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription let package = Package( name: "MyLlamaPackage", targets: [ .executableTarget( name: "MyLlamaPackage", dependencies: [ "LlamaFramework" ]), .binaryTarget( name: "LlamaFramework", url: "https://github.com/ggml-org/llama.cpp/releases/download/b5046/llama-b5046-xcframework.zip", checksum: "c19be78b5f00d8d29a25da41042cb7afa094cbf6280a225abe614b03b20029ab" ) ] ) ``` The above example is using an intermediate build `b5046` of the library. This can be modified to use a different version by changing the URL and checksum. ## Completions Command-line completion is available for some environments. #### Bash Completion ```bash $ build/bin/llama-cli --completion-bash > ~/.llama-completion.bash $ source ~/.llama-completion.bash ``` Optionally this can be added to your `.bashrc` or `.bash_profile` to load it automatically. For example: ```console $ echo "source ~/.llama-completion.bash" >> ~/.bashrc ``` ## Dependencies - [yhirose/cpp-httplib](https://github.com/yhirose/cpp-httplib) - Single-header HTTP server, used by `llama-server` - MIT license - [stb-image](https://github.com/nothings/stb) - Single-header image format decoder, used by multimodal subsystem - Public domain - [nlohmann/json](https://github.com/nlohmann/json) - Single-header JSON library, used by various tools/examples - MIT License - [miniaudio.h](https://github.com/mackron/miniaudio) - Single-header audio format decoder, used by multimodal subsystem - Public domain - [subprocess.h](https://github.com/sheredom/subprocess.h) - Single-header process launching solution for C and C++ - Public domain
▸ 中文总结(生成于 2026-07-30 14:17)

ggerganov/llama.cpp 项目介绍

项目概述

llama.cpp 是一个完全用 C/C++ 实现的大语言模型(LLM)推理引擎,旨在以最小的配置和领先的性能,在各种硬件(本地和云端)上运行 LLM 推理。项目由 ggerganov 维护,目前已获得 122100+ Star,是开源社区最流行的本地 LLM 推理方案之一。

核心目标

  • 零依赖:纯 C/C++ 实现,不依赖任何外部框架或库。
  • 跨平台高性能:优先支持 Apple Silicon,同时覆盖 x86(AVX/AVX2/AVX512/AMX)、RISC-V(RVV/ZVFH/ZFH 等)、NVIDIA GPU(CUDA)、AMD GPU(HIP)、Moore Threads GPU(MUSA)、Intel GPU(SYCL)、Vulkan、WebGPU 等几乎所有主流计算后端。
  • 低资源消耗:提供 1.5-bit、2-bit、3-bit、4-bit、5-bit、6-bit、8-bit 的整数量化,大幅减少显存占用并加速推理。
  • CPU+GPU 混合推理:支持将超过显存容量的大模型部分卸载到 CPU,实现更大模型的本地运行。

核心技术架构

  • ggml 库:llama.cpp 是 ggml 库的主要试验田。ggml 是一个面向机器学习的张量库,专门为 LLM 推理优化。
  • 量化技术:支持多种位宽的整数量化(如 Q4_0、Q5_1 等),可在几乎不损失精度的前提下将模型体积压缩至 1/4 甚至更小,使模型能运行在 8GB 显存的消费级显卡上。
  • 后端抽象:通过 Metal、CUDA、Vulkan、SYCL 等后端实现硬件加速,用户只需在编译时选择对应的后端即可。
  • GGUF 模型格式:所有模型需转换为统一的 GGUF 格式,Hugging Face 上已有大量预转换的 GGUF 模型可直接使用。

支持模型

llama.cpp 兼容大量开源模型及其微调版本,包括但不限于:

  • 纯文本模型:LLaMA 全系列、Mistral 7B、Mixtral MoE、Falcon、Qwen、DeepSeek、Gemma、Phi、Yi、Baichuan、InternLM2、Mamba、RWKV-6/7、GPT-2、BERT、StableLM、Command-R、OLMo、SmolLM、Hunyuan 等数十种。
  • 多模态模型:LLaVA 1.5/1.6、BakLLaVA、Qwen2-VL、Mini CPM、Moondream 等。
  • 特殊架构:支持 MoE(混合专家)、Mamba(状态空间模型)、BitNet b1.58(1.58 bit 量化)等。

详细支持列表见 README 中的 models 折叠区。

技术亮点

  • 极高的性能实测:在 Apple Silicon 上通过 Metal 后端达到行业领先的推理速度;在 x86 上利用 AVX 指令集进一步加速。
  • 量化精度与速度平衡:官方提供了详尽的量化方案,用户可根据需求选择。例如 Q4_0 在 1.5B 模型上可达到 5765 tokens/s (pp512)和 197 tokens/s(tg128)的 benchmark 结果(Metal+BLAS,16 线程)。
  • 多用户并行解码:llama-server 支持多用户并发请求,最大并行数可配置,适用于生产环境。
  • 推测解码:支持使用较小的 draft 模型加速主模型推理。
  • 约束输出:通过 GBNF 语法文件控制模型输出,例如强制输出 JSON 格式。
  • REST API 兼容 OpenAI:llama-server 提供 /v1/chat/completions 等端点,可直接替代 OpenAI API。
  • WebGPU 浏览器端推理:可在浏览器中直接运行 LLM,无需下载任何二进制文件。
  • 丰富的生态:已有 20+ 种语言的绑定(Python、Go、Node.js、Rust、C#、Java 等)、10+ 个主流 UI(如 Ollama、LM Studio、GPT4All、text-generation-webui)、以及大量基础设施工具(如 GPUStack、llama-swap)。

快速开始(摘自 README)

安装方式

  • 通过 Homebrew/nix/winget/conda-forge 安装
  • 使用 Docker(官方提供 Dockerfile)
  • 从 Releases 页面下载预编译二进制
  • 从源码编译(参见 build guide)

示例命令

# 使用本地模型文件
llama-cli -m my_model.gguf

# 直接从 Hugging Face 下载并运行
llama-cli -hf ggml-org/gemma-3-1b-it-GGUF

# 启动兼容 OpenAI API 的 HTTP 服务器
llama-server -hf ggml-org/gemma-3-1b-it-GGUF

对话模式

llama-cli -m model.gguf
# 模型带内置聊天模板时会自动进入对话模式

约束输出(JSON)

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

项目生态

  • 绑定:支持 Python、Go、Node.js、Rust、C#/ .NET、Java、Ruby、Swift、Zig、Flutter/Dart 等 20+ 语言。
  • UI:Ollama、LM Studio、GPT4All、Jan、LocalAI、koboldcpp、text-generation-webui 等 20+ 知名项目均基于 llama.cpp。
  • 工具:GGUF 编辑器、模型格式转换脚本、量化工具、Hugging Face 推理端点等。
  • 基础设施:GPUStack、Kubernetes Operator、llama-swap 等用于模型部署和集群管理。

性能数据样例(官方 Benchmark)

模型 大小 参数 后端 线程 测试 tokens/s
qwen2 1.5B Q4_0 885.97 MiB 1.54 B Metal,BLAS 16 pp512 5765.41 ± 20.55
tg128 197.71 ± 0.81

(注:pp 为 prompt processing,tg 为 text generation,数据来自 llama-bench 工具)

总结

llama.cpp 是目前最成熟、最流行的本地 LLM 推理引擎之一,凭借纯 C/C++ 实现、极致的量化优化、广泛的硬件支持和庞大的社区生态,为开发者和企业提供了在消费级硬件上运行大语言模型的能力。它不仅是推理工具,也是 ggml 库的核心试验场,持续推动着边缘 AI 推理的边界。