Skip to content

Commit

Permalink
dev: Simplify devShells, restore the -extra devShell
Browse files Browse the repository at this point in the history
  • Loading branch information
ditsuke committed Aug 19, 2024
1 parent 5da9da4 commit 7729067
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 46 deletions.
52 changes: 43 additions & 9 deletions .devops/nix/devshells.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,48 @@
{ inputs, ... }:

{
perSystem =
{ config, lib, ... }:
{
devShells = lib.pipe (config.packages) [
(lib.concatMapAttrs
(name: package: {
${name} = package.passthru.shell or null;
}))
(lib.filterAttrs (name: value: value != null))
];
config,
lib,
system,
...
}:
{
devShells =
let
pkgs = import inputs.nixpkgs { inherit system; };
stdenv = pkgs.stdenv;
scripts = config.packages.python-scripts;
in
lib.pipe (config.packages) [
(lib.concatMapAttrs (
name: package: {
${name} = pkgs.mkShell {
name = "${name}";
inputsFrom = [ package ];
shellHook = ''
echo "Entering ${name} devShell"
'';
};
"${name}-extra" =
if (name == "python-scripts") then
null
else
pkgs.mkShell {
name = "${name}-extra";
inputsFrom = [
package
scripts
];
shellHook = ''
echo "Entering ${name} devShell"
addToSearchPath "LD_LIBRARY_PATH" "${lib.getLib stdenv.cc.cc}/lib"
'';
};
}
))
(lib.filterAttrs (name: value: value != null))
];
};
}

33 changes: 8 additions & 25 deletions .devops/nix/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@
vulkan-loader,
curl,
shaderc,
useBlas ? builtins.all (x: !x) [
useCuda
useMetalKit
useRocm
useVulkan
] && blas.meta.available,
useBlas ?
builtins.all (x: !x) [
useCuda
useMetalKit
useRocm
useVulkan
]
&& blas.meta.available,
useCuda ? config.cudaSupport,
useMetalKit ? stdenv.isAarch64 && stdenv.isDarwin,
# Increases the runtime closure size by ~700M
Expand Down Expand Up @@ -214,25 +216,6 @@ effectiveStdenv.mkDerivation (finalAttrs: {
cp $src/include/llama.h $out/include/
'';

# Define the shells here, but don't add in the inputsFrom to avoid recursion.
passthru = {
inherit
useBlas
useCuda
useMetalKit
useMpi
useRocm
useVulkan
;

shell = mkShell {
name = "shell-${finalAttrs.finalPackage.name}";
description = "contains numpy and sentencepiece";
nativeBuildInputs = [ cmake ];
inputsFrom = [ finalAttrs.finalPackage ];
};
};

meta = {
# Configurations we don't want even the CI to evaluate. Results in the
# "unsupported platform" messages. This is mostly a no-op, because
Expand Down
32 changes: 20 additions & 12 deletions .devops/nix/python-scripts.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
stdenv,
buildPythonPackage,
poetry-core,
breakpointHook,
mkShell,
python3Packages,
gguf-py,
Expand All @@ -18,6 +17,25 @@ let
torchWithoutCuda
gguf-py
tqdm

# for scripts/compare-llama-bench.py
gitpython
tabulate

# for examples/pydantic-models-to-grammar-examples.py
docstring-parser
pydantic

];

llama-python-test-deps = with python3Packages; [
# Server bench
matplotlib

# server tests
openai
behave
prometheus-client
];
in

Expand All @@ -43,16 +61,6 @@ buildPythonPackage ({
src = lib.cleanSource ../../.;
};
nativeBuildInputs = [ poetry-core ];
nativeCheckInputs = llama-python-test-deps;
dependencies = llama-python-deps;

passthru = {
shell = mkShell {
name = "shell-python-scripts";
description = "contains numpy and sentencepiece";
buildInputs = llama-python-deps;
shellHook = ''
addToSearchPath "LD_LIBRARY_PATH" "${lib.getLib stdenv.cc.cc}/lib"
'';
};
};
})

0 comments on commit 7729067

Please sign in to comment.