Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 106 additions & 0 deletions .devops/nix/rocm-modules-10/amdsmi/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
{
lib,
stdenv,
fetchFromGitHub,
rocmUpdateScript,
cmake,
pkg-config,
libdrm,
libnl,
libmnl,
python,
wrapPython,
autoPatchelfHook,
}:

let
esmi_ib_src = fetchFromGitHub {
owner = "amd";
repo = "esmi_ib_library";
# ROCm 10 pins this exact commit in projects/amdsmi/CMakeLists.txt
rev = "d494a3194ceb4cc4dbb2debf9fcbe8773c6d3bef";
hash = "sha256-StSYzyIujaH8UJIRpfJC0lf+oVT9fWflJgQONvRqu70=";
};
in
stdenv.mkDerivation (finalAttrs: {
pname = "amdsmi";
version = "10.0.0";
src = fetchFromGitHub {
owner = "ROCm";
repo = "rocm-systems";
rev = "therock-10.0";
sparseCheckout = [
"projects/amdsmi"
"shared"
];
hash = "sha256-yhgSwRk9vL40bmnAE3im7DOXy6uMA7NTZxPp5fQC7Qo=";
};
sourceRoot = "${finalAttrs.src.name}/projects/amdsmi";

postPatch = ''
# ROCm 10 dropped the raw -L link line from the goamdsmi shim, so only the
# target rename is still needed here.
substituteInPlace goamdsmi_shim/CMakeLists.txt \
--replace-fail "amd_smi)" ${"'"}''${AMD_SMI_TARGET})'
# ROCm 10 replaced the tag comparison with an offline-safe check: it only
# fetches when esmi_ib_library/src/e_smi.c is absent, which the copy below
# satisfies.

sed -i '/^struct drm_color_ctm_3x4 {/,/^};/d' include/libdrm/drm_mode.h

# Manually unpack esmi_ib_src and add amd_hsmp.h so execute-process git clone doesn't run
cp -rf --no-preserve=mode ${esmi_ib_src} ./esmi_ib_library
mkdir -p ./esmi_ib_library/include/asm
cp ./include/amd_smi/impl/amd_hsmp.h ./esmi_ib_library/include/asm/amd_hsmp.h
'';

# ROCm 10 moved the vendored DRM headers from include/amd_smi/impl/amdgpu_drm.h
# to include/libdrm/, so amdsmi#165 no longer applies. The fix is still needed:
# drm_color_ctm_3x4 is defined by current system libdrm, and the vendored copy
# is unused and not part of the amdsmi public interface.
patches = [ ];

nativeBuildInputs = [
cmake
pkg-config
wrapPython
autoPatchelfHook
];

buildInputs = [
libdrm
# ROCm 10's amdsmi uses system netlink via pkg-config (libnl-3.0, libmnl)
libnl
libmnl
];

cmakeFlags = [
# Manually define CMAKE_INSTALL_<DIR>
# See: https://github.com/NixOS/nixpkgs/pull/197838
"-DCMAKE_INSTALL_BINDIR=bin"
"-DCMAKE_INSTALL_LIBDIR=lib"
"-DCMAKE_INSTALL_INCLUDEDIR=include"
];

postInstall = ''
mkdir -p $out/${python.sitePackages}
ln -s $out/share/amd_smi/amdsmi $out/${python.sitePackages}/amdsmi

makeWrapperArgs=(--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ libdrm ]})
wrapPythonProgramsIn $out
rm $out/bin/amd-smi
ln -sf $out/libexec/amdsmi_cli/amdsmi_cli.py $out/bin/amd-smi
'';

passthru.updateScript = rocmUpdateScript { inherit finalAttrs; };

meta = {
description = "System management interface for AMD GPUs supported by ROCm";
homepage = "https://github.com/ROCm/rocm-systems/tree/develop/projects/amdsmi";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ lovesegfault ];
teams = [ lib.teams.rocm ];
platforms = [ "x86_64-linux" ];
mainProgram = "amd-smi";
};
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
From b8b4a6bcfe35ba9539a120cfd16573123ddd9241 Mon Sep 17 00:00:00 2001
From: "Sv. Lockal" <lockalsash@gmail.com>
Date: Mon, 15 Dec 2025 03:46:35 +0800
Subject: [PATCH] Fix compilation with libdrm-2.4.130

Fix error: redefinition of 'struct drm_color_ctm_3x4'.

drm_color_ctm_3x4 structure is now defined in https://github.com/torvalds/linux/commit/e5719e7f19009d4fbedf685fc22eec9cd8de154f#diff-4c51fb416ec7cc69566cd7b795ee57eb070aa1006ad65d6962081f039ffb2718

As this structure is unused and not a part of amdsmi public interface,
it is safe to remove it.
---
include/amd_smi/impl/amdgpu_drm.h | 9 ---------
1 file changed, 9 deletions(-)

diff --git a/include/amd_smi/impl/amdgpu_drm.h b/include/amd_smi/impl/amdgpu_drm.h
index b56a5ac4b..0e483d13b 100644
--- a/include/amd_smi/impl/amdgpu_drm.h
+++ b/include/amd_smi/impl/amdgpu_drm.h
@@ -1625,15 +1625,6 @@ struct drm_amdgpu_info_uq_metadata {
#define AMDGPU_FAMILY_GC_11_5_0 150 /* GC 11.5.0 */
#define AMDGPU_FAMILY_GC_12_0_0 152 /* GC 12.0.0 */

-/* FIXME wrong namespace! */
-struct drm_color_ctm_3x4 {
- /*
- * Conversion matrix with 3x4 dimensions in S31.32 sign-magnitude
- * (not two's complement!) format.
- */
- __u64 matrix[12];
-};
-
#if defined(__cplusplus)
}
#endif
176 changes: 176 additions & 0 deletions .devops/nix/rocm-modules-10/aotriton/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
{
lib,
stdenv,
fetchFromGitHub,
cmake,
rocm-cmake,
clr,
python3,
ninja,
xz,
writableTmpDirAsHomeHook,
pkg-config,
gpuTargets ? clr.localGpuTargets or clr.gpuTargets,
# for passthru.tests
aotriton,
hello,
}:
let
supportedTargets = lib.lists.intersectLists [
# aotriton GPU support list:
# https://github.com/ROCm/aotriton/blob/main/v2python/gpu_targets.py
"gfx90a"
"gfx942"
"gfx950"
# some gfx1100 kernels fail with error: branch size exceeds simm16
# but build proceeds and those ops will fallback so it's ok
"gfx1100"
"gfx1151"
"gfx1150"
"gfx1201"
"gfx1200"
] gpuTargets;
anySupportedTargets = supportedTargets != [ ];
# Pick a single arbitrary target to speed up shim build when we can't support our target
supportedTargets' =
if anySupportedTargets then lib.concatStringsSep ";" supportedTargets else "gfx1200";
in
stdenv.mkDerivation (finalAttrs: {
pname = "aotriton${lib.optionalString (!anySupportedTargets) "-shim"}";
version = "0.11.1b";

src = fetchFromGitHub {
owner = "ROCm";
repo = "aotriton";
tag = finalAttrs.version;
hash = "sha256-F7JjyS+6gMdCpOFLldTsNJdVzzVwd6lwW7+V8ZOZfig=";
leaveDotGit = true;
# fetch all submodules except unused triton submodule that is ~500MB
postFetch = ''
cd $out
git reset --hard HEAD
for submodule in $(git config --file .gitmodules --get-regexp path | awk '{print $2}' | grep '^third_party/' | grep -v '^third_party/triton$'); do
git submodule update --init --recursive "$submodule"
done
find "$out" -name .git -print0 | xargs -0 rm -rf
'';
};

cmakeBuildType = "RelWithDebInfo";
separateDebugInfo = true;
__structuredAttrs = true;
strictDeps = true;
# Only set big-parallel when we are building kernels, no-image mode build is faster
requiredSystemFeatures = if anySupportedTargets then [ "big-parallel" ] else [ ];

env = {
AOTRITON_CI_SUPPLIED_SHA1 = finalAttrs.version;
ROCM_PATH = "${clr}";
CFLAGS = "-w -g1 -gz -Wno-c++11-narrowing";
CXXFLAGS = finalAttrs.env.CFLAGS;
TRITON_STORE_BINARY_ONLY = 1; # reduce triton disk space usage
};

nativeBuildInputs = [
cmake
rocm-cmake
pkg-config
python3
ninja
clr
writableTmpDirAsHomeHook # venv wants to cache in ~
];

buildInputs = [
clr
xz
]
++ (with python3.pkgs; [
wheel
packaging
pyyaml
numpy
filelock
iniconfig
pluggy
pybind11
pandas
triton
]);

# Excerpt from README:
# Note: do not run ninja separately, due to the limit of the current build system,
# ninja install will run the whole build process unconditionally.
dontBuild = true;
# This builds+installs
installPhase = ''
runHook preInstall
ninja install
runHook postInstall
'';
# tests are intended to be ran manually as test/ python scripts and need accelerator
doCheck = false;
doInstallCheck = false;

# Need to set absolute paths to VENV and its PYTHON or
# build fails with "AOTRITON_INHERIT_SYSTEM_SITE_TRITON is enabled
# but triton is not available … no such file or directory"
# Set via a preConfigure hook so a valid absolute path can be
# picked if nix-shell is used against this package
preConfigure = ''
cmakeFlagsArray+=(
"-DVENV_DIR=$(pwd)/build/venv/"
"-DVENV_BIN_PYTHON=$(pwd)/build/venv/bin/python"
)
'';

cmakeFlags = [
# Disable building kernels if no supported targets are enabled
(lib.cmakeBool "AOTRITON_NOIMAGE_MODE" (!anySupportedTargets))
# Use preinstalled triton from our python's site-packages
(lib.cmakeBool "AOTRITON_INHERIT_SYSTEM_SITE_TRITON" true)
# Circular dependency
(lib.cmakeBool "AOTRITON_USE_TORCH" false)
# FP32 kernels are optional, turn them off to speed up builds and save space
# Perf sensitive code should be using BF16 or F16
(lib.cmakeBool "AOTRITON_ENABLE_FP32_INPUTS" false)
# Avoid kernels being skipped if build host is overloaded
(lib.cmakeFeature "AOTRITON_GPU_BUILD_TIMEOUT" "0")
# Manually define CMAKE_INSTALL_<DIR>
# See: https://github.com/NixOS/nixpkgs/pull/197838
(lib.cmakeFeature "CMAKE_INSTALL_BINDIR" "bin")
(lib.cmakeFeature "CMAKE_INSTALL_LIBDIR" "lib")
(lib.cmakeFeature "CMAKE_INSTALL_INCLUDEDIR" "include")
# Note: build will warn "AMDGPU_TARGETS was not set, and system GPU detection was unsuccsesful."
# but this can safely be ignored, aotriton uses a different approach to pass targets
(lib.cmakeFeature "AOTRITON_TARGET_ARCH" supportedTargets')
];

passthru.tests = {
# regression test that aotriton so doesn't crash in static constructor
# currently known to fail on rocm toolchain but fine with default stdenv
ld-preload-into-hello = stdenv.mkDerivation {
name = "aotriton-basic-load-test";
nativeBuildInputs = [ hello ];
buildCommand = ''
set -e
LD_PRELOAD=${
aotriton.override {
gpuTargets = [ ];
}
}/lib/libaotriton_v2.so ${hello}/bin/hello > /dev/null
echo "ld-preload-into-hello" > $out
'';
};
};

meta = {
description = "ROCm Ahead of Time (AOT) Triton Math Library";
homepage = "https://github.com/ROCm/aotriton";
license = lib.licenses.mit;
teams = [ lib.teams.rocm ];
platforms = lib.platforms.linux;
# ld: error: unable to insert .comment after .comment
broken = stdenv.cc.isClang;
};
})
42 changes: 42 additions & 0 deletions .devops/nix/rocm-modules-10/aqlprofile/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
lib,
stdenv,
clr,
cmake,
fetchFromGitHub,
rocmUpdateScript,
}:

stdenv.mkDerivation (finalAttrs: {
pname = "aqlprofile";
version = "7.2.3";

src = fetchFromGitHub {
owner = "ROCm";
repo = "rocm-systems";
rev = "rocm-${finalAttrs.version}";
sparseCheckout = [
"projects/aqlprofile"
"shared"
];
hash = "sha256-74HjB5Ughu17rSRx9mfCCsPJI4TVyXnT4aU7vIbm7ak=";
};
sourceRoot = "${finalAttrs.src.name}/projects/aqlprofile";

env.CXXFLAGS = "-DROCP_LD_AQLPROFILE=1";

nativeBuildInputs = [
cmake
clr
];

passthru.updateScript = rocmUpdateScript { inherit finalAttrs; };

meta = {
description = "AQLPROFILE library for AMD HSA runtime API extension support";
homepage = "https://github.com/ROCm/rocm-systems/tree/develop/projects/aqlprofile";
license = lib.licenses.mit;
teams = [ lib.teams.rocm ];
platforms = lib.platforms.linux;
};
})
Loading
Loading