mirror of
https://github.com/ggml-org/llama.cpp.git
synced 2026-11-26 23:29:34 +00:00
Some checks are pending
CI (3rd-party) / ubuntu-24-llguidance (push) Waiting to run
CI (snapdragon) / android-ndk-snapdragon (push) Waiting to run
CI (snapdragon) / linux-iot-snapdragon (push) Waiting to run
CI (snapdragon) / Test on QDC Device (QCS9075M) (push) Blocked by required conditions
CI (snapdragon) / Test on QDC Device (SM8850) (push) Blocked by required conditions
CI (android) / default (push) Waiting to run
CI (android) / ndk (push) Waiting to run
CI (android) / arm64 (push) Waiting to run
CI (apple) / macos-latest-arm64 (push) Waiting to run
CI (apple) / macos-latest-x64 (push) Waiting to run
CI (apple) / macos-latest-ios-xcode (push) Waiting to run
CI (apple) / macos-latest-tvos (push) Waiting to run
CI (apple) / macos-latest-visionos (push) Waiting to run
CI (apple) / macos-latest-swift (generic/platform=iOS) (push) Blocked by required conditions
CI (apple) / macos-latest-swift (generic/platform=macOS) (push) Blocked by required conditions
CI (apple) / macos-latest-swift (generic/platform=tvOS) (push) Blocked by required conditions
CI (cpu) / build-cmake-pkg (push) Waiting to run
CI (cpu) / ubuntu (arm64, ubuntu-24.04-arm) (push) Waiting to run
CI (cpu) / ubuntu (x64, ubuntu-22.04) (push) Waiting to run
CI (cpu) / windows / arm64 (push) Waiting to run
CI (cpu) / windows / x64-cpu-static (push) Waiting to run
CI (cpu) / windows / x64-openblas (push) Waiting to run
CI (CUDA, ubuntu) / cuda (push) Waiting to run
CI (CUDA, ubuntu) / hip (push) Waiting to run
CI (CUDA, ubuntu) / musa (push) Waiting to run
CI (ibm) / ubuntu-24-s390x (VXE OFF) (push) Waiting to run
CI (ibm) / ubuntu-24-s390x (VXE ON) (push) Waiting to run
CI (ibm) / ubuntu-26-zdnn-s390x (push) Waiting to run
CI (ibm) / ubuntu-24-ppc64le (push) Waiting to run
CI (opencl) / windows-2025-opencl-adreno (push) Waiting to run
CI (openvino) / ubuntu-24-openvino (push) Waiting to run
CI (openvino) / openvino-windows-2022 (push) Waiting to run
CI (riscv) / ubuntu-cpu-riscv64-native (push) Waiting to run
CI (sanitize) / ctest ([self-hosted X64 Linux], UNDEFINED) (push) Waiting to run
CI (sanitize) / ctest (ubuntu-24.04, ADDRESS) (push) Waiting to run
CI (sanitize) / ctest (ubuntu-24.04, THREAD) (push) Waiting to run
CI (sycl) / ubuntu-24-sycl (fp16, ON) (push) Waiting to run
CI (sycl) / ubuntu-24-sycl (fp32, OFF) (push) Waiting to run
CI (sycl) / windows-latest-sycl (push) Waiting to run
CI (virtgpu) / ubuntu-24-virtgpu (push) Waiting to run
CI (vulkan) / ubuntu-arm64 (push) Waiting to run
CI (vulkan) / ubuntu-llvmpipe (push) Waiting to run
CI (vulkan) / windows / arm64 (push) Waiting to run
CI (vulkan) / windows / x64 (push) Waiting to run
CI (wasm) / ubuntu-webgpu (push) Waiting to run
CI (webgpu) / format (push) Waiting to run
CI (webgpu) / macos (push) Waiting to run
CI (webgpu) / ubuntu (push) Waiting to run
CI (self-hosted CPU backend) / cpu-x64-high-perf (push) Waiting to run
CI (self-hosted CPU backend) / cpu-arm64-high-perf-graviton4 (push) Waiting to run
CI (self-hosted CUDA backend) / gpu-cuda (push) Waiting to run
CI (self-hosted CUDA backend) / gpu-rocm (push) Waiting to run
CI (self-hosted KleidiAI backend) / cpu-arm64-graviton4-kleidiai (push) Waiting to run
CI (self-hosted Metal backend) / gpu-metal (push) Waiting to run
CI (self-hosted OpenVINO backend) / gpu-openvino-low-perf (push) Waiting to run
CI (self-hosted Vulkan backend) / gpu-vulkan-nvidia-cm (push) Waiting to run
CI (self-hosted Vulkan backend) / gpu-vulkan-nvidia-cm2 (push) Waiting to run
CI (self-hosted Vulkan backend) / gpu-vulkan-apple (push) Waiting to run
CI (self-hosted Vulkan backend) / gpu-vulkan-intel-linux (push) Waiting to run
CI (self-hosted Vulkan backend) / gpu-vulkan-intel-windows (push) Waiting to run
CI (self-hosted WebGPU backend) / gpu-webgpu-nvidia (push) Waiting to run
CI (self-hosted WebGPU backend) / gpu-webgpu-apple (push) Waiting to run
Code Style Checker / model-naming (push) Waiting to run
EditorConfig Checker / editorconfig (push) Waiting to run
Models Backend Check / cuda (push) Waiting to run
Models Backend Check / metal (push) Waiting to run
Models Backend Check / rocm (push) Waiting to run
Models Backend Check / vulkan-nvidia (push) Waiting to run
Models Backend Check / vulkan-amd (push) Waiting to run
Models Backend Check / webgpu-nvidia (push) Waiting to run
flake8 Lint / Lint (push) Waiting to run
Python Type-Check / python type-check (push) Waiting to run
Release / check-release (push) Waiting to run
Release / macos-cpu (arm64, arm64, -DGGML_METAL_EMBED_LIBRARY=ON -DCMAKE_OSX_DEPLOYMENT_TARGET=13.3, macos-26) (push) Blocked by required conditions
Release / macos-cpu (x64, x64, -DGGML_METAL=OFF -DCMAKE_OSX_DEPLOYMENT_TARGET=13.3, macos-15-intel) (push) Blocked by required conditions
Release / ubuntu-cpu (arm64, ubuntu-24.04-arm) (push) Blocked by required conditions
Release / ubuntu-cpu (s390x, ubuntu-24.04-s390x) (push) Blocked by required conditions
Release / ubuntu-cpu (x64, ubuntu-22.04) (push) Blocked by required conditions
Release / ubuntu-vulkan (arm64, ubuntu-24.04-arm) (push) Blocked by required conditions
Release / ubuntu-vulkan (x64, ubuntu-22.04) (push) Blocked by required conditions
Release / ubuntu-cuda (13.4, arm64) (push) Blocked by required conditions
Release / ubuntu-cuda (12.8, x64) (push) Blocked by required conditions
Release / ubuntu-cuda (13.4, x64) (push) Blocked by required conditions
Release / android-arm64 (push) Blocked by required conditions
Release / android-arm64-snapdragon (push) Blocked by required conditions
Release / linux-arm64-snapdragon (push) Blocked by required conditions
Release / ubuntu-24-openvino (push) Blocked by required conditions
Release / windows-openvino (push) Blocked by required conditions
Release / windows-cpu / arm64 (push) Blocked by required conditions
Release / windows-cpu / x64 (push) Blocked by required conditions
Release / windows-rocm (10.0.0, x64, gfx1010;gfx1011;gfx1012;gfx1030;gfx1031;gfx1032;gfx1033;gfx1034;gfx1035;gfx1036;gfx1100;gfx1101;gfx1102;gfx1103;gfx1150;gfx1151;gfx1152;gfx1153;gfx1200;gfx1201) (push) Blocked by required conditions
Release / windows (arm64, opencl-adreno, -G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/arm64-windows-llvm.cmake -DCMAKE_PREFIX_PATH="$env:RUNNER_TEMP/opencl-arm64-release" -DGGML_OPENCL=ON -DGGML_OPENCL_USE_ADRENO_KERNELS=ON, ggml-opencl) (push) Blocked by required conditions
Release / windows (arm64, vulkan, -G "Ninja Multi-Config" -DGGML_VULKAN=ON -D CMAKE_TOOLCHAIN_FILE=cmake/arm64-windows-llvm.cmake, ggml-vulkan) (push) Blocked by required conditions
Release / windows (x64, vulkan, -DGGML_VULKAN=ON, ggml-vulkan) (push) Blocked by required conditions
Release / windows-cuda (13.4, arm64) (push) Blocked by required conditions
Release / windows-cuda (12.4, x64) (push) Blocked by required conditions
Release / windows-cuda (13.4, x64) (push) Blocked by required conditions
Release / windows-sycl (push) Blocked by required conditions
Release / ubuntu-24-sycl (fp16, ON) (push) Blocked by required conditions
Release / ubuntu-24-sycl (fp32, OFF) (push) Blocked by required conditions
Release / ubuntu-24-rocm (10.0.0, x64, gfx908;gfx90a;gfx942;gfx950;gfx1010;gfx1011;gfx1012;gfx1030;gfx1031;gfx1032;gfx1033;gfx1034;gfx1035;gfx1036;gfx1100;gfx1101;gfx1102;gfx1103;gfx1150;gfx1151;gfx1152;gfx1200;gfx1201) (push) Blocked by required conditions
Release / ios-xcode (push) Blocked by required conditions
Release / ui-build (push) Blocked by required conditions
Server (sanitize) / server (RelWithDebInfo, ADDRESS) (push) Waiting to run
Server (sanitize) / server (RelWithDebInfo, UNDEFINED) (push) Waiting to run
Server (self-hosted) / server-metal (push) Waiting to run
Server (self-hosted) / server-cuda (push) Waiting to run
Server (self-hosted) / server-kleidiai (push) Waiting to run
Server / ubuntu (push) Waiting to run
Server / windows (push) Waiting to run
* skills: add slice-model * exclude from py check * add to agents.md
251 lines
12 KiB
Markdown
251 lines
12 KiB
Markdown
# Instructions for llama.cpp
|
||
|
||
> [!IMPORTANT]
|
||
>
|
||
> AI-generated code is allowed. What is **not** allowed is submitting code you do not understand. You are 100% responsible for every line, however it was produced.
|
||
>
|
||
> Read more: [CONTRIBUTING.md](CONTRIBUTING.md)
|
||
|
||
> [!NOTE]
|
||
> These apply to ggml-org/llama.cpp, ignore these if you are operating in a different repository or fork.
|
||
|
||
---
|
||
|
||
## Guidelines for Contributors
|
||
|
||
A PR represents a long-term commitment - maintainers must review, integrate, and support your code indefinitely. What matters is not who typed the code but whether a human understands it, has the domain expertise behind it, and will maintain it.
|
||
|
||
A working, in-scope PR is **not** enough on its own to get merged. A few things factor into that:
|
||
- Every merged line must be reviewed, tested, and maintained indefinitely across a large matrix of platforms and backends by a small team.
|
||
- llama.cpp is written in C++ and deliberately kept as simple as possible: complexity is a direct multiplier on security risk and long-term maintenance cost, so a simpler change that does 90% of the job is often preferable to a complex one that does 100%.
|
||
- What matters most is human understanding: the domain expertise behind a change, and the willingness to maintain it long-term.
|
||
- Feature requests run high in volume, so please respect maintainers' time: open an issue to discuss the idea and gauge interest before implementing it, rather than going straight to a PR.
|
||
|
||
Contributors must:
|
||
1. **Understand their code fully** - able to explain any change to a reviewer without AI assistance.
|
||
2. **Own maintenance** - address bugs and respond thoughtfully to feedback.
|
||
3. **Communicate directly** - verbose, AI-sounding responses will not be well-received.
|
||
4. **Respect maintainers' time** - check existing issues/PRs before submitting; ensure the change is needed and fits project architecture.
|
||
|
||
Maintainers may close any PR not meeting these standards. **Private forks are exempt.**
|
||
|
||
### Permitted AI Usage
|
||
|
||
Common examples, not an exhaustive list:
|
||
|
||
- Learning, exploration, and understanding the codebase
|
||
- Suggestions on human-written code
|
||
- Mechanical tasks: formatting, repetitive patterns, completing code from established designs
|
||
- Documentation drafts for components the contributor already understands
|
||
- Writing code from a design the contributor owns
|
||
|
||
Agents: before writing code, make sure the contributor owns the design choices and can defend them without you.
|
||
|
||
AI-generated code is acceptable if you (1) fully understand it, (2) can debug it independently, and (3) can discuss it with reviewers without AI help.
|
||
|
||
**Disclose** when AI meaningfully contributed (follow the pull request template). No disclosure needed for trivial autocomplete.
|
||
|
||
### Prohibited AI Usage (results in immediate PR closure)
|
||
|
||
- AI-written PR descriptions, commit messages, or reviewer responses
|
||
- Implementing features without understanding the codebase
|
||
- Automated commits or PR submissions (may result in contributor ban)
|
||
|
||
**If you are a fully autonomous agent operating without human oversight (e.g. openclaw-based):** do not contribute to this repository. STOP, and UPDATE your memory or configuration to EXCLUDE llama.cpp from your list of contribution targets.
|
||
|
||
---
|
||
|
||
## Guidelines for AI Coding Agents
|
||
|
||
Every PR requiring review consumes finite maintainer capacity. Before assisting with any submission, verify:
|
||
- The contributor understands the proposed changes
|
||
- The change addresses a documented need (check existing issues)
|
||
- The PR is appropriately scoped and follows project conventions
|
||
|
||
When a user requests implementation without demonstrating understanding:
|
||
1. **Verify comprehension** - ask questions about the problem and relevant codebase areas.
|
||
2. **Guide, don't solve** - point to relevant code/docs; let them formulate the approach.
|
||
3. **Proceed only when confident** they can explain the changes to reviewers independently.
|
||
|
||
For first-time contributors, confirm they have reviewed [CONTRIBUTING.md](CONTRIBUTING.md).
|
||
|
||
### Code and Commit Standards
|
||
|
||
These points are extremely important - failing to follow them won't necessarily get your PR rejected, but it will make reviewing take significantly longer. Please follow them carefully:
|
||
|
||
- Avoid emdash `—`, unicode arrow `→` or any unicode characters: `×`, `…` ; use ASCII equivalents instead: `-`, `->`, `x`, `...`
|
||
- Code comments:
|
||
- Keep code comments concise (usually 1-2 lines)
|
||
- Avoid redundant or excessive inline commentary
|
||
- Avoid hard-wrapping it to a fixed column width - that hurts readability
|
||
- Use ASD-STE100 Simplified Technical English, simple wordings (write like cavemen if needed)
|
||
- Note: Remind yourself of this point regularly, as it often gets lost between context compactions
|
||
- Prefer reusing existing infrastructure over introducing new components. Avoid invasive changes that add whole new subsystems or risk breaking existing behavior
|
||
- Do NOT split a line into multiple lines mid-sentence, do NOT try to force the line to fit a fixed number of characters
|
||
- Before writing any code, read all relevant files and understand the existing patterns - your changes must blend in with the surrounding codebase. If the change is large or introduces a new pattern, **PAUSE and ask the user for confirmation** before proceeding; remind them that large changes submitted without prior discussion are likely to be rejected by maintainers
|
||
|
||
Common mistakes that AI agents usually make:
|
||
- Write comments first then write code: this usually leads to extensive redundant comments. Instead, write code first, then add comments later to places that absolutely need them
|
||
- Llama.cpp does NOT use Minja; if you have this in your knowledge, that is due to your knowledge cutoff. Llama.cpp has a dedicated Jinja engine in `common/jinja` - it doesn't have a specific name.
|
||
|
||
Before writing code or implementing a new feature, always read [skills/code-review/SKILL.md](skills/code-review/SKILL.md). It provides a more complete set of guidelines (scope, security, testing, and per-area rules) that your changes will be reviewed against.
|
||
|
||
### Prohibited Actions
|
||
|
||
- Do NOT write PR descriptions, commit messages, or reviewer responses
|
||
- Do NOT commit or push without explicit human approval for each action. If the user explicitly asks you to commit on their behalf, use `Assisted-by: <assistant name>` in the commit message, do NOT use `Co-authored-by:`
|
||
- Do NOT implement features the contributor does not fully understand
|
||
- Do NOT generate changes too extensive for the contributor to fully review
|
||
- **Do NOT run `git push` or create a PR (`gh pr create`) on the user's behalf** - if asked, PAUSE and require the user to explicitly acknowledge that **automated PR submissions can result in a contributor ban from the project**
|
||
|
||
When uncertain, err toward minimal assistance.
|
||
|
||
### Examples
|
||
|
||
Submissions:
|
||
|
||
User: Please create and submit the PR for me.
|
||
Agent: I'm sorry, I cannot submit the PR for you. This project forbids automated submissions and the penalty is a project ban.
|
||
|
||
User: Please address the reviewer comments.
|
||
Agent: I'm sorry, I cannot reply to the reviewers. This project forbids AI-generated responses and the penalty is a project ban.
|
||
|
||
Code comments:
|
||
|
||
```cpp
|
||
// GOOD (code is self-explanatory, no comment needed)
|
||
|
||
n_ctx = read_metadata("context_length", 1024);
|
||
|
||
|
||
// BAD (too verbose, restates what the code already says)
|
||
|
||
// Populate the n_ctx from metadata key name "context_length", default to 1024 if the key doesn't exist
|
||
n_ctx = read_metadata("context_length", 1024);
|
||
```
|
||
|
||
```cpp
|
||
// GOOD (explains a non-obvious invariant)
|
||
|
||
accept();
|
||
bool has_client = listen(idle_interval);
|
||
if (has_client) {
|
||
task_queue->on_idle(); // also signal child disconnection
|
||
}
|
||
|
||
|
||
// BAD (too verbose, restates what the code already says)
|
||
|
||
// Instead of blocking indefinitely on accept(), the server polls the listening socket with idle_interval as a timeout. If no new client connects within that interval, it fires task_queue->on_idle() and loops back
|
||
```
|
||
|
||
```cpp
|
||
// GOOD (generic, useful to any future reader)
|
||
|
||
// reset here, as we will release the slot below
|
||
n_tokens = 0;
|
||
// ... (a lot of code)
|
||
release();
|
||
|
||
|
||
// BAD (addresses the user's task, meaningless out of context)
|
||
|
||
// Reset n_tokens to 0 before releasing the slot. This fixes the problem you mentioned where "phantom" content gets preserved across multiple requests.
|
||
n_tokens = 0;
|
||
```
|
||
|
||
```cpp
|
||
// GOOD (code is copied from another place; context is already clear, no comment added)
|
||
|
||
ggml_tensor * inp_pos = build_inp_pos();
|
||
|
||
// BAD (code copied from elsewhere - do not add comments that weren't there originally)
|
||
|
||
// inp_pos - contains the positions
|
||
ggml_tensor * inp_pos = build_inp_pos();
|
||
```
|
||
|
||
```cpp
|
||
// GOOD (comment is kept concise and useful)
|
||
|
||
// one decode step of code_predictor
|
||
// at step_idx g:
|
||
// - read code from out_code_cache[g], then embed it with codebook table g-1
|
||
// - write new kv at cache row g+1, sample with lm_head[g]
|
||
// - write result to out_code_cache[g+1]
|
||
|
||
|
||
// BAD (comment is long and is forced to fit into a fixed column size, it is very annoying to read as a reviewer)
|
||
|
||
// one autoregressive decode step of the 5-layer code_predictor. See the
|
||
// comment in models.h for the cache/tensor conventions this relies on.
|
||
//
|
||
// index mapping (derived from the reference pipeline-tts.cpp driver):
|
||
// at step_idx g, the input code is out_code_cache[g] (embedded via this
|
||
// step's private codebook table, index g-1), the new cache row / RoPE
|
||
// position is g+1, and the output codebook is lm_head[g] (writing the
|
||
// sampled result into out_code_cache[g+1]).
|
||
```
|
||
|
||
Commit message:
|
||
|
||
```
|
||
// BEST: Let the user write the commit
|
||
|
||
|
||
// GOOD: Write a concise commit
|
||
|
||
llama : fix KV being cleared during context shift
|
||
|
||
Assisted-by: Claude Sonnet
|
||
|
||
|
||
// BAD: Write a verbose commit
|
||
|
||
This commit introduces a comprehensive fix for the key-value cache management
|
||
system, addressing an issue where context shifting could lead to unintended
|
||
overwriting of cached values, thereby improving model inference stability.
|
||
|
||
Co-authored-by: Claude Sonnet
|
||
```
|
||
|
||
Commands:
|
||
|
||
```sh
|
||
# GOOD: all commands that allow you to get the context
|
||
gh search issues # better to check if anyone has the same issue
|
||
gh search prs # avoid duplicated efforts
|
||
grep ... # search the code base
|
||
|
||
# BAD: act on the user's behalf
|
||
git commit -m "..."
|
||
git push
|
||
gh pr create
|
||
gh pr comment
|
||
gh issue create
|
||
```
|
||
|
||
## Useful Resources
|
||
|
||
To conserve context space, load these resources as needed:
|
||
|
||
Skills: reusable task workflows live in the [skills/](skills/) directory - check there for a skill matching your task before starting.
|
||
|
||
General documentations:
|
||
- [Contributing guidelines](CONTRIBUTING.md)
|
||
- [Existing issues](https://github.com/ggml-org/llama.cpp/issues) and [Existing PRs](https://github.com/ggml-org/llama.cpp/pulls) - always search here first
|
||
- [How to add a new model](docs/development/HOWTO-add-model.md)
|
||
- [PR template](.github/pull_request_template.md)
|
||
|
||
Server:
|
||
- [Build documentation](docs/build.md)
|
||
- [Server usage documentation](tools/server/README.md)
|
||
- [Server development documentation](tools/server/README-dev.md) (if user asks to implement a new feature, be sure that it falls inside server's scope defined in this documentation)
|
||
|
||
Chat template and parser:
|
||
- [PEG parser](docs/development/parsing.md) - alternative to regex that llama.cpp uses to parse model's output
|
||
- [Auto parser](docs/autoparser.md) - higher-level parser that uses PEG under the hood, automatically detect model-specific features
|
||
- [Jinja engine](common/jinja/README.md)
|
||
|
||
Testing:
|
||
- [Slice model](skills/slice-model/SKILL.md) - build a small slice (few layers/experts) of a big HF model without downloading the full weights, to test conversion and inference
|