nix: support Python tokenizer conversion in the router (#2515)
Ideally we wouldn't have the router wrapper that this change adds, but when I give PyO3 a Python interpreter with packages, it ends up linking libpython from the Python interpreter rather than the constructed environment and cannot pick up the Python modules as a result.
This commit is contained in:
parent
69e3be20fb
commit
94304649f1
23
flake.nix
23
flake.nix
|
@ -46,9 +46,26 @@
|
||||||
launcher = cargoNix.workspaceMembers.text-generation-launcher.build.override {
|
launcher = cargoNix.workspaceMembers.text-generation-launcher.build.override {
|
||||||
inherit crateOverrides;
|
inherit crateOverrides;
|
||||||
};
|
};
|
||||||
router = cargoNix.workspaceMembers.text-generation-router-v3.build.override {
|
router =
|
||||||
inherit crateOverrides;
|
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 "$@"
|
||||||
|
'';
|
||||||
|
};
|
||||||
server = pkgs.python3.pkgs.callPackage ./nix/server.nix { inherit nix-filter; };
|
server = pkgs.python3.pkgs.callPackage ./nix/server.nix { inherit nix-filter; };
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,6 +28,9 @@ defaultCrateOverrides
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
pyo3-build-config = attrs: {
|
||||||
|
buildInputs = [ python3 ];
|
||||||
|
};
|
||||||
text-generation-benchmark = attrs: {
|
text-generation-benchmark = attrs: {
|
||||||
src = filter {
|
src = filter {
|
||||||
root = ../benchmark;
|
root = ../benchmark;
|
||||||
|
|
Loading…
Reference in New Issue