Skip to content
156 changes: 156 additions & 0 deletions easybuild/easyconfigs/t/Triton/Triton-3.3.1-gfbf-2024a-CUDA-12.6.0.eb
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
easyblock = 'PythonBundle'

name = 'Triton'
version = '3.3.1'
versionsuffix = '-CUDA-%(cudaver)s'

homepage = 'https://triton-lang.org/'

description = """Triton is a language and compiler for parallel programming. It aims to provide a
Python-based programming environment for productively writing custom DNN compute
kernels capable of running at maximal throughput on modern GPU hardware."""

toolchain = {'name': 'gfbf', 'version': '2024a'}

builddependencies = [
('CMake', '3.29.3'),
('Ninja', '1.12.1'),
('nlohmann_json', '3.11.3'),
# LLVM dependencies
('git', '2.45.1'),
('libxml2', '2.12.7'),
('lit', '18.1.7'),
('ncurses', '6.5'),
]

dependencies = [
('CUDA', '12.6.0', '', SYSTEM),
('Python', '3.12.3'),
('Python-bundle-PyPI', '2024.06'),
('SciPy-bundle', '2024.05'),
('pybind11', '2.12.0'),
('Z3', '4.13.0'),
# LLVM dependencies
('zstd', '1.5.6'),
('zlib', '1.3.1'),
]

local_arch = {"arm64": "sbsa", "aarch64": "sbsa"}.get(ARCH, ARCH)

components = [
# Use same major.minor version as Triton, see this file using the right tag instead of 'main':
# https://github.com/triton-lang/triton/blob/main/cmake/nvidia-toolchain-version.json
# Check https://developer.download.nvidia.com/compute/cuda/redist for the latest version of redistrib_*.json.
# Generate checksums with:
# wget -O- https://developer.download.nvidia.com/compute/cuda/redist/redistrib_12.4.1.json | \
# jq -r '.cuda_nvcc | to_entries[] | select(.value | type=="object") | "'\
# \''" + (.value.relative_path | split("/")[-1]) + "'\'': '\''" + .value.sha256 + "'\'',"'
('CUDA-NVCC', '12.4.131', {
'easyblock': 'MakeCp',
'source_urls': [f'https://developer.download.nvidia.com/compute/cuda/redist/cuda_nvcc/linux-{local_arch}'],
'sources': [f'cuda_nvcc-linux-{local_arch}-%(version)s-archive.tar.xz'],
'checksums': [{
'cuda_nvcc-linux-x86_64-12.4.131-archive.tar.xz':
'7ffba1ada0e4b8c17e451ac7a60d386aa2642ecd08d71202a0b100c98bd74681',
'cuda_nvcc-linux-ppc64le-12.4.131-archive.tar.xz':
'2934e83a4df2e0f4182e148753cfd1f29af226a280ea459008819531e9edb5b9',
'cuda_nvcc-linux-sbsa-12.4.131-archive.tar.xz':
'83f130dab0325e12b90fdf1279c0cbbd88acf638ef0a7e0cad72d50855a4f44a',
'cuda_nvcc-linux-aarch64-12.4.131-archive.tar.xz':
'9e7a26fb7acd86ec8d4b67799a329d9bc6bd48bbf27a89f87df4385eb7fe5758',
}],
'skipsteps': ['build'],
'files_to_copy': [(['cuda_nvcc-linux*/bin/ptxas'], 'tools')],
}),
# Hash from cmake/llvm-hash.txt
('LLVM', 'a66376b0dc3b2ea8a84fda26faca287980986f78', {
'easyblock': 'CMakeNinja',
'source_urls': ['https://github.com/llvm/llvm-project/archive/'],
'sources': [{
'download_filename': '%(version)s.tar.gz',
'filename': 'llvm-project-%(version)s.tar.gz',
}],
'checksums': [
{'llvm-project-a66376b0dc3b2ea8a84fda26faca287980986f78.tar.gz':
'10eb1d36aabbc5d31c9d2af27844f51638d40be28975a4ab20ad13609f7da23d'},
],
'start_dir': 'llvm-project-%(version)s',
'separate_build_dir': 'llvm_build_dir',
'configopts': ' '.join([
# Reduce dependencies
'-DLLVM_ENABLE_BINDINGS=OFF', # Requires OCAML
'-DLLVM_ENABLE_LIBEDIT=OFF',
# See https://github.com/triton-lang/triton/blob/develop/scripts/build-llvm-project.sh
'-DCMAKE_BUILD_TYPE="Release"',
'-DLLVM_CCACHE_BUILD=OFF',
'-DLLVM_ENABLE_ASSERTIONS=ON',
'-DLLVM_OPTIMIZED_TABLEGEN=ON',
'-DLLVM_TARGETS_TO_BUILD="Native;NVPTX;AMDGPU"',
'-DLLVM_ENABLE_PROJECTS="mlir;llvm"',
]),
'srcdir': 'llvm',
'skipsteps': ['install'],
}),
]

local_preinstallopts = ' '.join([
'TRITON_BUILD_WITH_CLANG_LLD=0',
"TRITON_HOME='%(builddir)s/triton_home'",
'TRITON_OFFLINE_BUILD=1',
'TRITON_PTXAS_PATH="%(installdir)s/tools/ptxas"',
'TRITON_CUOBJDUMP_PATH="$CUDA_HOME/bin/cubjdump"',
'TRITON_NVDISASM_PATH="$CUDA_HOME/bin/nvdisasm"',
'LLVM_SYSPATH="%(builddir)s/llvm_build_dir"',
'JSON_SYSPATH="$EBROOTNLOHMANN_JSON"',
'PYBIND11_SYSPATH="$EBROOTPYBIND11"',
'MAX_JOBS=%(parallel)s',
# Build type
'DEBUG=0 REL_WITH_DEB_INFO=0 TRITON_REL_BUILD_WITH_ASSERTS=1',
"TRITON_APPEND_CMAKE_ARGS='-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON'",
]) + ' '

exts_list = [
(name, version, {
# make pip print output of cmake
'installopts': "-v ",
# ensure that libdevice.10.bc from $EBROOTCUDA/nvvm/libdevice is used:
'postinstallcmds': [
'rm -rf %(installdir)s/lib/python%(pyshortver)s/site-packages/triton/backends/nvidia/lib/libdevice.10.bc'
],
'preinstallopts': local_preinstallopts,
'source_urls': ['https://github.com/triton-lang/triton/archive/'],
'sources': ['v%(version)s.tar.gz'],
'patches': [
'Triton-3.3.1_disable-git-submodule-call.patch',
'Triton-3.3.1_disable-git-version-check.patch',
],
'checksums': [
{'v3.3.1.tar.gz': '9dc77d9205933bf2fc05eb054f4f1d92acd79a963826174d57fe9cfd58ba367b'},
{'Triton-3.3.1_disable-git-submodule-call.patch':
'26859c9388a4f43d326e362a625e3703f2c39a6f075af590f08660d343f78e19'},
{'Triton-3.3.1_disable-git-version-check.patch':
'e77b98e127699c189d4ca3afb0c5374c5e9f1351e82d529ae2521d3dcee70fed'},
],
'start_dir': 'python',
}),
]

postinstallpatches = [('triton_test.py', 'test/triton_test.py')]

checksums = [
{'triton_test.py': '02a3390a5dbe27385358ab319cf10972cd8b51aca599a6809efea612a90ecdba'},
]

sanity_check_commands = ['TRITON_HOME=$TMPDIR/eb-triton_home '
'python %(installdir)s/test/triton_test.py %(cuda_compute_capabilities)s']

modextrapaths = {
'TRITON_PTXAS_PATH': 'tools/ptxas',
}
modextravars = {
# Search for "_path_to_binary" in Triton sources
'TRITON_CUOBJDUMP_PATH': '$CUDA_HOME/bin/cubjdump',
'TRITON_LIBDEVICE_PATH': '$CUDA_HOME/nvvm/libdevice/libdevice.10.bc',
}

moduleclass = 'devel'
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
We don't have a .git folder/git checkout so this call will fail or do something unexpected.

Author: Alexander Grund (TU Dresden)

diff --git a/setup.py b/setup.py
--- a/python/setup.py
+++ b/python/setup.py
@@ -55,14 +55,6 @@ class BackendInstaller:
assert backend_name in os.listdir(
root_dir), f"{backend_name} is requested for install but not present in {root_dir}"

- try:
- subprocess.run(["git", "submodule", "update", "--init", f"{backend_name}"], check=True,
- stdout=subprocess.DEVNULL, cwd=root_dir)
- except subprocess.CalledProcessError:
- pass
- except FileNotFoundError:
- pass
-
backend_src_dir = os.path.join(root_dir, backend_name)

backend_path = os.path.abspath(os.path.join(backend_src_dir, "backend"))
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Running git on the source tarball cannot return useful information, so just disable it.

Author: Alexander Grund (TU Dresden)

diff --git a/setup.py b/setup.py
--- a/python/setup.py
+++ b/python/setup.py
@@ -739,6 +739,7 @@ def get_git_branch():


def get_git_version_suffix():
+ return ''
branch = get_git_branch()
if branch.startswith("release"):
return ""
21 changes: 21 additions & 0 deletions easybuild/easyconfigs/t/Triton/triton_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""Basic test the Triton installation works"""

import sys
import triton
from triton.backends.compiler import GPUTarget


@triton.jit
def kernel(_a, _b):
pass


src = triton.compiler.ASTSource(
fn=kernel,
signature="i32,i32",
)

cuda_cc = sys.argv[1].split(',')[-1]
target = GPUTarget("cuda", int(cuda_cc.replace('.', '')), 32)
output = triton.compile(src, target=target)
print(output)