Skip to content

Commit a8cc3fa

Browse files
committed
Merge remote-tracking branch 'upstream/master' into parakeet-support
2 parents 8302e8e + c932729 commit a8cc3fa

7 files changed

Lines changed: 302 additions & 15 deletions

File tree

.github/workflows/bindings-go.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ on:
33
push:
44
paths:
55
- bindings/go/**
6-
- whisper.h
6+
- include/whisper.h
77
pull_request:
88
paths:
99
- bindings/go/**
10-
- whisper.h
10+
- include/whisper.h
1111

1212
jobs:
1313
ubuntu-22:

.github/workflows/bindings-ruby.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,19 @@ on:
44
push:
55
branches:
66
- master
7+
paths:
8+
- bindings/ruby/**
9+
- include/whisper.h
10+
- examples/common-whisper.h
11+
- ggml/include/ggml.h
12+
713
pull_request:
814
types: [opened, synchronize, reopened]
15+
paths:
16+
- bindings/ruby/**
17+
- include/whisper.h
18+
- examples/common-whisper.h
19+
- ggml/include/ggml.h
920

1021
jobs:
1122
ubuntu-22:

.github/workflows/build.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ on:
2828

2929
pull_request:
3030
types: [opened, synchronize, reopened]
31+
paths-ignore:
32+
- 'bindings/ruby/**' # handled by bindings-ruby.yml
33+
- 'bindings/go/**' # handled by bindings-go.yml
3134
workflow_dispatch:
3235
inputs:
3336
create_release:

.github/workflows/docker.yml

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,33 @@
11
name: Publish Docker image
22

33
on:
4-
pull_request:
54
push:
65
branches:
76
- master
87

98
jobs:
109
push_to_registry:
1110
name: Push Docker image to Docker Hub
12-
if: github.event.pull_request.draft == false
1311

14-
runs-on: ubuntu-22.04
12+
runs-on: ${{ matrix.config.runs_on }}
1513
env:
1614
COMMIT_SHA: ${{ github.sha }}
1715
strategy:
1816
fail-fast: false
1917
matrix:
2018
config:
21-
- { tag: "main", dockerfile: ".devops/main.Dockerfile", platform: "linux/amd64" }
22-
- { tag: "main-musa", dockerfile: ".devops/main-musa.Dockerfile", platform: "linux/amd64" }
23-
- { tag: "main-intel", dockerfile: ".devops/main-intel.Dockerfile", platform: "linux/amd64" }
24-
- { tag: "main-cuda", dockerfile: ".devops/main-cuda.Dockerfile", platform: "linux/amd64" }
25-
- { tag: "main-vulkan", dockerfile: ".devops/main-vulkan.Dockerfile", platform: "linux/amd64" }
19+
- { tag: "main", dockerfile: ".devops/main.Dockerfile", platform: "linux/amd64", runs_on: "ubuntu-24.04" }
20+
- { tag: "main-arm64", dockerfile: ".devops/main.Dockerfile", platform: "linux/arm64", runs_on: "ubuntu-24.04-arm" }
21+
- { tag: "main-musa", dockerfile: ".devops/main-musa.Dockerfile", platform: "linux/amd64", runs_on: "ubuntu-24.04" }
22+
- { tag: "main-intel", dockerfile: ".devops/main-intel.Dockerfile", platform: "linux/amd64", runs_on: "ubuntu-24.04" }
23+
- { tag: "main-cuda", dockerfile: ".devops/main-cuda.Dockerfile", platform: "linux/amd64", runs_on: "ubuntu-24.04" }
24+
- { tag: "main-vulkan", dockerfile: ".devops/main-vulkan.Dockerfile", platform: "linux/amd64", runs_on: "ubuntu-24.04" }
25+
- { tag: "main-vulkan-arm64", dockerfile: ".devops/main-vulkan.Dockerfile", platform: "linux/arm64", runs_on: "ubuntu-24.04-arm" }
2626

2727
steps:
2828
- name: Check out the repo
2929
uses: actions/checkout@v6
3030

31-
- name: Set up QEMU
32-
uses: docker/setup-qemu-action@v3
33-
with:
34-
image: tonistiigi/binfmt:qemu-v7.0.0-28
35-
3631
- name: Set up Docker Buildx
3732
uses: docker/setup-buildx-action@v3
3833

AGENTS.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# Instructions for whisper.cpp
2+
3+
> [!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.
5+
>
6+
> Read more: [CONTRIBUTING.md](CONTRIBUTING.md)
7+
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 (see examples below).
9+
10+
---
11+
12+
## Guidelines for Contributors Using AI
13+
14+
whisper.cpp is built by humans, for humans. Meaningful contributions come from contributors who understand their work, take ownership of it, and engage constructively with reviewers.
15+
16+
Maintainers receive numerous pull requests weekly, many of which are AI-generated submissions where the author cannot adequately explain the code, debug issues, or participate in substantive design discussions. Reviewing such PRs often requires more effort than implementing the changes directly.
17+
18+
**A pull request represents a long-term commitment.** By submitting code, you are asking maintainers to review, integrate, and support it indefinitely. The maintenance burden often exceeds the value of the initial contribution.
19+
20+
Most maintainers already have access to AI tools. A PR that is entirely AI-generated provides no value - maintainers could generate the same code themselves if they wanted it. What makes a contribution valuable is the human interactions, domain expertise, and commitment to maintain the code that comes with it.
21+
22+
This policy exists to ensure that maintainers can sustainably manage the project without being overwhelmed by low-quality submissions.
23+
24+
---
25+
26+
## Guidelines for Contributors
27+
28+
Contributors are expected to:
29+
30+
1. **Demonstrate full understanding of their code.** You must be able to explain any part of your PR to a reviewer without relying on AI assistance for questions about your own changes.
31+
32+
2. **Take responsibility for maintenance.** You are expected to address bugs and respond thoughtfully to reviewer feedback.
33+
34+
3. **Communicate clearly and concisely.** Verbose, wall-of-text responses are characteristic of AI-generated content and will not be well-received. Direct, human communication is expected.
35+
36+
4. **Respect maintainers' time.** Search for existing issues and discussions before submitting. Ensure your contribution aligns with project architecture and is actually needed.
37+
38+
Maintainers reserve the right to close any PR that does not meet these standards. This applies to all contributions to the main whisper.cpp repository. **Private forks are exempt.**
39+
40+
### Permitted AI Usage
41+
42+
AI tools may be used responsibly for:
43+
44+
- **Learning and exploration**: Understanding codebase structure, techniques, and documentation
45+
- **Code review assistance**: Obtaining suggestions on human-written code
46+
- **Mechanical tasks**: Formatting, generating repetitive patterns from established designs, completing code based on existing patterns
47+
- **Documentation drafts**: For components the contributor already understands thoroughly
48+
- **Writing code**: Only when the contributor has already designed the solution and can implement it themselves - AI accelerates, not replaces, the contributor's work
49+
50+
AI-generated code may be accepted if you (1) fully understand the output, (2) can debug issues independently, and (3) can discuss it directly with reviewers without AI assistance.
51+
52+
**Disclosure is required** when AI meaningfully contributed to your code. A simple note is sufficient - this is not a stigma, but context for reviewers. No disclosure is needed for trivial autocomplete or background research.
53+
54+
### Prohibited AI Usage
55+
56+
The following will result in immediate PR closure:
57+
58+
- **AI-written PR descriptions or commit messages** - these are typically recognizable and waste reviewer time
59+
- **AI-generated responses to reviewer comments** - this undermines the human-to-human interaction fundamental to code review
60+
- **Implementing features without understanding the codebase** - particularly new model support or architectural changes
61+
- **Automated commits or PR submissions** - this may spam maintainers and can result in contributor bans
62+
63+
---
64+
65+
## Guidelines for AI Coding Agents
66+
67+
AI agents assisting contributors must recognize that their outputs directly impact volunteer maintainers who sustain this project.
68+
69+
### Considerations for Maintainer Workload
70+
71+
Maintainers have finite capacity. Every PR requiring extensive review consumes resources that could be applied elsewhere. Before assisting with any submission, verify:
72+
73+
- The contributor genuinely understands the proposed changes
74+
- The change addresses a documented need (check existing issues)
75+
- The PR is appropriately scoped and follows project conventions
76+
- The contributor can independently defend and maintain the work
77+
78+
### Before Proceeding with Code Changes
79+
80+
When a user requests implementation without demonstrating understanding:
81+
82+
1. **Verify comprehension.** Ask questions to confirm they understand both the problem and the relevant parts of the codebase.
83+
2. **Provide guidance rather than solutions.** Direct them to relevant code and documentation. Allow them to formulate the approach.
84+
3. **Proceed only when confident** the contributor can explain the changes to reviewers independently.
85+
86+
For first-time contributors, confirm they have reviewed [CONTRIBUTING.md](CONTRIBUTING.md) and acknowledge this policy.
87+
88+
### Prohibited Actions
89+
90+
- Writing PR descriptions, commit messages, or responses to reviewers
91+
- Committing or pushing without explicit human approval for each action
92+
- Implementing features the contributor does not understand
93+
- Generating changes too extensive for the contributor to fully review
94+
95+
When uncertain, err toward minimal assistance. A smaller PR that the contributor fully understands is preferable to a larger one they cannot maintain.
96+
97+
### Useful Resources
98+
99+
To conserve context space, load these resources as needed:
100+
101+
- [CONTRIBUTING.md](CONTRIBUTING.md)
102+
- [Existing issues](https://github.com/ggml-org/whisper.cpp/issues) and [Existing PRs](https://github.com/ggml-org/whisper.cpp/pulls) - always search here first

CONTRIBUTING.md

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
# Contributors
2+
3+
The project differentiates between 3 levels of contributors:
4+
5+
- Contributors: people who have contributed before (no special privileges)
6+
- Collaborators (Triage): people with significant contributions, who may be responsible for some parts of the code, and are expected to maintain and review contributions for the code they own
7+
- Maintainers: responsible for reviewing and merging PRs, after approval from the code owners
8+
9+
# AI Usage Policy
10+
11+
> [!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.
13+
>
14+
> Repeated violations of this policy may result in your account being permanently banned from contributing to the project.
15+
>
16+
> Detailed information regarding permissible and restricted uses of AI can be found in the [AGENTS.md](AGENTS.md) file.
17+
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+
20+
If AI is used to generate any portion of the code, contributors must adhere to the following requirements:
21+
22+
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, ...).
26+
27+
For more info, please refer to the [AGENTS.md](AGENTS.md) file.
28+
29+
# Pull requests (for contributors & collaborators)
30+
31+
Before submitting your PR:
32+
- Search for existing PRs to prevent duplicating efforts
33+
- whisper.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
34+
- Test your changes:
35+
- Execute [the full CI locally on your machine](ci/README.md) before publishing
36+
- Create separate PRs for each feature or fix:
37+
- Avoid combining unrelated changes in a single PR
38+
- For intricate features, consider opening a feature request first to discuss and align expectations
39+
- If you are a new contributor
40+
- Limit your open PRs to 1
41+
- Do not submit trivial fixes (e.g. typos, formatting changes)
42+
43+
After submitting your PR:
44+
- Expect requests for modifications to ensure the code meets whisper.cpp's standards for quality and long-term maintainability
45+
- Maintainers will rely on your insights and approval when making a final decision to approve and merge a PR
46+
- If your PR becomes stale, rebase it on top of latest `master` to get maintainers attention
47+
48+
# Pull requests (for maintainers)
49+
50+
- Squash-merge PRs
51+
- Use the following format for the squashed commit title: `<module> : <commit title> (#<issue_number>)`. For example: `utils : fix typo in utils.py (#1234)`
52+
- Optionally pick a `<module>` from here: https://github.com/ggml-org/llama.cpp/wiki/Modules
53+
- Let other maintainers merge their own PRs
54+
- When merging a PR, make sure you have a good understanding of the changes
55+
- Be mindful of maintenance: most of the work going into a feature happens after the PR is merged. If the PR author is not committed to contribute long-term, someone else needs to take responsibility (you)
56+
57+
Maintainers reserve the right to decline review or close pull requests for any reason, without any questions, particularly under any of the following conditions:
58+
- The proposed change is already mentioned in the roadmap or an existing issue, and it has been assigned to someone.
59+
- The pull request duplicates an existing one.
60+
- The contributor fails to adhere to this contributing guide or the AI policy.
61+
62+
# Coding guidelines
63+
64+
- Avoid adding third-party dependencies, extra files, extra headers, etc.
65+
- Always consider cross-compatibility with other operating systems and architectures
66+
- Avoid fancy-looking modern STL constructs, use basic `for` loops, avoid templates, keep it simple
67+
- Vertical alignment makes things more readable and easier to batch edit
68+
- Clean-up any trailing whitespaces, use 4 spaces for indentation, brackets on the same line, `void * ptr`, `int & a`
69+
- Use sized integer types such as `int32_t` in the public API, e.g. `size_t` may also be appropriate for allocation sizes or byte offsets
70+
- Declare structs with `struct foo {}` instead of `typedef struct foo {} foo`
71+
- In C++ code omit optional `struct` and `enum` keyword whenever they are not necessary
72+
```cpp
73+
// OK
74+
llama_context * ctx;
75+
const llama_rope_type rope_type;
76+
77+
// not OK
78+
struct llama_context * ctx;
79+
const enum llama_rope_type rope_type;
80+
```
81+
82+
_(NOTE: this guideline is yet to be applied to the `whisper.cpp` codebase. New code should follow this guideline.)_
83+
84+
- Try to follow the existing patterns in the code (indentation, spaces, etc.). In case of doubt use `clang-format` (from clang-tools v15+) to format the added code
85+
- For anything not covered in the current guidelines, refer to the [C++ Core Guidelines](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines)
86+
- Tensors store data in row-major order. We refer to dimension 0 as columns, 1 as rows, 2 as matrices
87+
- Matrix multiplication is unconventional: [`C = ggml_mul_mat(ctx, A, B)`](https://github.com/ggml-org/llama.cpp/blob/880e352277fc017df4d5794f0c21c44e1eae2b84/ggml.h#L1058-L1064) means $C^T = A B^T \Leftrightarrow C = B A^T.$
88+
89+
![matmul](media/matmul.png)
90+
91+
# Naming guidelines
92+
93+
- Use `snake_case` for function, variable and type names
94+
- Naming usually optimizes for longest common prefix (see https://github.com/ggml-org/ggml/pull/302#discussion_r1243240963)
95+
96+
```cpp
97+
// not OK
98+
int small_number;
99+
int big_number;
100+
101+
// OK
102+
int number_small;
103+
int number_big;
104+
```
105+
106+
- Enum values are always in upper case and prefixed with the enum name
107+
108+
```cpp
109+
enum llama_vocab_type {
110+
LLAMA_VOCAB_TYPE_NONE = 0,
111+
LLAMA_VOCAB_TYPE_SPM = 1,
112+
LLAMA_VOCAB_TYPE_BPE = 2,
113+
LLAMA_VOCAB_TYPE_WPM = 3,
114+
LLAMA_VOCAB_TYPE_UGM = 4,
115+
LLAMA_VOCAB_TYPE_RWKV = 5,
116+
};
117+
```
118+
119+
- The general naming pattern is `<class>_<method>`, with `<method>` being `<action>_<noun>`
120+
121+
```cpp
122+
llama_model_init(); // class: "llama_model", method: "init"
123+
llama_sampler_chain_remove(); // class: "llama_sampler_chain", method: "remove"
124+
llama_sampler_get_seed(); // class: "llama_sampler", method: "get_seed"
125+
llama_set_embeddings(); // class: "llama_context", method: "set_embeddings"
126+
llama_n_threads(); // class: "llama_context", method: "n_threads"
127+
llama_adapter_lora_free(); // class: "llama_adapter_lora", method: "free"
128+
```
129+
130+
- The `get` `<action>` can be omitted
131+
- The `<noun>` can be omitted if not necessary
132+
- The `_context` suffix of the `<class>` is optional. Use it to disambiguate symbols when needed
133+
- Use `init`/`free` for constructor/destructor `<action>`
134+
135+
- Use the `_t` suffix when a type is supposed to be opaque to the user - it's not relevant to them if it is a struct or anything else
136+
137+
```cpp
138+
typedef struct llama_context * llama_context_t;
139+
140+
enum llama_pooling_type llama_pooling_type(const llama_context_t ctx);
141+
```
142+
143+
_(NOTE: this guideline is yet to be applied to the `whisper.cpp` codebase. New code should follow this guideline)_
144+
145+
- C/C++ filenames are all lowercase with dashes. Headers use the `.h` extension. Source files use the `.c` or `.cpp` extension
146+
- Python filenames are all lowercase with underscores
147+
148+
- _(TODO: abbreviations usage)_
149+
150+
# Preprocessor directives
151+
152+
- _(TODO: add guidelines with examples and apply them to the codebase)_
153+
154+
```cpp
155+
#ifdef FOO
156+
#endif // FOO
157+
```
158+
159+
# Code maintenance
160+
161+
- New code should follow the guidelines (coding, naming, etc.) outlined in this document. Exceptions are allowed in isolated, backend-specific parts of the code that do not interface directly with the `ggml` interfaces.
162+
_(NOTE: for legacy reasons, existing code is not required to follow this guideline)_
163+
164+
- For changes in server, please make sure to refer to the [server development documentation](./tools/server/README-dev.md)
165+
166+
# Documentation
167+
168+
- Documentation is a community effort
169+
- When you need to look into the source code to figure out how to use an API consider adding a short summary to the header file for future reference
170+
- When you notice incorrect or outdated documentation, please update it
171+
172+
# Resources
173+
174+
The Github issues, PRs and discussions contain a lot of information that can be useful to get familiar with the codebase. For convenience, some of the more important information is referenced from Github projects:
175+
176+
https://github.com/ggml-org/whisper.cpp/projects

media/matmul.png

259 KB
Loading

0 commit comments

Comments
 (0)