From 00207e62b289f1d47acdeb58535650b07139c852 Mon Sep 17 00:00:00 2001 From: Luna Nova Date: Tue, 4 Nov 2025 19:41:04 -0800 Subject: [PATCH 1/4] rocmPackages.rocblas: remove reference to tensile in librocblas rocblas's closure-size was bloated by around 400MB by a ref to tensile in an error message string. tensile is used at build time to build and link kernels, but is not needed at runtime. Before: /nix/store/zggwlwji0jca2cvhgl4ick7l3fwlwsfb-rocblas-gfx1030-6.4.3 1.3G After: /nix/store/71rz9qm323rzmzgkx31llcsnhd0gkvl3-rocblas-gfx1030-6.4.3 904.5M --- pkgs/development/rocm-modules/6/rocblas/default.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkgs/development/rocm-modules/6/rocblas/default.nix b/pkgs/development/rocm-modules/6/rocblas/default.nix index 0c9c2ee5c424..ffaac106de35 100644 --- a/pkgs/development/rocm-modules/6/rocblas/default.nix +++ b/pkgs/development/rocm-modules/6/rocblas/default.nix @@ -24,6 +24,7 @@ python3Packages, rocm-smi, pkg-config, + removeReferencesTo, buildTensile ? true, buildTests ? false, buildBenchmarks ? false, @@ -54,6 +55,7 @@ stdenv.mkDerivation (finalAttrs: { clr gitMinimal pkg-config + removeReferencesTo ] ++ lib.optionals buildTensile [ tensile @@ -148,6 +150,13 @@ stdenv.mkDerivation (finalAttrs: { --replace-fail '0.10' '1.0' ''; + postInstall = + # tensile isn't needed at runtime and pulls in ~400MB of python deps + '' + remove-references-to -t ${tensile} \ + "$out/lib/librocblas.so."* + ''; + passthru = { amdgpu_targets = gpuTargets'; tests.rocblas-tests = finalAttrs.finalPackage.override { From f9864971a4c6b7fc1638db60cc02dcd928ff2209 Mon Sep 17 00:00:00 2001 From: Luna Nova Date: Tue, 4 Nov 2025 19:55:21 -0800 Subject: [PATCH 2/4] rocmPackages: don't set build{Tests,Benchmarks}=false in scope --- pkgs/development/rocm-modules/6/default.nix | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkgs/development/rocm-modules/6/default.nix b/pkgs/development/rocm-modules/6/default.nix index 6654bafef12d..44454b36958a 100644 --- a/pkgs/development/rocm-modules/6/default.nix +++ b/pkgs/development/rocm-modules/6/default.nix @@ -26,8 +26,6 @@ let { inherit rocmClangStdenv; stdenv = rocmClangStdenv; - buildTests = false; - buildBenchmarks = false; rocmUpdateScript = self.callPackage ./update.nix { }; From 5015e4b4468e63846ac14e9938f866d6c34c58e4 Mon Sep 17 00:00:00 2001 From: Luna Nova Date: Tue, 4 Nov 2025 19:54:45 -0800 Subject: [PATCH 3/4] rocmPackages.rocblas: split benchmark and test outputs --- .../rocm-modules/6/rocblas/default.nix | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/pkgs/development/rocm-modules/6/rocblas/default.nix b/pkgs/development/rocm-modules/6/rocblas/default.nix index ffaac106de35..37c303eca46f 100644 --- a/pkgs/development/rocm-modules/6/rocblas/default.nix +++ b/pkgs/development/rocm-modules/6/rocblas/default.nix @@ -26,8 +26,8 @@ pkg-config, removeReferencesTo, buildTensile ? true, - buildTests ? false, - buildBenchmarks ? false, + buildTests ? true, + buildBenchmarks ? true, tensileSepArch ? true, tensileLazyLib ? true, withHipBlasLt ? true, @@ -48,6 +48,8 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-FCzo/BOk4xLEFkdOdqcCXh4a9t3/OIIBEy8oz6oOMWg="; }; + outputs = [ "out" ] ++ lib.optional buildBenchmarks "benchmark" ++ lib.optional buildTests "test"; + nativeBuildInputs = [ cmake # no ninja, it buffers console output and nix times out long periods of no output @@ -78,10 +80,8 @@ stdenv.mkDerivation (finalAttrs: { python3Packages.msgpack python3Packages.zstandard ] - ++ lib.optionals buildTests [ - gtest - ] ++ lib.optionals (buildTests || buildBenchmarks) [ + gtest gfortran rocm-smi ] @@ -155,14 +155,26 @@ stdenv.mkDerivation (finalAttrs: { '' remove-references-to -t ${tensile} \ "$out/lib/librocblas.so."* + '' + + lib.optionalString buildBenchmarks '' + moveToOutput "bin/*-tune" "$benchmark" + moveToOutput "bin/*-bench" "$benchmark" + moveToOutput "bin/*example*" "$benchmark" + cp "$out/bin/"*.{yaml,txt} "$benchmark/bin" + '' + + lib.optionalString buildTests '' + moveToOutput "bin/*test*" "$test" + cp "$out/bin/"*.{yaml,txt} "$test/bin" + '' + + '' + if [ -d $out/bin ]; then + rm $out/bin/*.{yaml,txt} || true + rmdir $out/bin + fi ''; passthru = { amdgpu_targets = gpuTargets'; - tests.rocblas-tests = finalAttrs.finalPackage.override { - buildBenchmarks = true; - buildTests = true; - }; updateScript = rocmUpdateScript { name = finalAttrs.pname; inherit (finalAttrs.src) owner; From 9a22a291a158dfbe3c24fc1b2a8bf5392d931b44 Mon Sep 17 00:00:00 2001 From: Luna Nova Date: Tue, 4 Nov 2025 21:42:35 -0800 Subject: [PATCH 4/4] rocmPackages.rocblas: fix FHS diff path in rocblas test --- pkgs/development/rocm-modules/6/rocblas/default.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkgs/development/rocm-modules/6/rocblas/default.nix b/pkgs/development/rocm-modules/6/rocblas/default.nix index 37c303eca46f..c6bce658f6cc 100644 --- a/pkgs/development/rocm-modules/6/rocblas/default.nix +++ b/pkgs/development/rocm-modules/6/rocblas/default.nix @@ -7,6 +7,7 @@ cmake, rocm-cmake, clr, + diffutils, python3, tensile, boost, @@ -148,6 +149,12 @@ stdenv.mkDerivation (finalAttrs: { substituteInPlace CMakeLists.txt \ --replace-fail "4.43.0" "4.44.0" \ --replace-fail '0.10' '1.0' + '' + # Fixes sh: line 1: /usr/bin/diff: No such file or directory + # /build/source/clients/gtest/../include/testing_logging.hpp:1117: Failure + + lib.optionals buildTests '' + substituteInPlace clients/include/testing_logging.hpp \ + --replace-fail "/usr/bin/diff" "${lib.getExe' diffutils "diff"}" ''; postInstall =