forked from JustVugg/colibri
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
121 lines (103 loc) · 3.32 KB
/
Copy pathflake.nix
File metadata and controls
121 lines (103 loc) · 3.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
{
description = "colibrì — run GLM-5.2 (744B MoE) on a consumer machine with ~25 GB RAM";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
# Python with the packages needed by the offline converter tools
pythonEnv = pkgs.python3.withPackages (ps: with ps; [
torch
safetensors
huggingface-hub
numpy
tokenizers
datasets
]);
colibri = pkgs.stdenv.mkDerivation {
pname = "colibri";
version = "1.0";
src = ./.;
nativeBuildInputs = [ pkgs.makeWrapper ];
buildInputs = [
pkgs.gcc
pkgs.gmp
];
# Use x86-64-v3 (AVX2) for a portable binary; override with ARCH=native for local builds
ARCH = "x86-64-v3";
buildPhase = ''
runHook preBuild
make -C c glm ARCH="$ARCH"
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p $out/bin
cp c/glm $out/bin/glm
# Wrap coli (the Python CLI) so it finds the right python and the engine
mkdir -p $out/share/colibri
cp c/coli $out/share/colibri/coli
chmod +x $out/share/colibri/coli
cp -r c/tools $out/share/colibri/tools
makeWrapper ${pythonEnv}/bin/python $out/bin/coli \
--add-flags "$out/share/colibri/coli" \
--set PYTHONPATH "${pythonEnv}/${pkgs.python3.sitePackages}"
runHook postInstall
'';
checkPhase = ''
runHook preCheck
cd c
make test-c
cd ..
runHook postCheck
'';
doCheck = true;
meta = with pkgs.lib; {
description = "Run GLM-5.2 (744B MoE) on a consumer machine with ~25 GB RAM";
homepage = "https://github.com/JustVugg/colibri";
license = licenses.asl20;
platforms = platforms.linux;
mainProgram = "glm";
};
};
in
rec {
packages = {
default = colibri;
inherit colibri;
};
apps = {
default = {
type = "app";
program = "${colibri}/bin/glm";
};
coli = {
type = "app";
program = "${colibri}/bin/coli";
};
};
devShells.default = pkgs.mkShell {
inputsFrom = [ colibri ];
packages = [
pythonEnv
pkgs.gcc
pkgs.gnumake
pkgs.clang-tools # clangd / clang-tidy for IDE support
pkgs.pkg-config
];
shellHook = ''
echo "🐦 colibrì dev shell"
echo " gcc: $(gcc --version | head -1)"
echo " python: $(python3 --version)"
echo ""
echo "Build the engine: make -C c glm"
echo "Run the converter: python c/coli convert --model /path/to/glm52_i4"
echo "Chat: COLI_MODEL=/path/to/glm52_i4 ./c/glm ..."
'';
};
}
);
}