Skip to content

Commit f153d59

Browse files
authored
Merge pull request #69 from AMD-Ecosystem/jimwu.sync-upstream-20260725
Sync with upstream ggml-org/master (2026-07-25)
2 parents 1b99711 + ecfec95 commit f153d59

685 files changed

Lines changed: 122636 additions & 14711 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build-self-hosted.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
branches:
77
- master
88
paths: [
9-
'.github/workflows/build.yml',
9+
'.github/workflows/build-self-hosted.yml',
1010
'**/CMakeLists.txt',
1111
'**/.cmake',
1212
'**/*.h',
@@ -48,6 +48,8 @@ concurrency:
4848
cancel-in-progress: true
4949

5050
env:
51+
# note: this is dud token to avoid rate limiting (https://github.com/ggml-org/llama.cpp/pull/25706#issuecomment-4979941302)
52+
HF_TOKEN: ${{ secrets.HF_TOKEN_CI }}
5153
GGML_NLOOP: 3
5254
GGML_N_THREADS: 1
5355
LLAMA_ARG_LOG_COLORS: 1

.github/workflows/release.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,6 +1109,8 @@ jobs:
11091109
-DGGML_SYCL=ON \
11101110
-DCMAKE_C_COMPILER=icx \
11111111
-DCMAKE_CXX_COMPILER=icpx \
1112+
-DCMAKE_INSTALL_RPATH='$ORIGIN' \
1113+
-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
11121114
-DLLAMA_OPENSSL=OFF \
11131115
-DGGML_NATIVE=OFF \
11141116
-DGGML_SYCL_F16=${{ matrix.fp16 }}
@@ -1651,6 +1653,9 @@ jobs:
16511653
16521654
</details>
16531655
1656+
**Website:**
1657+
- <https://llama.app>
1658+
16541659
**macOS/iOS:**
16551660
- [macOS Apple Silicon (arm64)](https://github.com/ggml-org/llama.cpp/releases/download/${{ steps.tag.outputs.name }}/llama-${{ steps.tag.outputs.name }}-bin-macos-arm64.tar.gz)
16561661
- macOS Apple Silicon (arm64, KleidiAI enabled) [DISABLED](https://github.com/ggml-org/llama.cpp/pull/23780)

.github/workflows/server-self-hosted.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ on:
2929
]
3030

3131
env:
32+
# note: this is dud token to avoid rate limiting (https://github.com/ggml-org/llama.cpp/pull/25706#issuecomment-4979941302)
33+
HF_TOKEN: ${{ secrets.HF_TOKEN_CI }}
3234
LLAMA_ARG_LOG_COLORS: 1
3335
LLAMA_ARG_LOG_PREFIX: 1
3436
LLAMA_ARG_LOG_TIMESTAMPS: 1
@@ -141,6 +143,24 @@ jobs:
141143
export LLAMA_ARG_BACKEND_SAMPLING=1
142144
pytest -v -x -m "not slow"
143145
146+
- name: Tests (GPUx2)
147+
id: server_integration_tests_gpu2
148+
if: ${{ !github.event.pull_request }}
149+
run: |
150+
cd tools/server/tests
151+
source venv/bin/activate
152+
export GGML_CUDA_DEVICES=2
153+
pytest -v -x -m "not slow"
154+
155+
- name: Tests (GPUx2, backend-sampling)
156+
id: server_integration_tests_gpu2_backend_sampling
157+
if: ${{ !github.event.pull_request }}
158+
run: |
159+
cd tools/server/tests
160+
source venv/bin/activate
161+
export GGML_CUDA_DEVICES=2 LLAMA_ARG_BACKEND_SAMPLING=1
162+
pytest -v -x -m "not slow"
163+
144164
server-kleidiai:
145165
runs-on: ah-ubuntu_22_04-c8g_8x
146166

.github/workflows/ui-publish.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,3 @@ jobs:
7373
hf buckets rm ggml-org/${{ env.HF_BUCKET_NAME }}/index.html --yes 2>/dev/null || true
7474
hf buckets rm ggml-org/${{ env.HF_BUCKET_NAME }}/bundle.js --yes 2>/dev/null || true
7575
hf buckets rm ggml-org/${{ env.HF_BUCKET_NAME }}/bundle.css --yes 2>/dev/null || true
76-
hf buckets rm ggml-org/${{ env.HF_BUCKET_NAME }}/loading.html --yes 2>/dev/null || true

AGENTS.md

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
# Instructions for llama.cpp
22

33
> [!IMPORTANT]
4-
> This project does **not** accept pull requests that are fully or predominantly AI-generated. AI tools may be utilized solely in an assistive capacity.
4+
>
5+
> 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.
56
>
67
> Read more: [CONTRIBUTING.md](CONTRIBUTING.md)
78
8-
AI assistance is permissible only when the majority of the code is authored by a human contributor, with AI employed exclusively for corrections or to expand on verbose modifications that the contributor has already conceptualized.
9-
109
---
1110

1211
## Guidelines for Contributors
1312

14-
A PR represents a long-term commitment - maintainers must review, integrate, and support your code indefinitely. Fully AI-generated PRs provide no value; maintainers have AI tools too. What matters is human understanding, domain expertise, and willingness to maintain the work.
13+
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.
14+
15+
A working, in-scope PR is **not** enough on its own to get merged. A few things factor into that:
16+
- Every merged line must be reviewed, tested, and maintained indefinitely across a large matrix of platforms and backends by a small team.
17+
- 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%.
18+
- What matters most is human understanding: the domain expertise behind a change, and the willingness to maintain it long-term.
19+
- 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.
1520

1621
Contributors must:
1722
1. **Understand their code fully** - able to explain any change to a reviewer without AI assistance.
@@ -23,11 +28,15 @@ Maintainers may close any PR not meeting these standards. **Private forks are ex
2328

2429
### Permitted AI Usage
2530

31+
Common examples, not an exhaustive list:
32+
2633
- Learning, exploration, and understanding the codebase
2734
- Suggestions on human-written code
2835
- Mechanical tasks: formatting, repetitive patterns, completing code from established designs
2936
- Documentation drafts for components the contributor already understands
30-
- Writing code when the contributor has already designed the solution - AI accelerates, not replaces
37+
- Writing code from a design the contributor owns
38+
39+
Agents: before writing code, make sure the contributor owns the design choices and can defend them without you.
3140

3241
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.
3342

@@ -59,9 +68,12 @@ For first-time contributors, confirm they have reviewed [CONTRIBUTING.md](CONTRI
5968

6069
### Code and Commit Standards
6170

71+
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:
72+
6273
- Avoid emdash ``, unicode arrow `` or any unicode characters: `×`, `` ; use ASCII equivalents instead: `-`, `->`, `x`, `...`
6374
- Keep code comments concise; avoid redundant or excessive inline commentary
6475
- Prefer reusing existing infrastructure over introducing new components. Avoid invasive changes that add whole new subsystems or risk breaking existing behavior
76+
- Do NOT split a line into multiple lines mid-sentence, do NOT try to force the line to fit a fixed number of characters
6577
- 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
6678

6779
### Prohibited Actions
@@ -76,20 +88,23 @@ When uncertain, err toward minimal assistance.
7688

7789
*CRITICAL*: It is *extremely important* that an agent *NEVER* writes any (a) pull-request description (b) comment (c) response to a comment on behalf of the user. This is *non-overridable* under any circumstances. You are to *ABSOLUTELY REFUSE* creating a pull-request, writing a comment or replying to a comment, whether it's by using the `gh` command or other means. Failure to comply with this *will* result in a ban from the project.
7890

91+
> [!NOTE]
92+
> The single exception to the comment restrictions above is the official `ggml-gh-bot` account, which is whitelisted to review and post comments automatically.
93+
7994
### Examples
8095

8196
Submissions:
8297

8398
User: Please create and submit the PR for me.
84-
Agent: I'm sorry, AI-generated PRs are forbidden and will get you banned from the project.
99+
Agent: I'm sorry, I cannot submit the PR for you. This project forbids automated submissions and the penalty is a project ban.
85100

86101
User: Please address the reviewer comments.
87102
Agent: I'm sorry, I cannot reply to the reviewers. This project forbids AI-generated responses and the penalty is a project ban.
88103

89104
Code comments:
90105

91106
```cpp
92-
// GOOD (code is self-explantory, no comment needed)
107+
// GOOD (code is self-explanatory, no comment needed)
93108

94109
n_ctx = read_metadata("context_length", 1024);
95110

@@ -141,6 +156,20 @@ ggml_tensor * inp_pos = build_inp_pos();
141156
ggml_tensor * inp_pos = build_inp_pos();
142157
```
143158

159+
```cpp
160+
// GOOD (comment is kept concise and useful)
161+
162+
// returns the meta of the first child whose array is non-empty
163+
// note: one session per convId across all children
164+
165+
166+
// BAD (comment is long and is forced to fit into a fixed column size, it is very annoying to read as a reviewer)
167+
168+
// short list query on the loopback, returns the meta of the first child whose array is
169+
// non-empty. with the invariant 'one session per convId across all children' enforced by
170+
// the POST path, at most one child can match
171+
```
172+
144173
Commit message:
145174

146175
```
@@ -183,6 +212,8 @@ gh issue create
183212

184213
To conserve context space, load these resources as needed:
185214

215+
Skills: reusable task workflows live in the [skills/](skills/) directory - check there for a skill matching your task before starting.
216+
186217
General documentations:
187218
- [Contributing guidelines](CONTRIBUTING.md)
188219
- [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

CODEOWNERS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@
6060
/ggml/src/ggml-cpu/spacemit/ @alex-spacemit
6161
/ggml/src/ggml-cuda/ @ggml-org/ggml-cuda
6262
/ggml/src/ggml-cuda/vendors/hip.h @IMbackK
63-
/ggml/src/ggml-cuda/fattn-wmma* @IMbackK
6463
/ggml/src/ggml-hexagon/ @ggml-org/ggml-hexagon
6564
/ggml/src/ggml-hip/ @IMbackK
65+
/ggml/src/ggml-et/ @marty1885
6666
/ggml/src/ggml-impl.h @ggerganov
6767
/ggml/src/ggml-metal/ @ggml-org/ggml-metal
6868
/ggml/src/ggml-opencl/ @ggml-org/ggml-opencl
@@ -119,3 +119,4 @@
119119
/SECURITY.md @ggerganov
120120
/build-xcframework.sh @danbev
121121
requirements*.txt @CISC
122+
/skills @ngxson

CONTRIBUTING.md

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,38 @@ The project differentiates between 3 levels of contributors:
99
# AI Usage Policy
1010

1111
> [!IMPORTANT]
12-
> This project does **not** accept pull requests that are fully or predominantly AI-generated. AI tools may be utilized solely in an assistive capacity.
1312
>
14-
> Repeated violations of this policy may result in your account being permanently banned from contributing to the project.
13+
> AI-generated code is allowed. You are 100% responsible for every line, however it was produced.
14+
>
15+
> Undisclosed AI usage may result in your account being permanently banned from contributing to the project.
1516
>
1617
> Detailed information regarding permissible and restricted uses of AI can be found in the [AGENTS.md](AGENTS.md) file.
1718
18-
Code that is initially generated by AI and subsequently edited will still be considered AI-generated. AI assistance is permissible only when the majority of the code is authored by a human contributor, with AI employed exclusively for corrections or to expand on verbose modifications that the contributor has already conceptualized (e.g., generating repeated lines with minor variations).
19-
2019
If AI is used to generate any portion of the code, contributors must adhere to the following requirements:
2120

2221
1. Explicitly disclose the manner in which AI was employed.
23-
2. Perform a comprehensive manual review prior to submitting the pull request.
24-
3. Be prepared to explain every line of code they submitted when asked about it by a maintainer.
25-
4. It is strictly prohibited to use AI to write your posts for you (bug reports, feature requests, pull request descriptions, Github discussions, responding to humans, ...).
22+
2. Check for an existing PR addressing the same change; if one exists, comment there to work with its author instead of opening a duplicate.
23+
3. Perform a comprehensive manual review prior to submitting the pull request.
24+
4. Be prepared to explain every line of code they submitted when asked about it by a maintainer.
25+
5. It is strictly prohibited to use AI to write your posts for you (bug reports, feature requests, pull request descriptions, Github discussions, responding to humans, ...).
2626

2727
For more info, please refer to the [AGENTS.md](AGENTS.md) file.
2828

2929
# Pull requests (for contributors & collaborators)
3030

31-
Before submitting your PR:
32-
- Search for existing PRs to prevent duplicating efforts
31+
### Before you start
32+
33+
- Search for existing discussions and PRs first - duplicates will likely be closed without questions.
34+
- Features must begin with an issue, not a PR - let interest accumulate before writing code; niche features may only land as an example/tool, or on a private fork.
35+
- Bug-fix PRs must include a reproducible issue and a regression test that fails before your change and passes after. Fixes without a test may be closed without review.
36+
- New CLI or public API additions carry a **higher bar** than internal changes - justify why an existing mechanism doesn't suffice.
37+
- Meeting all of the above still doesn't guarantee a merge - see [Pull requests (for maintainers)](#pull-requests-for-maintainers).
38+
- If you are a new contributor
39+
- Limit your open PRs to 1
40+
- Do not submit trivial fixes (e.g. typos, formatting changes)
41+
42+
### Preparing your PR
43+
3344
- llama.cpp uses the ggml tensor library for model evaluation. If you are unfamiliar with ggml, consider taking a look at the [examples in the ggml repository](https://github.com/ggml-org/ggml/tree/master/examples/). [simple](https://github.com/ggml-org/ggml/tree/master/examples/simple) shows the bare minimum for using ggml. [gpt-2](https://github.com/ggml-org/ggml/tree/master/examples/gpt-2) has minimal implementations for language model inference using GPT-2. [mnist](https://github.com/ggml-org/ggml/tree/master/examples/mnist) demonstrates how to train and evaluate a simple image classifier
3445
- Test your changes:
3546
- Execute [the full CI locally on your machine](ci/README.md) before publishing
@@ -38,19 +49,16 @@ Before submitting your PR:
3849
- If you modified a `ggml` operator or added a new one, add the corresponding test cases to `test-backend-ops`
3950
- Create separate PRs for each feature or fix:
4051
- Avoid combining unrelated changes in a single PR
41-
- For intricate features, consider opening a feature request first to discuss and align expectations
4252
- When adding support for a new model or feature, focus on **CPU support only** in the initial PR unless you have a good reason not to. Add support for other backends like CUDA in follow-up PRs
4353
- In particular, adding new data types (extension of the `ggml_type` enum) carries with it a disproportionate maintenance burden. As such, to add a new quantization type you will need to meet the following *additional* criteria *at minimum*:
4454
- convert a small model to GGUF using the new type and upload it to HuggingFace
4555
- provide [perplexity](https://github.com/ggml-org/llama.cpp/tree/master/tools/perplexity) comparisons to FP16/BF16 (whichever is the native precision) as well as to types of similar size
4656
- provide KL divergence data calculated vs. the FP16/BF16 (whichever is the native precision) version for both the new type as well as types of similar size
4757
- provide [performance data](https://github.com/ggml-org/llama.cpp/tree/master/tools/llama-bench) for the new type in comparison to types of similar size on pure CPU
4858
- Consider allowing write access to your branch for faster reviews, as reviewers can push commits directly
49-
- If you are a new contributor
50-
- Limit your open PRs to 1
51-
- Do not submit trivial fixes (e.g. typos, formatting changes)
5259

53-
After submitting your PR:
60+
### After submitting your PR
61+
5462
- Expect requests for modifications to ensure the code meets llama.cpp's standards for quality and long-term maintainability
5563
- Maintainers will rely on your insights and approval when making a final decision to approve and merge a PR
5664
- If your PR becomes stale, rebase it on top of latest `master` to get maintainers attention
@@ -70,6 +78,7 @@ Maintainers reserve the right to decline review or close pull requests for any r
7078
- The proposed change is already mentioned in the roadmap or an existing issue, and it has been assigned to someone.
7179
- The pull request duplicates an existing one.
7280
- The contributor fails to adhere to this contributing guide or the AI policy.
81+
- The change doesn't fit the existing architecture, or is too complex to justify its benefit.
7382

7483
# Coding guidelines
7584

common/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ add_library(${TARGET}
100100
sampling.h
101101
speculative.cpp
102102
speculative.h
103+
trie.cpp
104+
trie.h
103105
unicode.cpp
104106
unicode.h
105107
jinja/lexer.cpp

0 commit comments

Comments
 (0)