about summary refs log tree commit diff
path: root/pkgs/development/python-modules/openai-triton
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/python-modules/openai-triton')
-rw-r--r--pkgs/development/python-modules/openai-triton/0000-dont-download-ptxas.patch15
-rw-r--r--pkgs/development/python-modules/openai-triton/0001-ptxas-disable-version-key-for-non-cuda-targets.patch27
-rw-r--r--pkgs/development/python-modules/openai-triton/bin.nix98
-rw-r--r--pkgs/development/python-modules/openai-triton/binary-hashes.nix32
-rw-r--r--pkgs/development/python-modules/openai-triton/default.nix224
-rwxr-xr-xpkgs/development/python-modules/openai-triton/prefetch.sh40
6 files changed, 0 insertions, 436 deletions
diff --git a/pkgs/development/python-modules/openai-triton/0000-dont-download-ptxas.patch b/pkgs/development/python-modules/openai-triton/0000-dont-download-ptxas.patch
deleted file mode 100644
index d31a4798af05c..0000000000000
--- a/pkgs/development/python-modules/openai-triton/0000-dont-download-ptxas.patch
+++ /dev/null
@@ -1,15 +0,0 @@
-diff --git a/python/setup.py b/python/setup.py
-index 18764ec13..b3bb5b60a 100644
---- a/python/setup.py
-+++ b/python/setup.py
-@@ -269,10 +269,6 @@ class CMakeBuild(build_ext):
-         subprocess.check_call(["cmake", self.base_dir] + cmake_args, cwd=cmake_dir, env=env)
-         subprocess.check_call(["cmake", "--build", "."] + build_args, cwd=cmake_dir)
- 
--
--download_and_copy_ptxas()
--
--
- setup(
-     name="triton",
-     version="2.1.0",
diff --git a/pkgs/development/python-modules/openai-triton/0001-ptxas-disable-version-key-for-non-cuda-targets.patch b/pkgs/development/python-modules/openai-triton/0001-ptxas-disable-version-key-for-non-cuda-targets.patch
deleted file mode 100644
index 3941d54b8b37f..0000000000000
--- a/pkgs/development/python-modules/openai-triton/0001-ptxas-disable-version-key-for-non-cuda-targets.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-From 10f3d49aa6084d1b9b9624017cce7df106b9fb7e Mon Sep 17 00:00:00 2001
-From: Yaroslav Bolyukin <iam@lach.pw>
-Date: Tue, 6 Feb 2024 13:51:28 +0100
-Subject: [PATCH] ptxas: disable version key for non-cuda targets
-
----
- python/triton/runtime/jit.py | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/python/triton/runtime/jit.py b/python/triton/runtime/jit.py
-index d55972b4b..bd875a701 100644
---- a/python/triton/runtime/jit.py
-+++ b/python/triton/runtime/jit.py
-@@ -117,8 +117,8 @@ def version_key():
-         with open(lib.module_finder.find_spec(lib.name).origin, "rb") as f:
-             contents += [hashlib.md5(f.read()).hexdigest()]
-     # ptxas version
--    ptxas = path_to_ptxas()[0]
--    ptxas_version = hashlib.md5(subprocess.check_output([ptxas, "--version"])).hexdigest()
-+    # ptxas = path_to_ptxas()[0]
-+    ptxas_version = "noptxas"
-     return '-'.join(TRITON_VERSION) + '-' + ptxas_version + '-' + '-'.join(contents)
- 
- 
--- 
-2.43.0
-
diff --git a/pkgs/development/python-modules/openai-triton/bin.nix b/pkgs/development/python-modules/openai-triton/bin.nix
deleted file mode 100644
index ef95ac07244ae..0000000000000
--- a/pkgs/development/python-modules/openai-triton/bin.nix
+++ /dev/null
@@ -1,98 +0,0 @@
-{
-  lib,
-  stdenv,
-  addOpenGLRunpath,
-  cudaPackages,
-  buildPythonPackage,
-  fetchurl,
-  isPy38,
-  isPy39,
-  isPy310,
-  isPy311,
-  python,
-  autoPatchelfHook,
-  filelock,
-  lit,
-  pythonRelaxDepsHook,
-  zlib,
-}:
-
-buildPythonPackage rec {
-  pname = "triton";
-  version = "2.1.0";
-  format = "wheel";
-
-  src =
-    let
-      pyVerNoDot = lib.replaceStrings [ "." ] [ "" ] python.pythonVersion;
-      unsupported = throw "Unsupported system";
-      srcs = (import ./binary-hashes.nix version)."${stdenv.system}-${pyVerNoDot}" or unsupported;
-    in
-    fetchurl srcs;
-
-  disabled = !(isPy38 || isPy39 || isPy310 || isPy311);
-
-  pythonRemoveDeps = [
-    "cmake"
-    "torch"
-  ];
-
-  buildInputs = [ zlib ];
-
-  nativeBuildInputs = [
-    pythonRelaxDepsHook # torch and triton refer to each other so this hook is included to mitigate that.
-    autoPatchelfHook
-  ];
-
-  propagatedBuildInputs = [
-    filelock
-    lit
-    zlib
-  ];
-
-  dontStrip = true;
-
-  # If this breaks, consider replacing with "${cuda_nvcc}/bin/ptxas"
-  postFixup =
-    ''
-      chmod +x "$out/${python.sitePackages}/triton/third_party/cuda/bin/ptxas"
-    ''
-    + (
-      let
-        # Bash was getting weird without linting,
-        # but basically upstream contains [cc, ..., "-lcuda", ...]
-        # and we replace it with [..., "-lcuda", "-L/run/opengl-driver/lib", "-L$stubs", ...]
-        old = [ "-lcuda" ];
-        new = [
-          "-lcuda"
-          "-L${addOpenGLRunpath.driverLink}"
-          "-L${cudaPackages.cuda_cudart}/lib/stubs/"
-        ];
-
-        quote = x: ''"${x}"'';
-        oldStr = lib.concatMapStringsSep ", " quote old;
-        newStr = lib.concatMapStringsSep ", " quote new;
-      in
-      ''
-        substituteInPlace $out/${python.sitePackages}/triton/common/build.py \
-          --replace '${oldStr}' '${newStr}'
-      ''
-    );
-
-  meta = with lib; {
-    description = "Language and compiler for custom Deep Learning operations";
-    homepage = "https://github.com/openai/triton/";
-    changelog = "https://github.com/openai/triton/releases/tag/v${version}";
-    # Includes NVIDIA's ptxas, but redistributions of the binary are not limited.
-    # https://docs.nvidia.com/cuda/eula/index.html
-    # triton's license is MIT.
-    # openai-triton-bin includes ptxas binary, therefore unfreeRedistributable is set.
-    license = with licenses; [
-      unfreeRedistributable
-      mit
-    ];
-    sourceProvenance = with sourceTypes; [ binaryNativeCode ];
-    platforms = [ "x86_64-linux" ];
-    maintainers = with maintainers; [ junjihashimoto ];
-  };
-}
diff --git a/pkgs/development/python-modules/openai-triton/binary-hashes.nix b/pkgs/development/python-modules/openai-triton/binary-hashes.nix
deleted file mode 100644
index 5c542ac187ee3..0000000000000
--- a/pkgs/development/python-modules/openai-triton/binary-hashes.nix
+++ /dev/null
@@ -1,32 +0,0 @@
-# Warning: Need to update at the same time as torch-bin
-#
-# Precompiled wheels can be found at:
-# https://download.pytorch.org/whl/torch_stable.html
-
-# To add a new version, run "prefetch.sh 'new-version'" to paste the generated file as follows.
-
-version:
-builtins.getAttr version {
-  "2.1.0" = {
-    x86_64-linux-38 = {
-      name = "triton-2.1.0-cp38-cp38-linux_x86_64.whl";
-      url = "https://download.pytorch.org/whl/triton-2.1.0-0-cp38-cp38-manylinux2014_x86_64.manylinux_2_17_x86_64.whl";
-      hash = "sha256-Ofb7a9zLPpjzFS4/vqck8a6ufXSUErux+pxEHUdOuiY=";
-    };
-    x86_64-linux-39 = {
-      name = "triton-2.1.0-cp39-cp39-linux_x86_64.whl";
-      url = "https://download.pytorch.org/whl/triton-2.1.0-0-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.whl";
-      hash = "sha256-IVROUiwCAFpibIrWPTm9/y8x1BBpWSkZ7ygelk7SZEY=";
-    };
-    x86_64-linux-310 = {
-      name = "triton-2.1.0-cp310-cp310-linux_x86_64.whl";
-      url = "https://download.pytorch.org/whl/triton-2.1.0-0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl";
-      hash = "sha256-ZkOZI6MNXUg5mwip6uEDcPbCYaXshkpkmDuuYxUtOdc=";
-    };
-    x86_64-linux-311 = {
-      name = "triton-2.1.0-cp311-cp311-linux_x86_64.whl";
-      url = "https://download.pytorch.org/whl/triton-2.1.0-0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl";
-      hash = "sha256-kZsGRT8AM+pSwT6veDPeDlfbMXjSPU4E+fxxxPLDK/g=";
-    };
-  };
-}
diff --git a/pkgs/development/python-modules/openai-triton/default.nix b/pkgs/development/python-modules/openai-triton/default.nix
deleted file mode 100644
index d1aaed52052dd..0000000000000
--- a/pkgs/development/python-modules/openai-triton/default.nix
+++ /dev/null
@@ -1,224 +0,0 @@
-{
-  lib,
-  config,
-  addDriverRunpath,
-  buildPythonPackage,
-  fetchFromGitHub,
-  fetchpatch,
-  setuptools,
-  pytestCheckHook,
-  pythonRelaxDepsHook,
-  cmake,
-  ninja,
-  pybind11,
-  gtest,
-  zlib,
-  ncurses,
-  libxml2,
-  lit,
-  llvm,
-  filelock,
-  torchWithRocm,
-  python,
-
-  runCommand,
-
-  cudaPackages,
-  cudaSupport ? config.cudaSupport,
-}:
-
-let
-  ptxas = "${cudaPackages.cuda_nvcc}/bin/ptxas"; # Make sure cudaPackages is the right version each update (See python/setup.py)
-in
-buildPythonPackage rec {
-  pname = "triton";
-  version = "2.1.0";
-  pyproject = true;
-
-  src = fetchFromGitHub {
-    owner = "openai";
-    repo = pname;
-    rev = "v${version}";
-    hash = "sha256-8UTUwLH+SriiJnpejdrzz9qIquP2zBp1/uwLdHmv0XQ=";
-  };
-
-  patches =
-    [
-      # fix overflow error
-      (fetchpatch {
-        url = "https://github.com/openai/triton/commit/52c146f66b79b6079bcd28c55312fc6ea1852519.patch";
-        hash = "sha256-098/TCQrzvrBAbQiaVGCMaF3o5Yc3yWDxzwSkzIuAtY=";
-      })
-    ]
-    ++ lib.optionals (!cudaSupport) [
-      ./0000-dont-download-ptxas.patch
-      # openai-triton wants to get ptxas version even if ptxas is not
-      # used, resulting in ptxas not found error.
-      ./0001-ptxas-disable-version-key-for-non-cuda-targets.patch
-    ];
-
-  postPatch =
-    let
-      quote = x: ''"${x}"'';
-      subs.ldFlags =
-        let
-          # Bash was getting weird without linting,
-          # but basically upstream contains [cc, ..., "-lcuda", ...]
-          # and we replace it with [..., "-lcuda", "-L/run/opengl-driver/lib", "-L$stubs", ...]
-          old = [ "-lcuda" ];
-          new = [
-            "-lcuda"
-            "-L${addDriverRunpath.driverLink}"
-            "-L${cudaPackages.cuda_cudart}/lib/stubs/"
-          ];
-        in
-        {
-          oldStr = lib.concatMapStringsSep ", " quote old;
-          newStr = lib.concatMapStringsSep ", " quote new;
-        };
-    in
-    ''
-      # Use our `cmakeFlags` instead and avoid downloading dependencies
-      substituteInPlace python/setup.py \
-        --replace "= get_thirdparty_packages(triton_cache_path)" "= os.environ[\"cmakeFlags\"].split()"
-
-      # Already defined in llvm, when built with -DLLVM_INSTALL_UTILS
-      substituteInPlace bin/CMakeLists.txt \
-        --replace "add_subdirectory(FileCheck)" ""
-
-      # Don't fetch googletest
-      substituteInPlace unittest/CMakeLists.txt \
-        --replace "include (\''${CMAKE_CURRENT_SOURCE_DIR}/googletest.cmake)" ""\
-        --replace "include(GoogleTest)" "find_package(GTest REQUIRED)"
-
-      cat << \EOF > python/triton/common/build.py
-
-      def libcuda_dirs():
-          return [ "${addDriverRunpath.driverLink}/lib" ]
-      EOF
-    ''
-    + lib.optionalString cudaSupport ''
-      # Use our linker flags
-      substituteInPlace python/triton/common/build.py \
-        --replace '${subs.ldFlags.oldStr}' '${subs.ldFlags.newStr}'
-    '';
-
-  nativeBuildInputs = [
-    setuptools
-    pythonRelaxDepsHook
-    # pytestCheckHook # Requires torch (circular dependency) and probably needs GPUs:
-    cmake
-    ninja
-
-    # Note for future:
-    # These *probably* should go in depsTargetTarget
-    # ...but we cannot test cross right now anyway
-    # because we only support cudaPackages on x86_64-linux atm
-    lit
-    llvm
-  ];
-
-  buildInputs = [
-    gtest
-    libxml2.dev
-    ncurses
-    pybind11
-    zlib
-  ];
-
-  propagatedBuildInputs = [
-    filelock
-    # openai-triton uses setuptools at runtime:
-    # https://github.com/NixOS/nixpkgs/pull/286763/#discussion_r1480392652
-    setuptools
-  ];
-
-  # Avoid GLIBCXX mismatch with other cuda-enabled python packages
-  preConfigure =
-    ''
-      # Ensure that the build process uses the requested number of cores
-      export MAX_JOBS="$NIX_BUILD_CORES"
-
-      # Upstream's setup.py tries to write cache somewhere in ~/
-      export HOME=$(mktemp -d)
-
-      # Upstream's github actions patch setup.cfg to write base-dir. May be redundant
-      echo "
-      [build_ext]
-      base-dir=$PWD" >> python/setup.cfg
-
-      # The rest (including buildPhase) is relative to ./python/
-      cd python
-    ''
-    + lib.optionalString cudaSupport ''
-      export CC=${cudaPackages.backendStdenv.cc}/bin/cc;
-      export CXX=${cudaPackages.backendStdenv.cc}/bin/c++;
-
-      # Work around download_and_copy_ptxas()
-      mkdir -p $PWD/triton/third_party/cuda/bin
-      ln -s ${ptxas} $PWD/triton/third_party/cuda/bin
-    '';
-
-  # CMake is run by setup.py instead
-  dontUseCmakeConfigure = true;
-
-  # Setuptools (?) strips runpath and +x flags. Let's just restore the symlink
-  postFixup = lib.optionalString cudaSupport ''
-    rm -f $out/${python.sitePackages}/triton/third_party/cuda/bin/ptxas
-    ln -s ${ptxas} $out/${python.sitePackages}/triton/third_party/cuda/bin/ptxas
-  '';
-
-  checkInputs = [ cmake ]; # ctest
-  dontUseSetuptoolsCheck = true;
-
-  preCheck = ''
-    # build/temp* refers to build_ext.build_temp (looked up in the build logs)
-    (cd /build/source/python/build/temp* ; ctest)
-
-    # For pytestCheckHook
-    cd test/unit
-  '';
-
-  # Circular dependency on torch
-  # pythonImportsCheck = [
-  #   "triton"
-  #   "triton.language"
-  # ];
-
-  # Ultimately, torch is our test suite:
-  passthru.tests = {
-    inherit torchWithRocm;
-    # Implemented as alternative to pythonImportsCheck, in case if circular dependency on torch occurs again,
-    # and pythonImportsCheck is commented back.
-    import-triton =
-      runCommand "import-triton"
-        { nativeBuildInputs = [ (python.withPackages (ps: [ ps.openai-triton ])) ]; }
-        ''
-          python << \EOF
-          import triton
-          import triton.language
-          EOF
-          touch "$out"
-        '';
-  };
-
-  pythonRemoveDeps = [
-    # Circular dependency, cf. https://github.com/openai/triton/issues/1374
-    "torch"
-
-    # CLI tools without dist-info
-    "cmake"
-    "lit"
-  ];
-
-  meta = with lib; {
-    description = "Language and compiler for writing highly efficient custom Deep-Learning primitives";
-    homepage = "https://github.com/openai/triton";
-    platforms = platforms.linux;
-    license = licenses.mit;
-    maintainers = with maintainers; [
-      SomeoneSerge
-      Madouura
-    ];
-  };
-}
diff --git a/pkgs/development/python-modules/openai-triton/prefetch.sh b/pkgs/development/python-modules/openai-triton/prefetch.sh
deleted file mode 100755
index f218718a5cf30..0000000000000
--- a/pkgs/development/python-modules/openai-triton/prefetch.sh
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/usr/bin/env nix-shell
-#!nix-shell -i bash -p nix-prefetch-scripts
-
-set -eou pipefail
-
-version=$1
-
-linux_bucket="https://download.pytorch.org/whl"
-
-url_and_key_list=(
-  "x86_64-linux-38 $linux_bucket/triton-${version}-0-cp38-cp38-manylinux2014_x86_64.manylinux_2_17_x86_64.whl triton-${version}-cp38-cp38-linux_x86_64.whl"
-  "x86_64-linux-39 $linux_bucket/triton-${version}-0-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.whl triton-${version}-cp39-cp39-linux_x86_64.whl"
-  "x86_64-linux-310 $linux_bucket/triton-${version}-0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl triton-${version}-cp310-cp310-linux_x86_64.whl"
-  "x86_64-linux-311 $linux_bucket/triton-${version}-0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl triton-${version}-cp311-cp311-linux_x86_64.whl"
-)
-
-hashfile=binary-hashes-"$version".nix
-echo "  \"$version\" = {" >> $hashfile
-
-for url_and_key in "${url_and_key_list[@]}"; do
-  key=$(echo "$url_and_key" | cut -d' ' -f1)
-  url=$(echo "$url_and_key" | cut -d' ' -f2)
-  name=$(echo "$url_and_key" | cut -d' ' -f3)
-
-  echo "prefetching ${url}..."
-  hash=$(nix hash to-sri --type sha256 `nix-prefetch-url "$url" --name "$name"`)
-
-  cat << EOF >> $hashfile
-    $key = {
-      name = "$name";
-      url = "$url";
-      hash = "$hash";
-    };
-EOF
-
-  echo
-done
-
-echo "  };" >> $hashfile
-echo "done."