Skip to content

ci: add CPU-only C++ build coverage - #119

Merged
rapids-bot[bot] merged 9 commits into
release/26.06from
add-cpu-only-build-ci
May 19, 2026
Merged

ci: add CPU-only C++ build coverage#119
rapids-bot[bot] merged 9 commits into
release/26.06from
add-cpu-only-build-ci

Conversation

@csadorf

@csadorf csadorf commented May 18, 2026

Copy link
Copy Markdown
Contributor

Adds a PR CI job that builds libnvforest with NVFOREST_ENABLE_GPU=OFF, reusing the existing conda C++ build path by passing NVFOREST_EXTRA_CMAKE_ARGS through the libnvforest recipe.

Closes #118

@csadorf csadorf added improvement Improves an existing functionality non-breaking Introduces a non-breaking change labels May 18, 2026
@copy-pr-bot

copy-pr-bot Bot commented May 18, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@github-actions github-actions Bot added the conda Relates to conda packaging label May 18, 2026
@csadorf
csadorf force-pushed the add-cpu-only-build-ci branch from f9cf095 to 6ddd13d Compare May 18, 2026 19:55
@csadorf csadorf linked an issue May 18, 2026 that may be closed by this pull request
@csadorf

csadorf commented May 18, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 5a76c2d

@csadorf
csadorf marked this pull request as ready for review May 18, 2026 20:45
@csadorf
csadorf requested review from a team as code owners May 18, 2026 20:45
@csadorf
csadorf requested a review from KyleFromNVIDIA May 18, 2026 20:45
@coderabbitai

coderabbitai Bot commented May 18, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: d4a78889-0a9d-4815-bb96-92853913c8f7

📥 Commits

Reviewing files that changed from the base of the PR and between 7fd48e0 and 042cf65.

📒 Files selected for processing (1)
  • cpp/include/nvforest/exceptions.hpp
🚧 Files skipped from review as they are similar to previous changes (1)
  • cpp/include/nvforest/exceptions.hpp

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • Improved model import validation with clearer runtime errors for invalid model formats and multi-class setups.
    • Fixed exception message handling so errors reliably own and report their text.
  • Chores

    • Added a CPU-only C++ build check to CI and made a build-time argument available to control CPU/GPU behavior.
  • Tests

    • Updated prediction tests to run correctly across CPU and GPU configurations.

Walkthrough

Adds a CI job that builds C++ with NVFOREST_ENABLE_GPU=OFF (gated to C++ changes) and surfaces NVFOREST_EXTRA_CMAKE_ARGS to the conda recipe; updates source/tests for CPU-only builds (owned exception messages, conditional CUDA usage, Treelite importer runtime validation, and raft_proto test handle adaptation).

Changes

CPU-only C++ build CI coverage and supporting fixes

Layer / File(s) Summary
CI workflow job and recipe configuration
.github/workflows/pr.yaml, conda/recipes/libnvforest/recipe.yaml
New conda-cpp-build-cpu job runs ci/build_cpp.sh with NVFOREST_EXTRA_CMAKE_ARGS=-DNVFOREST_ENABLE_GPU=OFF, gated to the test_cpp changed-file group and added to pr-builder.needs; recipe accepts NVFOREST_EXTRA_CMAKE_ARGS in the build env.
Conditional CUDA include and GPU checks
cpp/include/nvforest/forest_model.hpp
CUDA header is included only when NVFOREST_ENABLE_GPU is defined; pointer-based predict only calls cudaGetDevice under that flag and throws raft_proto::gpu_unsupported for GPU memory types in CPU-only builds.
Treelite importer validation and string support
cpp/include/nvforest/treelite_importer.hpp
Added <string> include and replaced ASSERT validations with model_import_error exceptions for multi-target rejection and MultiClf tree assignment conventions.
Tests: raft_proto handle adaptation
cpp/tests/treelite_importer.cpp
Added nvforest/detail/raft_proto/handle.hpp and updated tests to construct raft_proto::handle_t, initializing from raft::handle_t only when GPU support is enabled.
Exception message ownership fix
cpp/include/nvforest/exceptions.hpp
model_import_error now stores an owned std::string msg_ and what() returns msg_.c_str(); constructor changed to accept std::string.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • rapidsai/nvforest#110: Also modifies .github/workflows/pr.yaml for C++ build orchestration and related reusable workflow refs.

Suggested labels

ci

Suggested reviewers

  • KyleFromNVIDIA
  • bdice
  • dantegd
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding CPU-only C++ build CI coverage.
Description check ✅ Passed The description clearly explains the change and links to issue #118, which aligns with the changeset.
Linked Issues check ✅ Passed The PR fulfills all coding requirements from #118: adds CPU-only build CI job, configures NVFOREST_ENABLE_GPU=OFF with BUILD_NVFOREST_TESTS=ON, and ensures the job runs for C++-relevant changes.
Out of Scope Changes check ✅ Passed All changes are in-scope: CI workflow updates, conda recipe environment variable, and necessary exception/header fixes to support CPU-only builds.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch add-cpu-only-build-ci

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

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@cpp/include/nvforest/forest_model.hpp`:
- Around line 14-15: The public header unconditionally includes
<cuda_runtime_api.h>, forcing CUDA as a dependency; wrap that include in an
NVFOREST_ENABLE_GPU guard (as done in cuda_stream.hpp) so the header only pulls
in CUDA when GPU support is enabled, and leave the existing conditional usage of
cudaGetDevice() (e.g., where used in functions/methods referencing cudaGetDevice
or GPU memory types around line ~294) unchanged; ensure the guard uses `#ifdef`
NVFOREST_ENABLE_GPU / `#endif` around the include to allow CPU-only consumers to
build without CUDA headers.

In `@cpp/include/nvforest/treelite_importer.hpp`:
- Around line 374-377: The code uses tl_model.num_class[0] in a modulo without
validating it; validate the model's class info before the grove-per-class loop
by confirming tl_model.num_class has at least one element and that
tl_model.num_class[0] > 0, and if not throw a model_import_error with a clear
message; do this check prior to calling num_trees/entering the for-loop (or
immediately before the modulo in the loop) so tree_id % tl_model.num_class[0]
cannot cause division-by-zero or UB when processing trees in num_trees, and
reference the symbols num_trees, tl_model, num_class, tree_id, and
model_import_error when locating the insertion point.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 8fa75113-7012-4038-8fab-da37136da3d2

📥 Commits

Reviewing files that changed from the base of the PR and between abbcdbc and 5a76c2d.

📒 Files selected for processing (6)
  • .github/workflows/pr.yaml
  • conda/recipes/libnvforest/recipe.yaml
  • cpp/include/nvforest/exceptions.hpp
  • cpp/include/nvforest/forest_model.hpp
  • cpp/include/nvforest/treelite_importer.hpp
  • cpp/tests/treelite_importer.cpp

Comment thread cpp/include/nvforest/forest_model.hpp
Comment thread cpp/include/nvforest/treelite_importer.hpp

@dantegd dantegd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

Comment thread cpp/include/nvforest/exceptions.hpp Outdated
@csadorf
csadorf removed the request for review from KyleFromNVIDIA May 19, 2026 02:04
@csadorf

csadorf commented May 19, 2026

Copy link
Copy Markdown
Contributor Author

/merge

@rapids-bot
rapids-bot Bot merged commit 0737c0d into release/26.06 May 19, 2026
66 checks passed
@csadorf
csadorf deleted the add-cpu-only-build-ci branch May 19, 2026 02:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conda Relates to conda packaging CUDA/C++ improvement Improves an existing functionality non-breaking Introduces a non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add CI coverage for NVFOREST_ENABLE_GPU=OFF C++ builds

4 participants