README.md 2.25 KB
Newer Older
1
2
# `llama`

Michael Yang's avatar
Michael Yang committed
3
This package provides Go bindings to [llama.cpp](https://github.com/ggerganov/llama.cpp).
4

5
## Vendoring
6

Michael Yang's avatar
Michael Yang committed
7
Ollama vendors [llama.cpp](https://github.com/ggerganov/llama.cpp/) and [ggml](https://github.com/ggerganov/llama.cpp/tree/master/ggml/src). While we generally strive to contribute changes back upstream to avoid drift, we carry a small set of patches which are applied to the tracking commit.
8

9
10
11
If you update the vendoring code, start by running the following command to establish the tracking llama.cpp repo in the `./vendor/` directory.

```
Michael Yang's avatar
Michael Yang committed
12
make -f Makefile.sync apply-patches
13
14
15
16
17
18
```

### Updating Base Commit

**Pin to new base commit**

Michael Yang's avatar
Michael Yang committed
19
To change the base commit, update `FETCH_HEAD` in Makefile.sync.
20
21
22

When updating to a newer base commit, the existing patches may not apply cleanly and require manual merge resolution.

23
Start by applying the patches. If any of the patches have conflicts, the `git am` will stop at the first failure.
24
25

```
Michael Yang's avatar
Michael Yang committed
26
make -f Makefile.sync apply-patches
27
```
28

Michael Yang's avatar
Michael Yang committed
29
30
31
If there are conflicts, you will see an error message. Resolve the conflicts in `./vendor/`, and continue the patch series with `git am --continue` and rerun `make -f Makefile.sync apply-patches`. Repeat until all patches are successfully applied.

Once all patches are applied, commit the changes to the tracking repository.
32
33

```
Michael Yang's avatar
Michael Yang committed
34
make -f Makefile.sync format-patches sync
35
36
37
38
```

### Generating Patches

39
When working on new fixes or features that impact vendored code, use the following model. First get a clean tracking repo with all current patches applied:
40
41

```
Michael Yang's avatar
Michael Yang committed
42
make -f Makefile.sync clean apply-patches
43
44
```

45
Iterate until you're ready to submit PRs. Once your code is ready, commit a change in the `./vendor/` directory, then generate the patches for ollama with
46
47

```
Michael Yang's avatar
Michael Yang committed
48
make -f Makefile.sync format-patches
49
50
51
52
53
54
```

In your `./vendor/` directory, create a branch, and cherry-pick the new commit to that branch, then submit a PR upstream to llama.cpp.

Commit the changes in the ollama repo and submit a PR to Ollama, which will include the vendored code update with your change, along with the patches.

55
After your PR upstream is merged, follow the **Updating Base Commit** instructions above, however first remove your patch before running `apply-patches` since the new base commit contains your change already.