From 4f0319540b6a1db4f827eb4b31e262a9a510dfce Mon Sep 17 00:00:00 2001 From: marcus Date: Wed, 17 Jan 2024 13:49:42 -0800 Subject: [PATCH] test builds --- .github/dependabot.yml | 4 ++++ .github/workflows/llama-cpp-rs-check.yml | 22 +++++++++++++++++++++- llama-cpp-2/README.md | 17 ++++++++++++++--- llama-cpp-sys-2/build.rs | 12 ++++++++++++ test-build.Dockerfile | 11 +++++++++++ 5 files changed, 62 insertions(+), 4 deletions(-) create mode 100644 test-build.Dockerfile diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 53f8242a..caf29f5e 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -4,3 +4,7 @@ updates: directory: "/" schedule: interval: "weekly" + - package-ecosystem: github-actions + directory: / + schedule: + interval: "weekly" diff --git a/.github/workflows/llama-cpp-rs-check.yml b/.github/workflows/llama-cpp-rs-check.yml index d4896da6..b23234de 100644 --- a/.github/workflows/llama-cpp-rs-check.yml +++ b/.github/workflows/llama-cpp-rs-check.yml @@ -34,4 +34,24 @@ jobs: - name: Fmt run: cargo fmt - name: Test - run: cargo test \ No newline at end of file + run: cargo test + arm64: + name: Check that it builds on various targets + runs-on: ubuntu-latest + strategy: + matrix: + target: [ linux/arm64, linux/amd64 ] + steps: + - name: checkout + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + - name: Setup QEMU + uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 + with: + platforms: arm64,amd64 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 + - name: Build + uses: docker/build-push-action@v5 + with: + file: test-build.Dockerfile + platforms: ${{ matrix.target }} \ No newline at end of file diff --git a/llama-cpp-2/README.md b/llama-cpp-2/README.md index 501c7dee..85dde67d 100644 --- a/llama-cpp-2/README.md +++ b/llama-cpp-2/README.md @@ -6,13 +6,24 @@ A wrapper around the [llama-cpp](https://github.com/ggerganov/llama.cpp/) librar # Info -This is part of the project powering all the LLMs at [utilityai], it is tighly coupled llama.cpp and mimics its API as closly as possible while being safe in order to stay up to date. +This is part of the project powering all the LLMs at [utilityai], it is tightly coupled llama.cpp and mimics its API as +closly as possible while being safe in order to stay up to date. + +# Dependencies + +This uses bindgen to build the bindings to llama.cpp. This means that you need to have clang installed on your system. + +If this is a problem for you, open an issue, and we can look into including the bindings. + +See [bindgen](https://rust-lang.github.io/rust-bindgen/requirements.html) for more information. # Disclaimer -This is not a simple library to use. In an ideal work a nice abstraction would be written on top of this crate to provide an ergonomic API - the benfits of this crate over raw bindings is safety and not much else. +This is not a simple library to use. In an ideal work a nice abstraction would be written on top of this crate to +provide an ergonomic API - the benefits of this crate over raw bindings is safety and not much else. -We compensate for this shortcoming (we hope) by providing lots of examples and good documentation. Testing is a work in progress. +We compensate for this shortcoming (we hope) by providing lots of examples and good documentation. Testing is a work in +progress. # Contributing diff --git a/llama-cpp-sys-2/build.rs b/llama-cpp-sys-2/build.rs index 97ad89af..e683bf7b 100644 --- a/llama-cpp-sys-2/build.rs +++ b/llama-cpp-sys-2/build.rs @@ -21,6 +21,18 @@ fn main() { println!("cargo:rustc-link-search=native=/usr/local/cuda/lib64"); + if cfg!(target_arch = "aarch64") { + ggml_cuda + .flag_if_supported("-mfp16-format=ieee") + .flag_if_supported("-mno-unaligned-access"); + llama_cpp + .flag_if_supported("-mfp16-format=ieee") + .flag_if_supported("-mno-unaligned-access"); + ggml_cuda + .flag_if_supported("-mfp16-format=ieee") + .flag_if_supported("-mno-unaligned-access"); + } + ggml_cuda .cuda(true) .std("c++11") diff --git a/test-build.Dockerfile b/test-build.Dockerfile new file mode 100644 index 00000000..5d068d6b --- /dev/null +++ b/test-build.Dockerfile @@ -0,0 +1,11 @@ +# Builds the project in a docker container This is used to test arm and x86 builds using github actions + docker. +# This also requires us to declare all the dependencies in the dockerfile usful as documentation. +FROM rust:bookworm AS builder +# Install requirements for bindgen: https://rust-lang.github.io/rust-bindgen/requirements.html +RUN apt update && apt install -y llvm-dev libclang-dev clang +COPY . . +RUN cargo build --release --example simple + +FROM debian:bookworm-slim +COPY --from=builder /target/release/examples/simple /usr/local/bin/simple +ENTRYPOINT ["/usr/local/bin/simple"] \ No newline at end of file