mirror of
https://github.com/ggml-org/llama.cpp.git
synced 2026-11-28 19:16:22 +00:00
Espelho do repositório github do llama.cpp
* llama, metal : support BF16 src1 for MUL_MAT and MUL_MAT_ID Add GGML_PREC_BF16 handling for src1 on the Metal backend when the tensor API is available: MUL_MAT with an F32 src0 stages the A tile as bfloat, and MUL_MAT_ID stages src1 as bfloat instead of F16. The tensor path keeps src1 in F32 when it reads the operand directly. Add a temporary LLAMA_MOE_AMAX_SKIP env var that disables the graph-level amax rescaling for the MoE down projection and sets the BF16 src1 hint instead. Apply the hint inside build_lora_mm_id so it reaches the matmul before the per-expert scale and LoRA nodes wrap it. Add MUL_MAT_ID src1 BF16 test cases to test-backend-ops. Assisted-by: dsh:llama.cpp/ggml-org/DeepSeek-V4.1-Flash-1017-GGUF (Mac Studio, M5 Ultra, 256GB) * metal : support BF16 src1 without the tensor API Allow GGML_PREC_BF16 when the device has bfloat, not only when it has the Metal4 tensor API. Add legacy _prec_bf16 kernels for MUL_MAT and MUL_MAT_ID that stage src1 as bfloat in the threadgroup and run the simdgroup multiply with bfloat A and B. The F16 MUL_MAT_ID kernel uses half A on the tensor path and bfloat A on the legacy path. Cast the quantized dequantize outputs to the destination element type: the older Metal compiler on M2 rejects implicit float to bfloat. Tested on M2 Ultra (legacy): MUL_MAT_PREC_SRC1 24/24 and MUL_MAT_ID_PREC_SRC1_BF16 30/30. Flint Q4_K_M with LLAMA_MOE_AMAX_SKIP=1: pp512 -2.1%, tg128 +25.5% vs master. On M5 Max: pp512 +2.1%, tg128 +22.2%. Assisted-by: dsh:llama.cpp/ggml-org/DeepSeek-V4.1-Flash-1017-GGUF (Mac Studio, M5 Ultra, 256GB) * metal : derive matrix types with value_type helpers Add value_type_4x4/value_type_2x4/value_type_8x8 helpers and use them in the MUL_MAT and MUL_MAT_ID kernels so the templates take only the underlying types and derive the matrix types. Add TODOs for the remaining kernels. Assisted-by: dsh:llama.cpp/ggml-org/DeepSeek-V4.1-Flash-1017-GGUF (Mac Studio, M5 Ultra, 256GB) * metal : derive matrix types in the remaining kernels Use the value_type_* helpers in the flash-attention, top-k-mask, mul-mv and count-equal kernels to derive the matrix/vector types from the underlying scalar types, and simplify the FA_TYPES macros. Assisted-by: dsh:llama.cpp/ggml-org/DeepSeek-V4.1-Flash-1017-GGUF (Mac Studio, M5 Ultra, 256GB) * metal : enable BF16 in the tensor API metallib The tensor API requires macOS 26, where bfloat is always available, so define GGML_METAL_HAS_BF16 when compiling the tensor metallib. This makes the bfloat specializations of the value_type helpers visible to fa_tensor.metal and includes the prec_bf16 kernels in the prebuilt tensor metallib. Assisted-by: dsh:llama.cpp/ggml-org/DeepSeek-V4.1-Flash-1017-GGUF (Mac Studio, M5 Ultra, 256GB) * metal : support GGML_PREC_F32 for src1 in MUL_MAT and MUL_MAT_ID Split the tensor-API and legacy simdgroup mul_mm/mul_mm_id kernels into separate files and library kinds, following the fa_tensor.metal example. The legacy kernels, including the new _prec_f32 variants that stage src0 and src1 as float in shared memory, are compiled into the default mul_mm library; the tensor variants live in a separate mul_mm_tensor library kind and carry a _tensor host-name infix. Tensor devices run F32 src1 matmuls on the simdgroup path instead of the tensor API, which rounds float operands to a reduced precision. This removes the MUL_MM_SG kind and the #undef GGML_METAL_HAS_TENSOR compile. Add MUL_MAT_ID_PREC_SRC1_F32 tests. Assisted-by: dsh:llama.cpp/ggml-org/DeepSeek-V4.1-Flash-1017-GGUF (Mac Studio, M5 Ultra, 256GB) * cont : indentation * llama : move the MoE amax skip into the precision policy Add llm_arch_mmid_down_bf16() for the architectures whose MoE down projection uses the graph-level amax rescaling. Extract the precision policy setup from load_tensors() into llama_model_base::load_prec_policy(), and move the LLAMA_MOE_AMAX_SKIP handling there: it sets prec_src1 = BF16 for ffn_down_exps before the per-tensor policy is loaded. build_moe_ffn() now skips the amax rescaling when the policy requests BF16. Apply the policy with the original weight so cached experts get it, drop the prec_src1 parameter from build_lora_mm_id(), and remove the prec_src1 serialization from the model saver. Assisted-by: dsh:llama.cpp/ggml-org/DeepSeek-V4.1-Flash-1017-GGUF (Mac Studio, M5 Ultra, 256GB) * cont : minor |
||
|---|---|---|
| .devops | ||
| .gemini | ||
| .github | ||
| .pi/gg | ||
| app | ||
| benches | ||
| ci | ||
| cmake | ||
| common | ||
| conversion | ||
| docs | ||
| examples | ||
| ggml | ||
| gguf-py | ||
| grammars | ||
| include | ||
| licenses | ||
| media | ||
| models | ||
| pocs | ||
| requirements | ||
| scripts | ||
| skills | ||
| src | ||
| tests | ||
| tools | ||
| ui | ||
| vendor | ||
| .clang-format | ||
| .clang-tidy | ||
| .dockerignore | ||
| .ecrc | ||
| .editorconfig | ||
| .flake8 | ||
| .gitignore | ||
| .gitmodules | ||
| .pre-commit-config.yaml | ||
| AGENTS.md | ||
| AUTHORS | ||
| build-xcframework.sh | ||
| CLAUDE.md | ||
| CMakeLists.txt | ||
| CMakePresets.json | ||
| CODEOWNERS | ||
| CONTRIBUTING.md | ||
| convert_hf_to_gguf.py | ||
| convert_hf_to_gguf_update.py | ||
| convert_llama_ggml_to_gguf.py | ||
| convert_lora_to_gguf.py | ||
| flake.nix | ||
| LICENSE | ||
| Makefile | ||
| mypy.ini | ||
| pyproject.toml | ||
| pyrightconfig.json | ||
| README.md | ||
| requirements.txt | ||
| SECURITY.md | ||
| ty.toml | ||
llama.cpp
LLM inference in C/C++
v1.0.0 / ggml / ops / maintainer PRs / dev stats / lib llama API / llama-server REST API
Description
The main goal of llama.cpp is to enable LLM (and MLLM) inference with minimal setup and state-of-the-art performance on a wide range of hardware - locally and in the cloud.
The llama.cpp project is built on top of the ggml library.
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
|
|
|
Documentation
Tools
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