19 buildPythonPackage rec {
25 let pyVerNoDot = lib.replaceStrings [ "." ] [ "" ] python.pythonVersion;
26 unsupported = throw "Unsupported system";
27 srcs = (import ./binary-hashes.nix version)."${stdenv.system}-${pyVerNoDot}" or unsupported;
30 disabled = !(isPy38 || isPy39 || isPy310 || isPy311);
32 pythonRemoveDeps = [ "cmake" "torch" ];
34 buildInputs = [ zlib ];
37 pythonRelaxDepsHook # torch and triton refer to each other so this hook is included to mitigate that.
41 propagatedBuildInputs = [
49 # If this breaks, consider replacing with "${cuda_nvcc}/bin/ptxas"
51 chmod +x "$out/${python.sitePackages}/triton/third_party/cuda/bin/ptxas"
54 # Bash was getting weird without linting,
55 # but basically upstream contains [cc, ..., "-lcuda", ...]
56 # and we replace it with [..., "-lcuda", "-L/run/opengl-driver/lib", "-L$stubs", ...]
58 new = [ "-lcuda" "-L${addOpenGLRunpath.driverLink}" "-L${cudaPackages.cuda_cudart}/lib/stubs/" ];
60 quote = x: ''"${x}"'';
61 oldStr = lib.concatMapStringsSep ", " quote old;
62 newStr = lib.concatMapStringsSep ", " quote new;
65 substituteInPlace $out/${python.sitePackages}/triton/common/build.py \
66 --replace '${oldStr}' '${newStr}'
70 description = "A language and compiler for custom Deep Learning operations";
71 homepage = "https://github.com/openai/triton/";
72 changelog = "https://github.com/openai/triton/releases/tag/v${version}";
73 # Includes NVIDIA's ptxas, but redistributions of the binary are not limited.
74 # https://docs.nvidia.com/cuda/eula/index.html
75 # triton's license is MIT.
76 # openai-triton-bin includes ptxas binary, therefore unfreeRedistributable is set.
77 license = with licenses; [ unfreeRedistributable mit ];
78 sourceProvenance = with sourceTypes; [ binaryNativeCode ];
79 platforms = [ "x86_64-linux" ];
80 maintainers = with maintainers; [ junjihashimoto ];