Skip to content

[#11312][chore] Make TRT/NCCL configurable in CMake find modules#11528

Open
xuantengh wants to merge 1 commit intoNVIDIA:mainfrom
xuantengh:main
Open

[#11312][chore] Make TRT/NCCL configurable in CMake find modules#11528
xuantengh wants to merge 1 commit intoNVIDIA:mainfrom
xuantengh:main

Conversation

@xuantengh
Copy link

@xuantengh xuantengh commented Feb 15, 2026

Summary by CodeRabbit

  • Chores
    • Improved NCCL library discovery with version-aware library lookup and expanded search paths for greater installation flexibility.
    • Enhanced TensorRT library and include discovery to support versioned variants and broader installation layouts.

Description

Currently, scripts/build_wheel.py offers options to configure the custom installation path for NCCL/TRT, but the corresponding cpp/cmake/modules/*.cmake modules don't respect the setting. This PR modifies the find_library/find_path in those CMake modules to make it respect the CMake options from build_wheel.py.

Test Coverage

By default, nothing changes if --trt_root nor --nccl_root is not specified in scripts/build_wheel.py. If a user manually sets them when invoking the build script, CMake build system will use the specified path to find the necessary libraries/headers.

PR Checklist

  • Please check this after reviewing the above items as appropriate for this PR.

GitHub Bot Help

/bot [-h] ['run', 'kill', 'skip', 'reuse-pipeline'] ...

Provide a user friendly way for developers to interact with a Jenkins server.

Run /bot [-h|--help] to print this help message.

See details below for each supported subcommand.

Details

run [--reuse-test (optional)pipeline-id --disable-fail-fast --skip-test --stage-list "A10-PyTorch-1, xxx" --gpu-type "A30, H100_PCIe" --test-backend "pytorch, cpp" --add-multi-gpu-test --only-multi-gpu-test --disable-multi-gpu-test --post-merge --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx" --detailed-log --debug(experimental)]

Launch build/test pipelines. All previously running jobs will be killed.

--reuse-test (optional)pipeline-id (OPTIONAL) : Allow the new pipeline to reuse build artifacts and skip successful test stages from a specified pipeline or the last pipeline if no pipeline-id is indicated. If the Git commit ID has changed, this option will be always ignored. The DEFAULT behavior of the bot is to reuse build artifacts and successful test results from the last pipeline.

--disable-reuse-test (OPTIONAL) : Explicitly prevent the pipeline from reusing build artifacts and skipping successful test stages from a previous pipeline. Ensure that all builds and tests are run regardless of previous successes.

--disable-fail-fast (OPTIONAL) : Disable fail fast on build/tests/infra failures.

--skip-test (OPTIONAL) : Skip all test stages, but still run build stages, package stages and sanity check stages. Note: Does NOT update GitHub check status.

--stage-list "A10-PyTorch-1, xxx" (OPTIONAL) : Only run the specified test stages. Examples: "A10-PyTorch-1, xxx". Note: Does NOT update GitHub check status.

--gpu-type "A30, H100_PCIe" (OPTIONAL) : Only run the test stages on the specified GPU types. Examples: "A30, H100_PCIe". Note: Does NOT update GitHub check status.

--test-backend "pytorch, cpp" (OPTIONAL) : Skip test stages which don't match the specified backends. Only support [pytorch, cpp, tensorrt, triton]. Examples: "pytorch, cpp" (does not run test stages with tensorrt or triton backend). Note: Does NOT update GitHub pipeline status.

--only-multi-gpu-test (OPTIONAL) : Only run the multi-GPU tests. Note: Does NOT update GitHub check status.

--disable-multi-gpu-test (OPTIONAL) : Disable the multi-GPU tests. Note: Does NOT update GitHub check status.

--add-multi-gpu-test (OPTIONAL) : Force run the multi-GPU tests in addition to running L0 pre-merge pipeline.

--post-merge (OPTIONAL) : Run the L0 post-merge pipeline instead of the ordinary L0 pre-merge pipeline.

--extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx" (OPTIONAL) : Run the ordinary L0 pre-merge pipeline and specified test stages. Examples: --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx".

--detailed-log (OPTIONAL) : Enable flushing out all logs to the Jenkins console. This will significantly increase the log volume and may slow down the job.

--debug (OPTIONAL) : Experimental feature. Enable access to the CI container for debugging purpose. Note: Specify exactly one stage in the stage-list parameter to access the appropriate container environment. Note: Does NOT update GitHub check status.

For guidance on mapping tests to stage names, see docs/source/reference/ci-overview.md
and the scripts/test_to_stage_mapping.py helper.

kill

kill

Kill all running builds associated with pull request.

skip

skip --comment COMMENT

Skip testing for latest commit on pull request. --comment "Reason for skipping build/test" is required. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.

reuse-pipeline

reuse-pipeline

Reuse a previous pipeline to validate current commit. This action will also kill all currently running builds associated with the pull request. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.

Signed-off-by: Xuanteng Huang <xuanteng.huang@outlook.com>
@xuantengh xuantengh requested a review from a team as a code owner February 15, 2026 12:33
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 15, 2026

📝 Walkthrough

Walkthrough

The pull request broadens library discovery for NCCL and TensorRT CMake find modules by expanding search paths and adding support for versioned library names, enabling more flexible installation layouts.

Changes

Cohort / File(s) Summary
CMake Find Modules
cpp/cmake/modules/FindNCCL.cmake, cpp/cmake/modules/FindTensorRT.cmake
Expand library and include directory search paths to support versioned library name variants (e.g., libnccl.so.${NCCL_FIND_VERSION_MAJOR}, libnvinfer.so.${TensorRT_VERSION_MAJOR}) and additional installation root directories, improving compatibility with alternative package layouts.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: making TRT/NCCL configurable in CMake modules, which aligns with the pull request's purpose of respecting custom installation paths.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main
Description check ✅ Passed The PR provides a clear description of the issue and solution, explaining why CMake modules need to respect custom paths from build_wheel.py options.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@cpp/cmake/modules/FindNCCL.cmake`:
- Around line 18-21: The find_path call that sets NCCL_INCLUDE_DIR must also
search the custom NCCL_ROOT like the find_library call does; update the
find_path invocation (the call named find_path that produces NCCL_INCLUDE_DIR)
to include PATHS ${NCCL_ROOT} so headers (e.g., nccl.h) are resolvable when
--nccl_root is provided, matching the behavior of the existing find_library for
NCCL_LIBRARY.
🧹 Nitpick comments (1)
cpp/cmake/modules/FindNCCL.cmake (1)

20-20: Minor: versioned library name depends on NCCL_FIND_VERSION_MAJOR being set.

If find_package(NCCL) is called without a version argument, NCCL_FIND_VERSION_MAJOR will be empty and the name expands to "libnccl.so.", which won't match anything. This is harmless (the plain nccl name will still match), but worth being aware of. Consider guarding it:

Suggested guard
-  NAMES nccl "libnccl.so.${NCCL_FIND_VERSION_MAJOR}"
+  NAMES nccl $<$<BOOL:${NCCL_FIND_VERSION_MAJOR}>:libnccl.so.${NCCL_FIND_VERSION_MAJOR}>

Or more idiomatically in CMake:

set(_nccl_names nccl)
if(NCCL_FIND_VERSION_MAJOR)
  list(APPEND _nccl_names "libnccl.so.${NCCL_FIND_VERSION_MAJOR}")
endif()

find_library(
  NCCL_LIBRARY
  NAMES ${_nccl_names}
  PATHS ${NCCL_ROOT})

Comment on lines +18 to +21
find_library(
NCCL_LIBRARY
NAMES nccl "libnccl.so.${NCCL_FIND_VERSION_MAJOR}"
PATHS ${NCCL_ROOT})
Copy link
Contributor

@coderabbitai coderabbitai bot Feb 15, 2026

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

find_path for NCCL_INCLUDE_DIR (line 33) is missing NCCL_ROOT—headers won't be found from custom paths.

The find_library call now correctly searches ${NCCL_ROOT}, but the find_path on line 33 was not updated to match. When --nccl_root is set to a custom location, CMake will find the library but fail to locate nccl.h, causing the overall find to fail (since NCCL_INCLUDE_DIR is a REQUIRED_VARS on line 62).

Proposed fix
-find_path(NCCL_INCLUDE_DIR NAMES nccl.h)
+find_path(NCCL_INCLUDE_DIR NAMES nccl.h PATHS ${NCCL_ROOT}/include)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
find_library(
NCCL_LIBRARY
NAMES nccl "libnccl.so.${NCCL_FIND_VERSION_MAJOR}"
PATHS ${NCCL_ROOT})
find_library(
NCCL_LIBRARY
NAMES nccl "libnccl.so.${NCCL_FIND_VERSION_MAJOR}"
PATHS ${NCCL_ROOT})
find_path(NCCL_INCLUDE_DIR NAMES nccl.h PATHS ${NCCL_ROOT}/include)
🤖 Prompt for AI Agents
In `@cpp/cmake/modules/FindNCCL.cmake` around lines 18 - 21, The find_path call
that sets NCCL_INCLUDE_DIR must also search the custom NCCL_ROOT like the
find_library call does; update the find_path invocation (the call named
find_path that produces NCCL_INCLUDE_DIR) to include PATHS ${NCCL_ROOT} so
headers (e.g., nccl.h) are resolvable when --nccl_root is provided, matching the
behavior of the existing find_library for NCCL_LIBRARY.

Copy link
Collaborator

Choose a reason for hiding this comment

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

On a related note, I think it's unlikely that the un-versioned "libnccl.so" symlink is missing while the NCCL headers are present. If the header files and the library come from different versions of NCCL, the version skew may cause some unexpected linking issues. Perhaps adding "libnccl.so.${NCCL_FIND_VERSION_MAJOR}" to the find_library isn't necessary? If you feel it is necessary, can you please explain how you obtain this combination of header and library files?

This comment (but not coderabbit's comment) also applies to TensorRT.

Copy link
Contributor

Choose a reason for hiding this comment

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

@tburt-nv, you raise a valid point. In standard NCCL and TensorRT installations, the unversioned symlink (e.g., libnccl.solibnccl.so.2) is always present alongside the headers as part of the development package. Adding the versioned library name to the search seems orthogonal to the PR's main objective, which is to respect custom installation paths via --nccl_root and --trt_root.

The addition of PATHS ${NCCL_ROOT} is clearly necessary to make the custom paths work, but the versioned library names (libnccl.so.${NCCL_FIND_VERSION_MAJOR}) appear to address a different scenario that isn't explained in the PR description.

@xuantengh, could you clarify the use case where:

  1. The versioned library file exists (e.g., libnccl.so.2)
  2. But the unversioned symlink (libnccl.so) is missing
  3. Yet headers are still present

Without understanding this scenario, it's difficult to assess whether the versioned library name search is necessary or if it might inadvertently introduce version skew issues as tburt-nv mentioned. The same question applies to your TensorRT changes in FindTensorRT.cmake.


🧠 Learnings used
Learnt from: tongyuantongyu
Repo: NVIDIA/TensorRT-LLM PR: 7763
File: cpp/tensorrt_llm/CMakeLists.txt:297-301
Timestamp: 2025-09-16T09:30:09.716Z
Learning: In the TensorRT-LLM project, NCCL libraries are loaded earlier by PyTorch libraries or the bindings library, so the main shared library doesn't need NCCL paths in its RPATH - the libraries will already be available in the process address space when needed.

Learnt from: nv-lschneider
Repo: NVIDIA/TensorRT-LLM PR: 7910
File: cpp/tensorrt_llm/thop/allreduceOp.cpp:352-446
Timestamp: 2025-09-23T15:12:38.312Z
Learning: In TensorRT-LLM NCCL device implementation, NCCL version 2.28+ requirements are handled at runtime in the nccl_device/config layer rather than with compile-time guards. This allows the allreduceOp to remain version-agnostic and delegates version compatibility validation to the appropriate lower-level components that can gracefully handle unsupported configurations.

Learnt from: nv-lschneider
Repo: NVIDIA/TensorRT-LLM PR: 7910
File: cpp/tensorrt_llm/kernels/nccl_device/config.cu:15-17
Timestamp: 2025-09-23T15:01:00.070Z
Learning: In TensorRT-LLM NCCL device kernels, the <sstream> header is not needed as an explicit include in config.cu because it's provided transitively through other headers. Local compilation testing confirms this works without the explicit include.

Learnt from: tongyuantongyu
Repo: NVIDIA/TensorRT-LLM PR: 6984
File: cpp/tensorrt_llm/CMakeLists.txt:297-299
Timestamp: 2025-08-18T09:08:07.687Z
Learning: In the TensorRT-LLM project, artifacts are manually copied rather than installed via `cmake --install`, so INSTALL_RPATH properties are not needed - only BUILD_RPATH affects the final artifacts.

@svc-trtllm-gh-bot svc-trtllm-gh-bot added the Community want to contribute PRs initiated from Community label Feb 15, 2026
Comment on lines +24 to +25
PATHS ${TensorRT_WELL_KNOWN_ROOT}/include ${TensorRT_ROOT}/include
${TensorRT_ROOT}/include/tensorrt)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think CMake will still select ${TensorRT_WELL_KNOWN_ROOT}/include if it's present, since it comes first in these lists. Shall we swap the order so that ${TensorRT_ROOT}/include and ${TensorRT_ROOT}/include/tensorrt take priority when the --trt_root argument is given? I think the same applies to all PATHS modifications in this patch.

Comment on lines +97 to +98
NAMES "nvonnxparser_${TensorRT_VERSION_MAJOR}"
"libnvonnxparser.so.${TensorRT_VERSION_MAJOR}" nvonnxparser
Copy link
Collaborator

Choose a reason for hiding this comment

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

In this case, we should prioritize the un-versioned library when available.

Suggested change
NAMES "nvonnxparser_${TensorRT_VERSION_MAJOR}"
"libnvonnxparser.so.${TensorRT_VERSION_MAJOR}" nvonnxparser
NAMES "nvonnxparser_${TensorRT_VERSION_MAJOR}"
nvonnxparser "libnvonnxparser.so.${TensorRT_VERSION_MAJOR}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Community want to contribute PRs initiated from Community

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants