From a96e5f0ae06f5fe61d9f2b211ca7087864d2ef29 Mon Sep 17 00:00:00 2001 From: cfhammill Date: Wed, 31 Jul 2024 21:56:47 +0000 Subject: [PATCH] python311Packages.vllm: 0.3.2->0.5.2 vllm remove comment, minor version bump use refs/tags and format=pyproject use @args and realphabetize inputs move stdenv, mv cuda_home, add/clean cuda deps, restore comment nixfmt rfc style remove stale comment --- .../python-modules/outlines/default.nix | 13 ++- .../python-modules/vllm/default.nix | 101 ++++++++++-------- pkgs/top-level/python-packages.nix | 4 + 3 files changed, 73 insertions(+), 45 deletions(-) diff --git a/pkgs/development/python-modules/outlines/default.nix b/pkgs/development/python-modules/outlines/default.nix index 58e908e53a1c..e93ce65e23ad 100644 --- a/pkgs/development/python-modules/outlines/default.nix +++ b/pkgs/development/python-modules/outlines/default.nix @@ -6,9 +6,12 @@ setuptools-scm, interegular, cloudpickle, + datasets, diskcache, joblib, jsonschema, + pyairports, + pycountry, pydantic, lark, nest-asyncio, @@ -38,6 +41,7 @@ buildPythonPackage rec { propagatedBuildInputs = [ interegular cloudpickle + datasets diskcache joblib jsonschema @@ -48,16 +52,19 @@ buildPythonPackage rec { scipy torch transformers + pycountry + pyairports ]; - pythonImportsCheck = [ "outlines" ]; + checkPhase = '' + export HOME=$(mktemp -d) + python3 -c 'import outlines' + ''; meta = with lib; { description = "Structured text generation"; homepage = "https://github.com/outlines-dev/outlines"; license = licenses.asl20; maintainers = with maintainers; [ lach ]; - # Missing dependencies since the last update - broken = true; }; } diff --git a/pkgs/development/python-modules/vllm/default.nix b/pkgs/development/python-modules/vllm/default.nix index a27589f42abe..80ad9a2ac5bd 100644 --- a/pkgs/development/python-modules/vllm/default.nix +++ b/pkgs/development/python-modules/vllm/default.nix @@ -1,10 +1,13 @@ { lib, stdenv, + python, buildPythonPackage, + pythonRelaxDepsHook, fetchFromGitHub, which, ninja, + cmake, packaging, setuptools, torch, @@ -23,6 +26,13 @@ pydantic, aioprometheus, pynvml, + openai, + pyzmq, + tiktoken, + torchvision, + py-cpuinfo, + lm-format-enforcer, + prometheus-fastapi-instrumentator, cupy, writeShellScript, @@ -34,47 +44,41 @@ rocmSupport ? config.rocmSupport, rocmPackages ? { }, gpuTargets ? [ ], -}: +}@args: let - stdenv_pkg = stdenv; + cutlass = fetchFromGitHub { + owner = "NVIDIA"; + repo = "cutlass"; + rev = "refs/tags/v3.5.0"; + sha256 = "sha256-D/s7eYsa5l/mfx73tE4mnFcTQdYqGmXa9d9TCryw4e4="; + }; in buildPythonPackage rec { pname = "vllm"; - version = "0.3.3"; - format = "pyproject"; + version = "0.5.3.post1"; + pyproject = true; src = fetchFromGitHub { owner = "vllm-project"; repo = pname; - rev = "v${version}"; - hash = "sha256-LU5pCPVv+Ws9dL8oWL1sJGzwQKI1IFk2A1I6TP9gXL4="; + rev = "refs/tags/v${version}"; + hash = "sha256-++DK2Y2zz+1KrEcdQc5XFrSjc7fCwMD2DQ/RqY7PoFU="; }; + stdenv = if cudaSupport then cudaPackages.backendStdenv else args.stdenv; + # Otherwise it tries to enumerate host supported ROCM gfx archs, and that is not possible due to sandboxing. PYTORCH_ROCM_ARCH = lib.optionalString rocmSupport ( lib.strings.concatStringsSep ";" rocmPackages.clr.gpuTargets ); - # cupy-cuda12x is the same wheel as cupy, but built with cuda dependencies, we already have it set up - # like that in nixpkgs. Version upgrade is due to upstream shenanigans - # https://github.com/vllm-project/vllm/pull/2845/commits/34a0ad7f9bb7880c0daa2992d700df3e01e91363 - # # hipcc --version works badly on NixOS due to unresolved paths. - # Unclear why pythonRelaxDeps doesn't work here, but on last attempt, it didn't. postPatch = '' - substituteInPlace requirements.txt \ - --replace "xformers == 0.0.23.post1" "xformers" - substituteInPlace requirements.txt \ - --replace "cupy-cuda12x == 12.1.0" "cupy" - substituteInPlace requirements-build.txt \ - --replace "torch==2.1.2" "torch" - substituteInPlace pyproject.toml \ - --replace "torch == 2.1.2" "torch" - substituteInPlace requirements.txt \ - --replace "torch == 2.1.2" "torch" + substituteInPlace setup.py \ + --replace 'cmake_args = [' 'cmake_args = ["-DFETCHCONTENT_SOURCE_DIR_CUTLASS=${cutlass}",' '' + lib.optionalString rocmSupport '' substituteInPlace setup.py \ @@ -82,17 +86,19 @@ buildPythonPackage rec { ''; preBuild = - lib.optionalString cudaSupport '' - export CUDA_HOME=${cudaPackages.cuda_nvcc} - '' - + lib.optionalString rocmSupport '' + lib.optionalString rocmSupport '' export ROCM_HOME=${rocmPackages.clr} export PATH=$PATH:${rocmPackages.hipcc} + '' + + lib.optionalString cudaSupport '' + export CUDA_HOME=${cudaPackages.cuda_nvcc} ''; nativeBuildInputs = [ + cmake ninja packaging + pythonRelaxDepsHook setuptools torch wheel @@ -104,10 +110,12 @@ buildPythonPackage rec { with cudaPackages; [ cuda_cudart # cuda_runtime.h, -lcudart - cuda_cccl # + cuda_cccl libcusparse # cusparse.h - libcublas # cublas_v2.h libcusolver # cusolverDn.h + cuda_nvcc + cuda_nvtx + libcublas ] )) ++ (lib.optionals rocmSupport ( @@ -123,29 +131,38 @@ buildPythonPackage rec { propagatedBuildInputs = [ - psutil - ray - pandas - pyarrow - sentencepiece - numpy - torch - transformers - outlines - xformers - fastapi - uvicorn - pydantic aioprometheus + fastapi + lm-format-enforcer + numpy + openai + outlines + pandas + prometheus-fastapi-instrumentator + psutil + py-cpuinfo + pyarrow + pydantic + pyzmq + ray + sentencepiece + tiktoken + torch + torchvision + transformers + uvicorn + xformers ] ++ uvicorn.optional-dependencies.standard ++ aioprometheus.optional-dependencies.starlette ++ lib.optionals cudaSupport [ - pynvml cupy + pynvml ]; - stdenv = if cudaSupport then cudaPackages.backendStdenv else stdenv_pkg; + dontUseCmakeConfigure = true; + + pythonRelaxDeps = true; pythonImportsCheck = [ "vllm" ]; diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 8046bf0c3810..1e31c8716762 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -7167,6 +7167,8 @@ self: super: with self; { llvm = pkgs.llvm_14; }; + lm-format-enforcer = callPackage ../development/python-modules/lm-format-enforcer { }; + lmcloud = callPackage ../development/python-modules/lmcloud { }; lmdb = callPackage ../development/python-modules/lmdb { @@ -10904,6 +10906,8 @@ self: super: with self; { pyairnow = callPackage ../development/python-modules/pyairnow { }; + pyairports = callPackage ../development/python-modules/pyairports { }; + pyairvisual = callPackage ../development/python-modules/pyairvisual { }; pyais = callPackage ../development/python-modules/pyais { };