Skip to content

Commit da2d18b

Browse files
committed
add Nix flake
this commit adds a Nix flake [1] into the repository. it contains several notable things: - llm-d-inference-sim as a Nix package - inference-perf as a Nix package - a venv-enabled dev shell containing python, pdm, pyright and llm-d-inference-sim if Nix is present in your environment, you may enter the dev shell using `nix develop` (requires flakes to be enabled). the GitHub Actions uses this file to install the necessary dependencies to run end-to-end tests. [1]: https://wiki.nixos.org/wiki/Flakes
1 parent 7fcd027 commit da2d18b

File tree

2 files changed

+233
-0
lines changed

2 files changed

+233
-0
lines changed

flake.lock

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

flake.nix

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
{
2+
inputs = {
3+
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
4+
flake-parts.url = "github:hercules-ci/flake-parts";
5+
6+
pyproject-nix.url = "github:pyproject-nix/pyproject.nix";
7+
pyproject-nix.inputs.nixpkgs.follows = "nixpkgs";
8+
9+
inference-perf.url = "github:kubernetes-sigs/inference-perf";
10+
inference-perf.flake = false;
11+
};
12+
13+
outputs =
14+
{
15+
self,
16+
nixpkgs,
17+
flake-parts,
18+
pyproject-nix,
19+
inference-perf,
20+
...
21+
}@inputs:
22+
flake-parts.lib.mkFlake { inherit inputs; } (
23+
{ config, ... }:
24+
{
25+
systems = [
26+
"x86_64-linux"
27+
];
28+
flake = {
29+
lib = {
30+
pyproject = pyproject-nix.lib.project.loadPyproject {
31+
projectRoot = inference-perf;
32+
};
33+
};
34+
};
35+
perSystem =
36+
{ pkgs, self', ... }@systemInputs:
37+
let
38+
python = pkgs.python3;
39+
in
40+
{
41+
devShells.default = pkgs.mkShell {
42+
# PATH-only packages:
43+
packages =
44+
with pkgs;
45+
with python3Packages;
46+
with self'.packages;
47+
[
48+
llm-d-inference-sim
49+
pdm
50+
51+
# choose either python-lsp-server or pyright:
52+
basedpyright
53+
# python-lsp-server
54+
# pylsp-mypy
55+
];
56+
57+
buildInputs =
58+
with pkgs;
59+
with python3Packages;
60+
[
61+
numpy
62+
torch
63+
venvShellHook
64+
];
65+
66+
venvDir = "venv";
67+
};
68+
69+
packages = rec {
70+
default = inference-perf;
71+
72+
inference-perf =
73+
let
74+
buildAttrs = self.lib.pyproject.renderers.buildPythonPackage {
75+
inherit python;
76+
};
77+
in
78+
python.pkgs.buildPythonPackage (buildAttrs // { });
79+
80+
llm-d-inference-sim = pkgs.buildGoModule rec {
81+
pname = "llm-d-inference-sim";
82+
version = "0.6.1";
83+
84+
src = pkgs.fetchFromGitHub {
85+
owner = "llm-d";
86+
repo = "llm-d-inference-sim";
87+
tag = "v${version}";
88+
hash = "sha256-KdA7dgdy1jGjRhrqXfkg4Z9V3SXPcKp1FnTtm+e5DSA=";
89+
};
90+
vendorHash = "sha256-MINH7J2ozTORFK/KgZvXBlwThYRISL1wlHebdZxvuvw=";
91+
92+
nativeBuildInputs = with pkgs; [
93+
pkg-config
94+
];
95+
96+
buildInputs = with pkgs; [
97+
zeromq
98+
libtokenizers
99+
];
100+
101+
# several tests require networking.
102+
doCheck = false;
103+
104+
meta = {
105+
description = "A light weight vLLM simulator, for mocking out replicas";
106+
homepage = "https://github.com/llm-d/llm-d-inference-sim";
107+
license = with nixpkgs.lib.licenses; asl20;
108+
mainProgram = "llm-d-inference-sim";
109+
};
110+
};
111+
112+
libtokenizers = pkgs.rustPlatform.buildRustPackage rec {
113+
pname = "libtokenizers";
114+
version = "1.22.1"; # keep same as llm-d-inference-sim's version
115+
116+
src = pkgs.fetchFromGitHub {
117+
owner = "daulet";
118+
repo = "tokenizers";
119+
tag = "v${version}";
120+
hash = "sha256-unGAXpD4GHWVFcXAwd0zU/u30wzH909tDcRYRPsSKwQ=";
121+
};
122+
cargoHash = "sha256-rY3YAcCbbx5CY6qu44Qz6UQhJlWVxAWdTaUSagHDn2o=";
123+
124+
meta = {
125+
description = "Go bindings for Tiktoken & HuggingFace Tokenizer";
126+
homepage = "https://github.com/daulet/tokenizers";
127+
license = with nixpkgs.lib.licenses; mit;
128+
};
129+
};
130+
};
131+
};
132+
}
133+
);
134+
}

0 commit comments

Comments
 (0)