Skip to content

Build internal libraries as shared libraries in Python wheels - #389

Merged
scal444 merged 3 commits into
NVIDIA-BioNeMo:release_0_7from
scal444:fix/wheel-shared-libs
Oct 30, 2026
Merged

scal444 merged 3 commits into
NVIDIA-BioNeMo:release_0_7from
scal444:fix/wheel-shared-libs

Conversation

@scal444

@scal444 scal444 commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator

Static internal libraries copied their objects, including each CUDA fatbin, into every Python module that linked them. The BFGS minimizer kernels alone were duplicated across four modules, which pushed wheels past 150 MB.

Build the internal libraries as shared libraries installed next to the modules, link the shared CUDA runtime, and add $ORIGIN to the rpath that repair_wheel.sh writes. Link etkdg_stages to etkdg_impl, which provides the symbols it uses, instead of etkdg; the old link formed a cycle that CMake only permits among static libraries.

Static internal libraries copied their objects, including each CUDA fatbin,
into every Python module that linked them. The BFGS minimizer kernels alone
were duplicated across four modules, which pushed wheels past 150 MB.

Build the internal libraries as shared libraries installed next to the
modules, link the shared CUDA runtime, and add $ORIGIN to the rpath that
repair_wheel.sh writes. Link etkdg_stages to etkdg_impl, which provides the
symbols it uses, instead of etkdg; the old link formed a cycle that CMake
only permits among static libraries.
@greptile-apps

greptile-apps Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the previous finding is fixed and no new actionable issues were found.

Summary

The PR builds internal libraries as shared libraries beside the Python modules, avoiding repeated copies of CUDA code.

  • Python wheels install shared libraries beside their extension modules.
  • Force-field energy totals use one shared CUDA reducer.
  • ETKDG stages link directly to their implementation library.

Reviews (2) · Last reviewed commit: "Describe the shared-library rpath in rep..." · Reviewed by Greptile

Comment thread nvmolkit/CMakeLists.txt Resolved
Shared libraries resolve their own dependencies, so:
- Launch reduceEnergiesKernel through FFKernelUtils::launchReduceEnergiesKernel
  in the library that defines it. CUDA 13 gives kernel host stubs hidden
  visibility, so another library cannot launch the kernel directly. This
  replaces the identical MMFF and DistGeom launchers.
- Declare the libraries each test links instead of relying on static
  libraries to forward their private dependencies.
- Build conformer_checkers only with tests or benchmarks so wheels do not
  install it.
The header still described patching only the _*.so modules without the
$ORIGIN entry for the internal shared libraries.
@scal444
scal444 merged commit 31b2fe8 into NVIDIA-BioNeMo:release_0_7 Oct 30, 2026
12 of 15 checks passed
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.

1 participant