1{
2 lib,
3 stdenv,
4 cudaPackages,
5 buildPythonPackage,
6 fetchurl,
7 python,
8 autoPatchelfHook,
9 filelock,
10 lit,
11 zlib,
12}:
13
14buildPythonPackage rec {
15 pname = "triton";
16 version = "3.4.0";
17 format = "wheel";
18
19 src =
20 let
21 pyVerNoDot = lib.replaceStrings [ "." ] [ "" ] python.pythonVersion;
22 unsupported = throw "Unsupported system";
23 srcs = (import ./binary-hashes.nix version)."${stdenv.system}-${pyVerNoDot}" or unsupported;
24 in
25 fetchurl srcs;
26
27 pythonRemoveDeps = [
28 "cmake"
29 # torch and triton refer to each other so this hook is included to mitigate that.
30 "torch"
31 ];
32
33 buildInputs = [ zlib ];
34
35 nativeBuildInputs = [
36 autoPatchelfHook
37 ];
38
39 propagatedBuildInputs = [
40 filelock
41 lit
42 zlib
43 ];
44
45 dontStrip = true;
46
47 # If this breaks, consider replacing with "${cuda_nvcc}/bin/ptxas"
48 postFixup = ''
49 mkdir -p $out/${python.sitePackages}/triton/third_party/cuda/bin/
50 ln -s ${cudaPackages.cuda_nvcc}/bin/ptxas $out/${python.sitePackages}/triton/third_party/cuda/bin/
51 '';
52
53 meta = {
54 description = "Language and compiler for custom Deep Learning operations";
55 homepage = "https://github.com/triton-lang/triton/";
56 changelog = "https://github.com/triton-lang/triton/releases/tag/v${version}";
57 # Includes NVIDIA's ptxas, but redistributions of the binary are not limited.
58 # https://docs.nvidia.com/cuda/eula/index.html
59 # triton's license is MIT.
60 # triton-bin includes ptxas binary, therefore unfreeRedistributable is set.
61 license = with lib.licenses; [
62 unfreeRedistributable
63 mit
64 ];
65 sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
66 maintainers = with lib.maintainers; [ junjihashimoto ];
67 };
68}