2024-08-09 04:32:37 -06:00
|
|
|
{
|
|
|
|
inputs = {
|
2024-08-13 02:44:15 -06:00
|
|
|
crate2nix = {
|
|
|
|
url = "github:nix-community/crate2nix";
|
|
|
|
inputs.nixpkgs.follows = "tgi-nix/nixpkgs";
|
|
|
|
};
|
2024-08-16 02:01:01 -06:00
|
|
|
nix-filter.url = "github:numtide/nix-filter";
|
2024-08-09 04:32:37 -06:00
|
|
|
tgi-nix.url = "github:danieldk/tgi-nix";
|
|
|
|
nixpkgs.follows = "tgi-nix/nixpkgs";
|
|
|
|
flake-utils.url = "github:numtide/flake-utils";
|
2024-08-09 07:24:21 -06:00
|
|
|
rust-overlay = {
|
|
|
|
url = "github:oxalica/rust-overlay";
|
|
|
|
inputs.nixpkgs.follows = "tgi-nix/nixpkgs";
|
|
|
|
};
|
2024-08-09 04:32:37 -06:00
|
|
|
};
|
|
|
|
outputs =
|
|
|
|
{
|
|
|
|
self,
|
2024-08-13 02:44:15 -06:00
|
|
|
crate2nix,
|
2024-08-16 02:01:01 -06:00
|
|
|
nix-filter,
|
2024-08-09 04:32:37 -06:00
|
|
|
nixpkgs,
|
|
|
|
flake-utils,
|
2024-08-09 07:24:21 -06:00
|
|
|
rust-overlay,
|
2024-08-09 04:32:37 -06:00
|
|
|
tgi-nix,
|
|
|
|
}:
|
|
|
|
flake-utils.lib.eachDefaultSystem (
|
|
|
|
system:
|
|
|
|
let
|
2024-08-13 02:44:15 -06:00
|
|
|
cargoNix = crate2nix.tools.${system}.appliedCargoNix {
|
|
|
|
name = "tgi";
|
|
|
|
src = ./.;
|
2024-08-15 02:21:51 -06:00
|
|
|
additionalCargoNixArgs = [ "--all-features" ];
|
2024-08-13 02:44:15 -06:00
|
|
|
};
|
2024-08-09 04:32:37 -06:00
|
|
|
pkgs = import nixpkgs {
|
2024-08-29 08:25:25 -06:00
|
|
|
inherit system;
|
|
|
|
inherit (tgi-nix.lib) config;
|
2024-08-09 07:24:21 -06:00
|
|
|
overlays = [
|
|
|
|
rust-overlay.overlays.default
|
2024-08-29 08:25:25 -06:00
|
|
|
tgi-nix.overlays.default
|
2024-08-09 07:24:21 -06:00
|
|
|
];
|
2024-08-09 04:32:37 -06:00
|
|
|
};
|
2024-08-16 02:01:01 -06:00
|
|
|
crateOverrides = import ./nix/crate-overrides.nix { inherit pkgs nix-filter; };
|
2024-08-20 23:48:13 -06:00
|
|
|
benchmark = cargoNix.workspaceMembers.text-generation-benchmark.build.override {
|
|
|
|
inherit crateOverrides;
|
|
|
|
};
|
2024-08-20 14:07:33 -06:00
|
|
|
launcher = cargoNix.workspaceMembers.text-generation-launcher.build.override {
|
|
|
|
inherit crateOverrides;
|
|
|
|
};
|
2024-09-12 02:44:01 -06:00
|
|
|
router =
|
|
|
|
let
|
|
|
|
routerUnwrapped = cargoNix.workspaceMembers.text-generation-router-v3.build.override {
|
|
|
|
inherit crateOverrides;
|
|
|
|
};
|
|
|
|
packagePath =
|
|
|
|
with pkgs.python3.pkgs;
|
|
|
|
makePythonPath [
|
|
|
|
protobuf
|
|
|
|
sentencepiece
|
|
|
|
torch
|
|
|
|
transformers
|
|
|
|
];
|
|
|
|
in
|
|
|
|
pkgs.writeShellApplication {
|
|
|
|
name = "text-generation-router";
|
|
|
|
text = ''
|
|
|
|
PYTHONPATH="${packagePath}" ${routerUnwrapped}/bin/text-generation-router "$@"
|
|
|
|
'';
|
|
|
|
};
|
2024-08-20 14:07:33 -06:00
|
|
|
server = pkgs.python3.pkgs.callPackage ./nix/server.nix { inherit nix-filter; };
|
2024-08-09 04:32:37 -06:00
|
|
|
in
|
|
|
|
{
|
2024-08-20 14:07:33 -06:00
|
|
|
devShells = with pkgs; rec {
|
|
|
|
default = pure;
|
|
|
|
|
|
|
|
pure = mkShell {
|
|
|
|
buildInputs = [
|
2024-08-20 23:48:13 -06:00
|
|
|
benchmark
|
2024-08-20 14:07:33 -06:00
|
|
|
launcher
|
|
|
|
router
|
|
|
|
server
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
impure = mkShell {
|
2024-08-09 04:32:37 -06:00
|
|
|
buildInputs =
|
|
|
|
[
|
|
|
|
openssl.dev
|
|
|
|
pkg-config
|
2024-08-09 07:24:21 -06:00
|
|
|
(rust-bin.stable.latest.default.override {
|
|
|
|
extensions = [
|
|
|
|
"rust-analyzer"
|
|
|
|
"rust-src"
|
|
|
|
];
|
|
|
|
})
|
2024-08-20 14:07:33 -06:00
|
|
|
protobuf
|
2024-08-09 04:32:37 -06:00
|
|
|
]
|
|
|
|
++ (with python3.pkgs; [
|
|
|
|
venvShellHook
|
2024-09-02 01:27:10 -06:00
|
|
|
docker
|
2024-08-09 04:32:37 -06:00
|
|
|
pip
|
2024-08-20 03:15:30 -06:00
|
|
|
ipdb
|
2024-09-06 02:19:04 -06:00
|
|
|
pyright
|
2024-09-02 01:27:10 -06:00
|
|
|
pytest
|
|
|
|
pytest-asyncio
|
2024-09-06 02:19:04 -06:00
|
|
|
ruff
|
2024-09-02 01:27:10 -06:00
|
|
|
syrupy
|
2024-08-09 04:32:37 -06:00
|
|
|
]);
|
|
|
|
|
2024-08-20 14:07:33 -06:00
|
|
|
inputsFrom = [ server ];
|
|
|
|
|
2024-08-09 04:32:37 -06:00
|
|
|
venvDir = "./.venv";
|
|
|
|
|
2024-09-02 01:27:10 -06:00
|
|
|
postVenvCreation = ''
|
2024-08-09 04:32:37 -06:00
|
|
|
unset SOURCE_DATE_EPOCH
|
2024-09-02 01:27:10 -06:00
|
|
|
( cd server ; python -m pip install --no-dependencies -e . )
|
|
|
|
( cd clients/python ; python -m pip install --no-dependencies -e . )
|
2024-08-09 04:32:37 -06:00
|
|
|
'';
|
|
|
|
postShellHook = ''
|
|
|
|
unset SOURCE_DATE_EPOCH
|
2024-08-20 14:07:33 -06:00
|
|
|
export PATH=$PATH:~/.cargo/bin
|
2024-08-09 04:32:37 -06:00
|
|
|
'';
|
|
|
|
};
|
2024-08-20 14:07:33 -06:00
|
|
|
};
|
2024-08-23 14:06:22 -06:00
|
|
|
|
|
|
|
packages.default = pkgs.writeShellApplication {
|
|
|
|
name = "text-generation-inference";
|
|
|
|
runtimeInputs = [
|
|
|
|
server
|
|
|
|
router
|
|
|
|
];
|
|
|
|
text = ''
|
|
|
|
${launcher}/bin/text-generation-launcher "$@"
|
|
|
|
'';
|
|
|
|
};
|
2024-08-09 04:32:37 -06:00
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|