Skip to content

Commit 573cead

Browse files
authored
Merge pull request #286763 from CertainLach/openai-triton
python311Packages.openai-triton: remove ptxas --version call when built without cuda support
2 parents aa5da33 + 962cced commit 573cead

File tree

2 files changed

+51
-2
lines changed

2 files changed

+51
-2
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
From 10f3d49aa6084d1b9b9624017cce7df106b9fb7e Mon Sep 17 00:00:00 2001
2+
From: Yaroslav Bolyukin <[email protected]>
3+
Date: Tue, 6 Feb 2024 13:51:28 +0100
4+
Subject: [PATCH] ptxas: disable version key for non-cuda targets
5+
6+
---
7+
python/triton/runtime/jit.py | 4 ++--
8+
1 file changed, 2 insertions(+), 2 deletions(-)
9+
10+
diff --git a/python/triton/runtime/jit.py b/python/triton/runtime/jit.py
11+
index d55972b4b..bd875a701 100644
12+
--- a/python/triton/runtime/jit.py
13+
+++ b/python/triton/runtime/jit.py
14+
@@ -117,8 +117,8 @@ def version_key():
15+
with open(lib.module_finder.find_spec(lib.name).origin, "rb") as f:
16+
contents += [hashlib.md5(f.read()).hexdigest()]
17+
# ptxas version
18+
- ptxas = path_to_ptxas()[0]
19+
- ptxas_version = hashlib.md5(subprocess.check_output([ptxas, "--version"])).hexdigest()
20+
+ # ptxas = path_to_ptxas()[0]
21+
+ ptxas_version = "noptxas"
22+
return '-'.join(TRITON_VERSION) + '-' + ptxas_version + '-' + '-'.join(contents)
23+
24+
25+
--
26+
2.43.0
27+

pkgs/development/python-modules/openai-triton/default.nix

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
, filelock
2020
, torchWithRocm
2121
, python
22+
23+
, runCommand
24+
2225
, cudaPackages
2326
, cudaSupport ? config.cudaSupport
2427
}:
@@ -46,6 +49,9 @@ buildPythonPackage rec {
4649
})
4750
] ++ lib.optionals (!cudaSupport) [
4851
./0000-dont-download-ptxas.patch
52+
# openai-triton wants to get ptxas version even if ptxas is not
53+
# used, resulting in ptxas not found error.
54+
./0001-ptxas-disable-version-key-for-non-cuda-targets.patch
4955
];
5056

5157
nativeBuildInputs = [
@@ -71,7 +77,12 @@ buildPythonPackage rec {
7177
zlib
7278
];
7379

74-
propagatedBuildInputs = [ filelock ];
80+
propagatedBuildInputs = [
81+
filelock
82+
# openai-triton uses setuptools at runtime:
83+
# https://github.com/NixOS/nixpkgs/pull/286763/#discussion_r1480392652
84+
setuptools
85+
];
7586

7687
postPatch = let
7788
# Bash was getting weird without linting,
@@ -150,7 +161,18 @@ buildPythonPackage rec {
150161
# ];
151162

152163
# Ultimately, torch is our test suite:
153-
passthru.tests = { inherit torchWithRocm; };
164+
passthru.tests = {
165+
inherit torchWithRocm;
166+
# Implemented as alternative to pythonImportsCheck, in case if circular dependency on torch occurs again,
167+
# and pythonImportsCheck is commented back.
168+
import-triton = runCommand "import-triton" { nativeBuildInputs = [(python.withPackages (ps: [ps.openai-triton]))]; } ''
169+
python << \EOF
170+
import triton
171+
import triton.language
172+
EOF
173+
touch "$out"
174+
'';
175+
};
154176

155177
pythonRemoveDeps = [
156178
# Circular dependency, cf. https://github.com/openai/triton/issues/1374

0 commit comments

Comments
 (0)