Commit a96e5f0a authored by cfhammill's avatar cfhammill Committed by Someone Serge
Browse files

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
parent 5377367b
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -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;
  };
}
+54 −37
Original line number Diff line number Diff line
{
  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 # <thrust/*>
        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
      aioprometheus
      fastapi
      lm-format-enforcer
      numpy
      openai
      outlines
      pandas
      prometheus-fastapi-instrumentator
      psutil
      py-cpuinfo
      pyarrow
      pydantic
      pyzmq
      ray
      sentencepiece
      numpy
      tiktoken
      torch
      torchvision
      transformers
      outlines
      xformers
      fastapi
      uvicorn
      pydantic
      aioprometheus
      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" ];

+4 −0
Original line number Diff line number Diff line
@@ -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 { };