Skip to content

Commit 43001ce

Browse files
committed
2 parents 0347727 + e31fb67 commit 43001ce

File tree

110 files changed

+9347
-3829
lines changed

Some content is hidden

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

110 files changed

+9347
-3829
lines changed

.devops/nix/docker.nix

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
lib,
3+
dockerTools,
4+
buildEnv,
5+
llama-cpp,
6+
interactive ? true,
7+
coreutils,
8+
}:
9+
10+
# A tar that can be fed into `docker load`:
11+
#
12+
# $ nix build .#llamaPackages.docker
13+
# $ docker load < result
14+
15+
# For details and variations cf.
16+
# - https://nixos.org/manual/nixpkgs/unstable/#ssec-pkgs-dockerTools-buildLayeredImage
17+
# - https://discourse.nixos.org/t/a-faster-dockertools-buildimage-prototype/16922
18+
# - https://nixery.dev/
19+
20+
# Approximate (compressed) sizes, at the time of writing, are:
21+
#
22+
# .#llamaPackages.docker: 125M;
23+
# .#llamaPackagesCuda.docker: 537M;
24+
# .#legacyPackages.aarch64-linux.llamaPackagesXavier.docker: 415M.
25+
26+
dockerTools.buildLayeredImage {
27+
name = llama-cpp.pname;
28+
tag = "latest";
29+
30+
contents =
31+
[ llama-cpp ]
32+
++ lib.optionals interactive [
33+
coreutils
34+
dockerTools.binSh
35+
dockerTools.caCertificates
36+
];
37+
}

.devops/nix/package.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,11 @@ effectiveStdenv.mkDerivation (
255255
# Configurations we don't want even the CI to evaluate. Results in the
256256
# "unsupported platform" messages. This is mostly a no-op, because
257257
# cudaPackages would've refused to evaluate anyway.
258-
badPlatforms = optionals (useCuda || useOpenCL || useVulkan) lib.platforms.darwin;
258+
badPlatforms = optionals (useCuda || useOpenCL) lib.platforms.darwin;
259259

260260
# Configurations that are known to result in build failures. Can be
261261
# overridden by importing Nixpkgs with `allowBroken = true`.
262-
broken = (useMetalKit && !effectiveStdenv.isDarwin) || (useVulkan && effectiveStdenv.isDarwin);
262+
broken = (useMetalKit && !effectiveStdenv.isDarwin);
263263

264264
description = "Inference of LLaMA model in pure C/C++${descriptionSuffix}";
265265
homepage = "https://github.com/ggerganov/llama.cpp/";

.devops/nix/scope.nix

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,8 @@ lib.makeScope newScope (
1212
self: {
1313
inherit llamaVersion;
1414
llama-cpp = self.callPackage ./package.nix { };
15+
docker = self.callPackage ./docker.nix { };
16+
docker-min = self.callPackage ./docker.nix { interactive = false; };
17+
sif = self.callPackage ./sif.nix { };
1518
}
1619
)

.devops/nix/sif.nix

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
lib,
3+
singularity-tools,
4+
llama-cpp,
5+
bashInteractive,
6+
interactive ? false,
7+
}:
8+
9+
let
10+
optionalInt = cond: x: if cond then x else 0;
11+
in
12+
singularity-tools.buildImage rec {
13+
inherit (llama-cpp) name;
14+
contents = [ llama-cpp ] ++ lib.optionals interactive [ bashInteractive ];
15+
16+
# These are excessive (but safe) for most variants. Building singularity
17+
# images requires superuser privileges, so we build them inside a VM in a
18+
# writable image of pre-determined size.
19+
#
20+
# ROCm is currently affected by https://github.com/NixOS/nixpkgs/issues/276846
21+
#
22+
# Expected image sizes:
23+
# - cpu/blas: 150M,
24+
# - cuda, all gencodes: 560M,
25+
diskSize = 4096 + optionalInt llama-cpp.useRocm 16384;
26+
memSize = diskSize;
27+
}

.flake8

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
[flake8]
22
max-line-length = 125
3+
ignore = W503

.github/workflows/build.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ jobs:
3737
3838
- name: Build
3939
id: make_build
40+
env:
41+
LLAMA_FATAL_WARNINGS: 1
4042
run: |
4143
CC=gcc-8 make -j $(nproc)
4244
@@ -65,7 +67,7 @@ jobs:
6567
run: |
6668
mkdir build
6769
cd build
68-
cmake ..
70+
cmake .. -DLLAMA_FATAL_WARNINGS=ON
6971
cmake --build . --config Release -j $(nproc)
7072
7173
- name: Test
@@ -100,7 +102,7 @@ jobs:
100102
run: |
101103
mkdir build
102104
cd build
103-
cmake .. -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
105+
cmake .. -DLLAMA_FATAL_WARNINGS=ON -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
104106
cmake --build . --config ${{ matrix.build_type }} -j $(nproc)
105107
106108
- name: Test
@@ -244,6 +246,8 @@ jobs:
244246
245247
- name: Build
246248
id: make_build
249+
env:
250+
LLAMA_FATAL_WARNINGS: 1
247251
run: |
248252
LLAMA_NO_METAL=1 make -j $(sysctl -n hw.logicalcpu)
249253
@@ -277,7 +281,7 @@ jobs:
277281
sysctl -a
278282
mkdir build
279283
cd build
280-
cmake -DLLAMA_METAL=OFF ..
284+
cmake -DLLAMA_FATAL_WARNINGS=ON -DLLAMA_METAL=OFF ..
281285
cmake --build . --config Release -j $(sysctl -n hw.logicalcpu)
282286
283287
- name: Test

.github/workflows/nix-ci-aarch64.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ on:
1919

2020
jobs:
2121
nix-build-aarch64:
22-
if: ${{ vars.CACHIX_NAME != '' }}
2322
runs-on: ubuntu-latest
2423
steps:
2524
- name: Checkout repository
@@ -37,16 +36,16 @@ jobs:
3736
extra-conf: |
3837
extra-platforms = aarch64-linux
3938
extra-system-features = nixos-test kvm
40-
extra-substituters = https://${{ vars.CACHIX_NAME }}.cachix.org https://cuda-maintainers.cachix.org
41-
extra-trusted-public-keys = ${{ vars.CACHIX_PUBLIC_KEY }} cuda-maintainers.cachix.org-1:0dq3bujKpuEPMCX6U4WylrUDZ9JyUG0VpVZa7CNfq5E=
39+
extra-substituters = https://llama-cpp.cachix.org https://cuda-maintainers.cachix.org
40+
extra-trusted-public-keys = llama-cpp.cachix.org-1:H75X+w83wUKTIPSO1KWy9ADUrzThyGs8P5tmAbkWhQc= cuda-maintainers.cachix.org-1:0dq3bujKpuEPMCX6U4WylrUDZ9JyUG0VpVZa7CNfq5E=
4241
- uses: DeterminateSystems/magic-nix-cache-action@v2
4342
with:
4443
upstream-cache: https://${{ matrix.cachixName }}.cachix.org
4544
- name: Set-up cachix to push the results to
4645
uses: cachix/cachix-action@v13
4746
with:
4847
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
49-
name: ${{ vars.CACHIX_NAME }}
48+
name: llama-cpp
5049
- name: Show all output paths
5150
run: >
5251
nix run github:nix-community/nix-eval-jobs

.github/workflows/nix-ci.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ jobs:
2323
with:
2424
github-token: ${{ secrets.GITHUB_TOKEN }}
2525
extra-conf: |
26-
extra-substituters = https://${{ vars.CACHIX_NAME }}.cachix.org https://cuda-maintainers.cachix.org
27-
extra-trusted-public-keys = ${{ vars.CACHIX_PUBLIC_KEY }} cuda-maintainers.cachix.org-1:0dq3bujKpuEPMCX6U4WylrUDZ9JyUG0VpVZa7CNfq5E=
26+
extra-substituters = https://llama-cpp.cachix.org https://cuda-maintainers.cachix.org
27+
extra-trusted-public-keys = llama-cpp.cachix.org-1:H75X+w83wUKTIPSO1KWy9ADUrzThyGs8P5tmAbkWhQc= cuda-maintainers.cachix.org-1:0dq3bujKpuEPMCX6U4WylrUDZ9JyUG0VpVZa7CNfq5E=
2828
- uses: DeterminateSystems/magic-nix-cache-action@v2
2929
with:
3030
upstream-cache: https://${{ matrix.cachixName }}.cachix.org
@@ -37,7 +37,6 @@ jobs:
3737
--flake
3838
".#packages.$(nix eval --raw --impure --expr builtins.currentSystem)"
3939
nix-build:
40-
if: ${{ vars.CACHIX_NAME != '' }}
4140
strategy:
4241
fail-fast: false
4342
matrix:
@@ -51,16 +50,16 @@ jobs:
5150
with:
5251
github-token: ${{ secrets.GITHUB_TOKEN }}
5352
extra-conf: |
54-
extra-substituters = https://${{ vars.CACHIX_NAME }}.cachix.org https://cuda-maintainers.cachix.org
55-
extra-trusted-public-keys = ${{ vars.CACHIX_PUBLIC_KEY }} cuda-maintainers.cachix.org-1:0dq3bujKpuEPMCX6U4WylrUDZ9JyUG0VpVZa7CNfq5E=
53+
extra-substituters = https://llama-cpp.cachix.org https://cuda-maintainers.cachix.org
54+
extra-trusted-public-keys = llama-cpp.cachix.org-1:H75X+w83wUKTIPSO1KWy9ADUrzThyGs8P5tmAbkWhQc= cuda-maintainers.cachix.org-1:0dq3bujKpuEPMCX6U4WylrUDZ9JyUG0VpVZa7CNfq5E=
5655
- uses: DeterminateSystems/magic-nix-cache-action@v2
5756
with:
5857
upstream-cache: https://${{ matrix.cachixName }}.cachix.org
5958
- name: Set-up cachix to push the results to
6059
uses: cachix/cachix-action@v13
6160
with:
6261
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
63-
name: ${{ vars.CACHIX_NAME }}
62+
name: llama-cpp
6463
- name: Build
6564
run: >
6665
nix run github:Mic92/nix-fast-build

.github/workflows/python-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ jobs:
1616
- name: flake8 Lint
1717
uses: py-actions/flake8@v2
1818
with:
19-
ignore: "E203,E211,E221,E225,E231,E241,E251,E261,E266,E501,E701,E704"
19+
ignore: "E203,E211,E221,E225,E231,E241,E251,E261,E266,E501,E701,E704,W503"
2020
exclude: "examples/*,examples/*/**,*/**/__init__.py"

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@
2323
.clang-tidy
2424
.vs/
2525
.vscode/
26+
.idea/
2627

2728
lcov-report/
2829
gcovr-report/
2930

3031
build*
32+
cmake-build-*
3133
out/
3234
tmp/
3335

0 commit comments

Comments
 (0)