From 013498f6d1365d98a592ba63193e75a71e96c384 Mon Sep 17 00:00:00 2001 From: Sizhe Zhao Date: Thu, 4 Jun 2026 16:13:40 +0800 Subject: [PATCH] python3Packages.tokenspeed-triton: init at 3.7.10.post20260531 --- .../tokenspeed-triton/default.nix | 92 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 + 2 files changed, 94 insertions(+) create mode 100644 pkgs/development/python-modules/tokenspeed-triton/default.nix diff --git a/pkgs/development/python-modules/tokenspeed-triton/default.nix b/pkgs/development/python-modules/tokenspeed-triton/default.nix new file mode 100644 index 000000000000..f63b1973cee8 --- /dev/null +++ b/pkgs/development/python-modules/tokenspeed-triton/default.nix @@ -0,0 +1,92 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + pythonAtLeast, + + # build-system + cmake, + nanobind, + ninja, + setuptools, + + # nativeBuildInputs + writableTmpDirAsHomeHook, + + # buildInputs + tokenspeed-triton-llvm, + nlohmann_json, + zlib, +}: +buildPythonPackage (finalAttrs: { + pname = "tokenspeed-triton"; + version = "3.7.10.post20260531"; + pyproject = true; + __structuredAttrs = true; + + src = fetchFromGitHub { + owner = "lightseekorg"; + repo = "triton"; + tag = "v${finalAttrs.version}"; + hash = "sha256-xsV63z2NtB5BM0rF0J+cnMH2RYzoWkpsSXHQI2nIEdQ="; + }; + + postPatch = '' + substituteInPlace setup.py \ + --replace-fail "TRITON_VERSION = " 'TRITON_VERSION = "${finalAttrs.version}" # ' + + sed -i '/def is_git_repo()/a\\ return False' setup.py + + substituteInPlace pyproject.toml \ + --replace-fail "cmake>=3.20,<4.0" "cmake>=3.20" \ + --replace-fail "nanobind==2.10.2" "nanobind>=2.10.2" + ''; + + build-system = [ + cmake + nanobind + ninja + setuptools + ]; + + dontUseCmakeConfigure = true; + + nativeBuildInputs = [ + writableTmpDirAsHomeHook + ]; + + # https://github.com/lightseekorg/triton/blob/v3.7.10.post20260531/.github/workflows/wheels.yml#L109-L117 + env = { + TRITON_OFFLINE_BUILD = true; + TRITON_BUILD_RELEASE = true; + TRITON_BUILD_PROTON = false; + TRITON_STABLE_ABI = pythonAtLeast "3.12"; + LLVM_SYSPATH = tokenspeed-triton-llvm; + JSON_SYSPATH = nlohmann_json; + NIX_CFLAGS_COMPILE = "-Wno-stringop-overflow"; + }; + + buildInputs = [ + zlib + ]; + + pythonImportsCheck = [ + "tokenspeed_triton" + ]; + + # tests import triton instead of tokenspeed_triton + doCheck = false; + + meta = { + description = "Language and compiler for custom Deep Learning operations"; + homepage = "https://github.com/lightseekorg/triton"; + downloadPage = "https://pypi.org/project/tokenspeed-triton/#files"; + changelog = "https://github.com/lightseekorg/triton/releases/tag/${finalAttrs.src.tag}"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ prince213 ]; + platforms = [ + "aarch64-linux" + "x86_64-linux" + ]; + }; +}) diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index edeaf390c28d..413bf4899c55 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -19800,6 +19800,8 @@ self: super: with self; { tokenlib = callPackage ../development/python-modules/tokenlib { }; + tokenspeed-triton = callPackage ../development/python-modules/tokenspeed-triton { }; + tokentrim = callPackage ../development/python-modules/tokentrim { }; tololib = callPackage ../development/python-modules/tololib { };