Skip to content

Commit 0507d69

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 0507d69

File tree

2 files changed

+225
-0
lines changed

2 files changed

+225
-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: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
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 = [ pkgs.python3Packages.venvShellHook ];
58+
venvDir = "venv";
59+
};
60+
61+
packages = rec {
62+
default = inference-perf;
63+
64+
inference-perf =
65+
let
66+
buildAttrs = self.lib.pyproject.renderers.buildPythonPackage {
67+
inherit python;
68+
};
69+
in
70+
python.pkgs.buildPythonPackage (buildAttrs // { });
71+
72+
llm-d-inference-sim = pkgs.buildGoModule rec {
73+
pname = "llm-d-inference-sim";
74+
version = "0.6.1";
75+
76+
src = pkgs.fetchFromGitHub {
77+
owner = "llm-d";
78+
repo = "llm-d-inference-sim";
79+
tag = "v${version}";
80+
hash = "sha256-KdA7dgdy1jGjRhrqXfkg4Z9V3SXPcKp1FnTtm+e5DSA=";
81+
};
82+
vendorHash = "sha256-MINH7J2ozTORFK/KgZvXBlwThYRISL1wlHebdZxvuvw=";
83+
84+
nativeBuildInputs = with pkgs; [
85+
pkg-config
86+
];
87+
88+
buildInputs = with pkgs; [
89+
zeromq
90+
libtokenizers
91+
];
92+
93+
# several tests require networking.
94+
doCheck = false;
95+
96+
meta = {
97+
description = "A light weight vLLM simulator, for mocking out replicas";
98+
homepage = "https://github.com/llm-d/llm-d-inference-sim";
99+
license = with nixpkgs.lib.licenses; asl20;
100+
mainProgram = "llm-d-inference-sim";
101+
};
102+
};
103+
104+
libtokenizers = pkgs.rustPlatform.buildRustPackage rec {
105+
pname = "libtokenizers";
106+
version = "1.22.1"; # keep same as llm-d-inference-sim's version
107+
108+
src = pkgs.fetchFromGitHub {
109+
owner = "daulet";
110+
repo = "tokenizers";
111+
tag = "v${version}";
112+
hash = "sha256-unGAXpD4GHWVFcXAwd0zU/u30wzH909tDcRYRPsSKwQ=";
113+
};
114+
cargoHash = "sha256-rY3YAcCbbx5CY6qu44Qz6UQhJlWVxAWdTaUSagHDn2o=";
115+
116+
meta = {
117+
description = "Go bindings for Tiktoken & HuggingFace Tokenizer";
118+
homepage = "https://github.com/daulet/tokenizers";
119+
license = with nixpkgs.lib.licenses; mit;
120+
};
121+
};
122+
};
123+
};
124+
}
125+
);
126+
}

0 commit comments

Comments
 (0)