Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: utilityai/llama-cpp-rs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0.1.33
Choose a base ref
...
head repository: utilityai/llama-cpp-rs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
Loading
Showing with 3,449 additions and 2,385 deletions.
  1. +12 −10 .github/workflows/llama-cpp-rs-check.yml
  2. +1 −1 .github/workflows/publish-upon-release.yml
  3. +22 −12 .github/workflows/update-llama-cpp.yml
  4. +19 −7 .github/workflows/update-toml-version.yaml
  5. +549 −983 Cargo.lock
  6. +8 −6 Cargo.toml
  7. +2 −2 README.md
  8. +19 −0 examples/embeddings/Cargo.toml
  9. +244 −0 examples/embeddings/src/main.rs
  10. +7 −3 { → examples}/simple/Cargo.toml
  11. +107 −21 { → examples}/simple/src/main.rs
  12. +86 −0 examples/usage.rs
  13. +24 −13 llama-cpp-2/Cargo.toml
  14. +0 −63 llama-cpp-2/benches/generate.rs
  15. +0 −52 llama-cpp-2/benches/grammar_bias.rs
  16. +235 −10 llama-cpp-2/src/context.rs
  17. +104 −35 llama-cpp-2/src/context/kv_cache.rs
  18. +266 −38 llama-cpp-2/src/context/params.rs
  19. +0 −257 llama-cpp-2/src/context/sample.rs
  20. +0 −491 llama-cpp-2/src/grammar.rs
  21. +33 −0 llama-cpp-2/src/grammar/tests.rs
  22. +116 −3 llama-cpp-2/src/lib.rs
  23. +15 −0 llama-cpp-2/src/llama_backend.rs
  24. +70 −7 llama-cpp-2/src/llama_batch.rs
  25. +308 −51 llama-cpp-2/src/model.rs
  26. +113 −3 llama-cpp-2/src/model/params.rs
  27. +131 −0 llama-cpp-2/src/model/params/kv_overrides.rs
  28. +436 −0 llama-cpp-2/src/sampling.rs
  29. +7 −60 llama-cpp-2/src/timing.rs
  30. +91 −16 llama-cpp-2/src/token/data_array.rs
  31. +38 −47 llama-cpp-2/src/token_type.rs
  32. +51 −25 llama-cpp-sys-2/Cargo.toml
  33. +2 −2 llama-cpp-sys-2/README.md
  34. +329 −141 llama-cpp-sys-2/build.rs
  35. +1 −1 llama-cpp-sys-2/llama.cpp
  36. +0 −23 llama-cpp-sys-2/src/lib.rs
  37. +1 −0 llama-cpp-sys-2/wrapper.h
  38. +2 −2 test-build.Dockerfile
22 changes: 12 additions & 10 deletions .github/workflows/llama-cpp-rs-check.yml
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
submodules: recursive
- name: Install Compile Deps
@@ -34,7 +34,7 @@ jobs:
- name: Fmt
run: cargo fmt
- name: Test
run: cargo test
run: cargo test --features sampler
arm64:
name: Check that it builds on various targets
runs-on: ubuntu-latest
@@ -43,15 +43,15 @@ jobs:
target: [ linux/arm64, linux/amd64 ]
steps:
- name: checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- name: Setup QEMU
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf
with:
platforms: arm64,amd64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5
- name: Build
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
file: test-build.Dockerfile
target: base-cuda
@@ -61,22 +61,24 @@ jobs:
runs-on: macos-latest
steps:
- name: checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
submodules: recursive
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Build
run: cargo build
run: cargo build --features sampler
windows:
name: Check that it builds on windows
runs-on: windows-latest
steps:
- name: checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
submodules: recursive
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Build
run: cargo build
run: cargo build --features sampler
- name: Test
run: cargo test --features sampler
2 changes: 1 addition & 1 deletion .github/workflows/publish-upon-release.yml
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
submodules: recursive
- name: Publish crates for llama-cpp-sys-2
34 changes: 22 additions & 12 deletions .github/workflows/update-llama-cpp.yml
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ name: Update llama cpp nightly
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch: {}
workflow_dispatch: { }

permissions:
pull-requests: write
@@ -13,23 +13,33 @@ jobs:
runs-on: ubuntu-latest
name: Update llama cpp
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- name: Set date
run: echo "DATE=$(date -I)" >> $GITHUB_ENV
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
name: Checkout latest
with:
submodules: recursive
- name: create branch
run: git checkout -b update-llama-cpp-$(date -I)
- name: update submodules
- name: Create branch
run: git checkout -b update-llama-cpp-${{ env.DATE }}
- name: Update submodules
run: git submodule update --remote
- name: config git
- name: Config git
run: |
git config --global user.email "marcus@utilityai.ca"
git config --global user.name "Marcus Dunn"
- name: commit
- name: Commit
run: git commit -am "updated llama.cpp"
- name: push
run: git push --set-upstream origin update-llama-cpp-$(date -I) --force
- name: create draft pr
- name: Push
run: git push --set-upstream origin update-llama-cpp-${{ env.DATE }} --force
- name: Close any outdated PRs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo ${{ secrets.GITHUB_TOKEN }} | gh auth login --with-token
gh pr create --fill --draft --body "please close and reopen this pull request to trigger the checks"
gh pr list --json number,title --jq '.[] | select(.title | contains("Updated llama-cpp (bot)")) | .number' | xargs -I {} gh pr close {}
- name: Create open PR
env:
GITHUB_TOKEN: ${{ secrets.LLAMA_CPP_RS_UPDATE_LLAMA_CPP_ACTION}}
run: |
unset GITHUB_TOKEN
echo ${{ secrets.LLAMA_CPP_RS_UPDATE_LLAMA_CPP_ACTION }} | gh auth login --with-token
gh pr create --fill --head update-llama-cpp-${{ env.DATE }} --title "Updated llama-cpp (bot)"
26 changes: 19 additions & 7 deletions .github/workflows/update-toml-version.yaml
Original file line number Diff line number Diff line change
@@ -2,19 +2,22 @@ name: Update version in TOML files

on:
repository_dispatch:
types: [trigger-update-toml-version]
types: [ trigger-update-toml-version ]
workflow_dispatch:

permissions:
contents: write
pull-requests: write

jobs:
modify_files:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
submodules: recursive

- name: Update version in TOML files
env:
@@ -28,14 +31,23 @@ jobs:
sed -i "s/^version = \".*\"/version = \"$NEXT_VERSION\"/g" llama-cpp-sys-2/Cargo.toml
# Update version in llama-cpp-2 Cargo.toml
sed -i "s/^version = \".*\"/version = \"$NEXT_VERSION\"/g" llama-cpp-2/Cargo.toml
sed -i "s/^\(llama-cpp-sys-2 = { path = \"\.\.\/llama-cpp-sys-2\", version = \)\"$CURRENT_VERSION\"/\1\"$NEXT_VERSION\"/" llama-cpp-2/Cargo.toml
sed -i "s/^\(llama-cpp-sys-2 = { path = \"\.\.\/llama-cpp-sys-2\", version = \)\"$CURRENT_VERSION\"/\1\"$NEXT_VERSION\"/" llama-cpp-2/Cargo.toml
# Update the version in the simple Cargo.toml
sed -i "s/^version = \".*\"/version = \"$NEXT_VERSION\"/g" examples/simple/Cargo.toml
sed -i "s/^\(llama-cpp-2 = { path = \"\.\.\/llama-cpp-2\", version = \)\"$CURRENT_VERSION\"/\1\"$NEXT_VERSION\"/" examples/simple/Cargo.toml
# Update the version in the root embeddings Cargo.toml
sed -i "s/^version = \".*\"/version = \"$NEXT_VERSION\"/g" examples/embeddings/Cargo.toml
sed -i "s/^\(llama-cpp-2 = { path = \"\.\.\/llama-cpp-2\", version = \)\"$CURRENT_VERSION\"/\1\"$NEXT_VERSION\"/" examples/embeddings/Cargo.toml
# Update Cargo.lock by running cargo check
cargo check
# Commit the changes
git config --global user.email "actions@github.com"
git config --global user.name "GitHub Actions"
git add llama-cpp-sys-2/Cargo.toml llama-cpp-2/Cargo.toml
git add llama-cpp-sys-2/Cargo.toml llama-cpp-2/Cargo.toml examples/simple/Cargo.toml examples/embeddings/Cargo.toml Cargo.lock
git commit -m "Bump version to $NEXT_VERSION [skip ci]"
# Create a branch for the changes
# Create a branch for the changes
git checkout -b version-bump-$NEXT_VERSION
# Push the changes and create a pull request
git push origin version-bump-$NEXT_VERSION
gh pr create --base main --head version-bump-$NEXT_VERSION --title "Bump version to $NEXT_VERSION"
git push origin version-bump-$NEXT_VERSION --force
gh pr create --base main --head version-bump-$NEXT_VERSION --title "Bumped version to $NEXT_VERSION" --fill
Loading