Skip to content

Commit d03ba79

Browse files
JohnJohn
authored andcommitted
Merge branch 'server-features' of https://github.com/minarchist/mllama.cpp into server-features
2 parents 4fbfc5a + a744a48 commit d03ba79

File tree

8 files changed

+234
-36
lines changed

8 files changed

+234
-36
lines changed

.devops/nix/jetson-support.nix

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@
88
pkgsCuda,
99
...
1010
}:
11-
lib.optionalAttrs (system == "aarch64-linux") {
12-
packages =
11+
{
12+
legacyPackages =
1313
let
14-
caps.jetson-xavier = "7.2";
15-
caps.jetson-orin = "8.7";
16-
caps.jetson-nano = "5.3";
14+
caps.llamaPackagesXavier = "7.2";
15+
caps.llamaPackagesOrin = "8.7";
16+
caps.llamaPackagesTX2 = "6.2";
17+
caps.llamaPackagesNano = "5.3";
1718

1819
pkgsFor =
1920
cap:
@@ -27,6 +28,12 @@
2728
};
2829
};
2930
in
30-
builtins.mapAttrs (name: cap: ((pkgsFor cap).callPackage ./scope.nix { }).llama-cpp) caps;
31+
builtins.mapAttrs (name: cap: (pkgsFor cap).callPackage ./scope.nix { }) caps;
32+
33+
packages = lib.optionalAttrs (system == "aarch64-linux") {
34+
jetson-xavier = config.legacyPackages.llamaPackagesXavier.llama-cpp;
35+
jetson-orin = config.legacyPackages.llamaPackagesOrin.llama-cpp;
36+
jetson-nano = config.legacyPackages.llamaPackagesNano.llama-cpp;
37+
};
3138
};
3239
}

.github/workflows/build.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,6 @@ jobs:
515515
- name: Build Xcode project
516516
run: xcodebuild -project examples/llama.swiftui/llama.swiftui.xcodeproj -scheme llama.swiftui -sdk iphoneos CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= -destination 'generic/platform=iOS' build
517517

518-
519518
# freeBSD-latest:
520519
# runs-on: macos-12
521520
# steps:

.github/workflows/nix-ci.yml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: Nix CI
2+
3+
on:
4+
workflow_dispatch: # allows manual triggering
5+
push:
6+
branches:
7+
- master
8+
paths: ['.github/workflows/**', '**/CMakeLists.txt', '**/Makefile', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu', '**/*.swift', '**/*.m', '**/*.sh', '**/*.py', '**/*.nix']
9+
pull_request:
10+
types: [opened, synchronize, reopened]
11+
paths: ['**/CMakeLists.txt', '**/Makefile', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu', '**/*.swift', '**/*.m', '**/*.sh', '**/*.py', '**/*.nix']
12+
13+
jobs:
14+
nix-eval:
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
os: [ ubuntu-latest, macos-latest ]
19+
runs-on: ${{ matrix.os }}
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
- name: Install Nix
24+
uses: DeterminateSystems/nix-installer-action@v9
25+
with:
26+
github-token: ${{ secrets.GITHUB_TOKEN }}
27+
extra-conf: |
28+
extra-substituters = https://${{ vars.CACHIX_NAME }}.cachix.org https://cuda-maintainers.cachix.org
29+
extra-trusted-public-keys = ${{ vars.CACHIX_PUBLIC_KEY }} cuda-maintainers.cachix.org-1:0dq3bujKpuEPMCX6U4WylrUDZ9JyUG0VpVZa7CNfq5E=
30+
- uses: DeterminateSystems/magic-nix-cache-action@v2
31+
with:
32+
upstream-cache: https://${{ matrix.cachixName }}.cachix.org
33+
- name: List all flake outputs
34+
run: nix flake show --all-systems
35+
- name: Show all output paths
36+
run: >
37+
nix run github:nix-community/nix-eval-jobs
38+
-- --gc-roots-dir gcroot
39+
--flake
40+
".#packages.$(nix eval --raw --impure --expr builtins.currentSystem)"
41+
nix-build:
42+
if: ${{ vars.CACHIX_NAME != '' }}
43+
strategy:
44+
fail-fast: false
45+
matrix:
46+
os: [ ubuntu-latest, macos-latest ]
47+
runs-on: ${{ matrix.os }}
48+
steps:
49+
- name: Checkout repository
50+
uses: actions/checkout@v4
51+
- name: Install Nix
52+
uses: DeterminateSystems/nix-installer-action@v9
53+
with:
54+
github-token: ${{ secrets.GITHUB_TOKEN }}
55+
extra-conf: |
56+
extra-substituters = https://${{ vars.CACHIX_NAME }}.cachix.org https://cuda-maintainers.cachix.org
57+
extra-trusted-public-keys = ${{ vars.CACHIX_PUBLIC_KEY }} cuda-maintainers.cachix.org-1:0dq3bujKpuEPMCX6U4WylrUDZ9JyUG0VpVZa7CNfq5E=
58+
- uses: DeterminateSystems/magic-nix-cache-action@v2
59+
with:
60+
upstream-cache: https://${{ matrix.cachixName }}.cachix.org
61+
- name: Set-up cachix to push the results to
62+
uses: cachix/cachix-action@v13
63+
with:
64+
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
65+
name: ${{ vars.CACHIX_NAME }}
66+
- name: Build
67+
run: >
68+
nix run github:Mic92/nix-fast-build
69+
-- --skip-cached --no-nom
70+
--flake
71+
".#checks.$(nix eval --raw --impure --expr builtins.currentSystem)"
72+
nix-build-aarch64:
73+
if: ${{ vars.CACHIX_NAME != '' }}
74+
runs-on: ubuntu-latest
75+
steps:
76+
- name: Checkout repository
77+
uses: actions/checkout@v4
78+
- name: Install QEMU
79+
# Copy-paste from https://github.com/orgs/community/discussions/8305#discussioncomment-5888654
80+
run: |
81+
sudo apt-get install -y qemu-user-static qemu-system-aarch64
82+
sudo usermod -a -G kvm $USER
83+
- name: Install Nix
84+
uses: DeterminateSystems/nix-installer-action@v9
85+
with:
86+
github-token: ${{ secrets.GITHUB_TOKEN }}
87+
extra-conf: |
88+
extra-platforms = aarch64-linux
89+
extra-system-features = nixos-test kvm
90+
extra-substituters = https://${{ vars.CACHIX_NAME }}.cachix.org https://cuda-maintainers.cachix.org
91+
extra-trusted-public-keys = ${{ vars.CACHIX_PUBLIC_KEY }} cuda-maintainers.cachix.org-1:0dq3bujKpuEPMCX6U4WylrUDZ9JyUG0VpVZa7CNfq5E=
92+
- uses: DeterminateSystems/magic-nix-cache-action@v2
93+
with:
94+
upstream-cache: https://${{ matrix.cachixName }}.cachix.org
95+
- name: Set-up cachix to push the results to
96+
uses: cachix/cachix-action@v13
97+
with:
98+
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
99+
name: ${{ vars.CACHIX_NAME }}
100+
- name: Show all output paths
101+
run: >
102+
nix run github:nix-community/nix-eval-jobs
103+
-- --gc-roots-dir gcroot
104+
--flake
105+
".#packages.aarch64-linux"
106+
- name: Build
107+
run: >
108+
nix run github:Mic92/nix-fast-build
109+
-- --skip-cached --no-nom
110+
--systems aarch64-linux
111+
--flake
112+
".#checks.aarch64-linux"
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: update-flake-lock
2+
on:
3+
workflow_dispatch:
4+
schedule:
5+
- cron: '0 0 * * 0' # runs weekly on Sunday at 00:00
6+
7+
jobs:
8+
lockfile:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout repository
12+
uses: actions/checkout@v4
13+
- name: Install Nix
14+
uses: DeterminateSystems/nix-installer-action@main
15+
- name: Update flake.lock
16+
uses: DeterminateSystems/update-flake-lock@main
17+
with:
18+
pr-title: "nix: update flake.lock"
19+
pr-labels: |
20+
nix
21+
pr-reviewers: philiptaron,SomeoneSerge
22+
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/nix-flakestry.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Make the flake discoverable on https://flakestry.dev and https://flakehub.com/flakes
2+
name: "Publish a flake to flakestry & flakehub"
3+
on:
4+
push:
5+
tags:
6+
- "*"
7+
workflow_dispatch:
8+
inputs:
9+
tag:
10+
description: "The existing tag to publish"
11+
type: "string"
12+
required: true
13+
jobs:
14+
flakestry-publish:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
id-token: "write"
18+
contents: "read"
19+
steps:
20+
- uses: flakestry/flakestry-publish@main
21+
with:
22+
version: "${{ inputs.tag || github.ref_name }}"
23+
flakehub-publish:
24+
runs-on: "ubuntu-latest"
25+
permissions:
26+
id-token: "write"
27+
contents: "read"
28+
steps:
29+
- uses: "actions/checkout@v4"
30+
with:
31+
ref: "${{ (inputs.tag != null) && format('refs/tags/{0}', inputs.tag) || '' }}"
32+
- uses: "DeterminateSystems/nix-installer-action@main"
33+
- uses: "DeterminateSystems/flakehub-push@main"
34+
with:
35+
visibility: "public"
36+
tag: "${{ inputs.tag }}"

flake.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,29 @@
66
flake-parts.url = "github:hercules-ci/flake-parts";
77
};
88

9+
# Optional binary cache
10+
nixConfig = {
11+
extra-substituters = [
12+
# Populated by the CI in ggerganov/llama.cpp
13+
"https://llama-cpp.cachix.org"
14+
15+
# A development cache for nixpkgs imported with `config.cudaSupport = true`.
16+
# Populated by https://hercules-ci.com/github/SomeoneSerge/nixpkgs-cuda-ci.
17+
# This lets one skip building e.g. the CUDA-enabled openmpi.
18+
# TODO: Replace once nix-community obtains an official one.
19+
"https://cuda-maintainers.cachix.org"
20+
];
21+
22+
# Verify these are the same keys as published on
23+
# - https://app.cachix.org/cache/llama-cpp
24+
# - https://app.cachix.org/cache/cuda-maintainers
25+
extra-trusted-public-keys = [
26+
"llama-cpp.cachix.org-1:H75X+w83wUKTIPSO1KWy9ADUrzThyGs8P5tmAbkWhQc="
27+
"cuda-maintainers.cachix.org-1:0dq3bujKpuEPMCX6U4WylrUDZ9JyUG0VpVZa7CNfq5E="
28+
];
29+
};
30+
31+
932
# For inspection, use `nix flake show github:ggerganov/llama.cpp` or the nix repl:
1033
#
1134
# ```bash
@@ -74,26 +97,48 @@
7497
{
7598
config,
7699
lib,
100+
system,
77101
pkgs,
78102
pkgsCuda,
79103
pkgsRocm,
80104
...
81105
}:
82106
{
107+
# Unlike `.#packages`, legacyPackages may contain values of
108+
# arbitrary types (including nested attrsets) and may even throw
109+
# exceptions. This attribute isn't recursed into by `nix flake
110+
# show` either.
111+
#
112+
# You can add arbitrary scripts to `.devops/nix/scope.nix` and
113+
# access them as `nix build .#llamaPackages.${scriptName}` using
114+
# the same path you would with an overlay.
115+
legacyPackages = {
116+
llamaPackages = pkgs.callPackage .devops/nix/scope.nix { inherit llamaVersion; };
117+
llamaPackagesCuda = pkgsCuda.callPackage .devops/nix/scope.nix { inherit llamaVersion; };
118+
llamaPackagesRocm = pkgsRocm.callPackage .devops/nix/scope.nix { inherit llamaVersion; };
119+
};
120+
83121
# We don't use the overlay here so as to avoid making too many instances of nixpkgs,
84122
# cf. https://zimbatm.com/notes/1000-instances-of-nixpkgs
85123
packages =
86124
{
87-
default = (pkgs.callPackage .devops/nix/scope.nix { inherit llamaVersion; }).llama-cpp;
125+
default = config.legacyPackages.llamaPackages.llama-cpp;
88126
}
89127
// lib.optionalAttrs pkgs.stdenv.isLinux {
90128
opencl = config.packages.default.override { useOpenCL = true; };
91-
cuda = (pkgsCuda.callPackage .devops/nix/scope.nix { inherit llamaVersion; }).llama-cpp;
92-
rocm = (pkgsRocm.callPackage .devops/nix/scope.nix { inherit llamaVersion; }).llama-cpp;
129+
cuda = config.legacyPackages.llamaPackagesCuda.llama-cpp;
93130

94131
mpi-cpu = config.packages.default.override { useMpi = true; };
95132
mpi-cuda = config.packages.default.override { useMpi = true; };
133+
}
134+
// lib.optionalAttrs (system == "x86_64-linux") {
135+
rocm = config.legacyPackages.llamaPackagesRocm.llama-cpp;
96136
};
137+
138+
# Packages exposed in `.#checks` will be built by the CI and by
139+
# `nix flake check`. Currently we expose all packages, but we could
140+
# make more granular choices
141+
checks = config.packages;
97142
};
98143
};
99144
}

0 commit comments

Comments
 (0)