Skip to content

Add cxxdev output to torch-bin - #116

Merged
danieldk merged 1 commit into
mainfrom
torch-bin-cxxdev
Oct 15, 2025
Merged

Add cxxdev output to torch-bin#116
danieldk merged 1 commit into
mainfrom
torch-bin-cxxdev

Conversation

@danieldk

Copy link
Copy Markdown
Member

This output propagates C++ dependencies in a similar way as the from-source Torch derivations.

This output propagates C++ dependencies.

@MekkCyber MekkCyber left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice! Thanks

Comment on lines +114 to +121
rm -rf $out/nix-support

# Variables that we want to pass through to downstream derivations.
mkdir -p $out/nix-support
echo 'export ROCM_PATH="${placeholder "out"}"' >> $out/nix-support/setup-hook
echo 'export ROCM_SOURCE_DIR="${placeholder "out"}"' >> $out/nix-support/setup-hook
echo 'export CMAKE_CXX_FLAGS="-I${placeholder "out"}/include -I${placeholder "out"}/include/rocblas"' >> $out/nix-support/setup-hook
'';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is out generated internally by symlinkJoin to provide the output of linked rocm packages ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep! out is the standard output.

Comment on lines +85 to +109
aotriton
clr
comgr
hipblas
hipblas-common-devel
hipblaslt
hipfft
hipify-clang
hiprand
hipsolver
hipsparse
hipsparselt
hsa-rocr
miopen-hip
rccl
rocblas
rocm-core
rocm-device-libs
rocm-hip-runtime
rocm-smi-lib
rocminfo
rocrand
rocsolver
rocsparse
roctracer

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are already built and cached right ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed.

Comment on lines +210 to +214
# Remove all ROCm libraries, we want to link against Nix packages.
# This keeps the outputs lean and requires downstream to specify
# dependencies.
rm -rf $out/${python.sitePackages}/torch/lib/{libamd*,libaotriton*,libdrm*,libelf*,libgomp*,libhip*,libhsa*,libMIOpen*,libnuma*,librccl*,libroc*,libtinfo*}.so
rm -rf $out/${python.sitePackages}/torch/lib/{rocblas,hipblaslt,hipsparselt}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing that removing the libs don't break anything ! but how are we linking to the nix provided deps here ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

autoPatchelfHook does it automatically for us:

We only have to make sure that the dependencies are visible through buildInputs.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oooh nice

Comment on lines +135 to +137
cudaPropagateToOutput = "cxxdev";
rocmPropagateToOutput = "cxxdev";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are part of the buildPythonPackage attributes ?

@danieldk danieldk Oct 15, 2025

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any buildPythonPackage/mkDerivation attribute that is not used by buildPythonPackage/mkDerivation is exposed as an environment variable in the build environment. These then get picked up by the CUDA/ROCm setup hooks:

printWords "${propagatedBuildInputs[@]}" >> "${!cudaPropagateToOutput}/nix-support/propagated-build-inputs"

Comment on lines +131 to +133
outputs = [
"out" # output standard python package
"cxxdev" # propagated deps for the cmake consumers of torch

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how does nix know which ouptut is which here, I mean why does out contain the standard package, and cxxdev the other deps ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By default everything goes to out. The other outputs you can move files to manually, e.g. by doing something like

mv $out/somefile $cxxdev/

But here we rely on the CUDA/ROCm setup hooks to put stuff in the cxxdev output.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good! thanks for the insights

@danieldk
danieldk merged commit 65870ec into main Oct 15, 2025
1 of 2 checks passed
@danieldk
danieldk deleted the torch-bin-cxxdev branch October 15, 2025 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants