Prepare RF split counts for distributed training - #8348
Conversation
|
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. |
There was a problem hiding this comment.
Pull request overview
This PR prepares the batched-level decision tree/random forest split representation for future distributed tree building by splitting the left-child sample count into separate global vs rank-local fields, while preserving current single-rank behavior.
Changes:
- Replaced
nLeftwithglobal_nLeftandlocal_nLeftinDT::Split, updating merge/reduction logic accordingly. - Updated objective and builder/kernel call sites to compute/propagate 64-bit counts and to pass
(nLeft, nLeft)explicitly for the single-rank path. - Simplified tests and host-side handling by using
DT::Splitdirectly instead of a host mirror struct.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| cpp/tests/sg/rf_test.cu | Updates split assertions to validate both global_nLeft and local_nLeft and removes the test-only host mirror. |
| cpp/src/decisiontree/batched-levelalgo/split.cuh | Extends Split with global/local left counts and updates reduction/printing paths. |
| cpp/src/decisiontree/batched-levelalgo/objectives.cuh | Switches split-count plumbing to std::int64_t and updates split construction to supply both counts explicitly. |
| cpp/src/decisiontree/batched-levelalgo/kernels/builder_kernels.cuh | Updates split partition validation to use local_nLeft with 64-bit-safe comparisons. |
| cpp/src/decisiontree/batched-levelalgo/kernels/builder_kernels_impl.cuh | Updates partition scan state/counting to use 64-bit counts and indexes using local_nLeft. |
| cpp/src/decisiontree/batched-levelalgo/builder.cuh | Uses global_nLeft for tree metadata counts and local_nLeft for instance-range partitioning; removes host mirror in split retry flow. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThis PR replaces ChangesDecision tree split accounting int64 refactor
Estimated code review effort: 4 (Complex) | ~60 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
cpp/src/decisiontree/batched-levelalgo/builder.cuh (1)
111-126: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winAvoid truncating
global_nLefttoIdxThere
CreateLeafNode()takesIdxT(intin this instantiation), butsplit.global_nLeftisstd::int64_t. The leaf counts at lines 111 and 123 narrow here; if they exceedint, the tree stores the wrong sample count. Widen the node count type or wrap the call withML::narrow_cast<IdxT>(...).🤖 Prompt for 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. In `@cpp/src/decisiontree/batched-levelalgo/builder.cuh` around lines 111 - 126, The leaf-count creation in builder.cuh is narrowing split.global_nLeft into NodeT::CreateLeafNode, which can truncate counts when IdxT is smaller than std::int64_t. Update the affected CreateLeafNode calls in the builder logic to use a safe conversion such as ML::narrow_cast<IdxT> or widen the node count type used by NodeT so the stored leaf sample counts remain correct. Use the CreateLeafNode and split.global_nLeft call sites in the batched-levelalgo builder to locate both conversions.Source: Path instructions
🤖 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.
Outside diff comments:
In `@cpp/src/decisiontree/batched-levelalgo/builder.cuh`:
- Around line 111-126: The leaf-count creation in builder.cuh is narrowing
split.global_nLeft into NodeT::CreateLeafNode, which can truncate counts when
IdxT is smaller than std::int64_t. Update the affected CreateLeafNode calls in
the builder logic to use a safe conversion such as ML::narrow_cast<IdxT> or
widen the node count type used by NodeT so the stored leaf sample counts remain
correct. Use the CreateLeafNode and split.global_nLeft call sites in the
batched-levelalgo builder to locate both conversions.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: dabb035f-d74e-4211-9ae2-aea17e6ab9c9
📒 Files selected for processing (6)
cpp/src/decisiontree/batched-levelalgo/builder.cuhcpp/src/decisiontree/batched-levelalgo/kernels/builder_kernels.cuhcpp/src/decisiontree/batched-levelalgo/kernels/builder_kernels_impl.cuhcpp/src/decisiontree/batched-levelalgo/objectives.cuhcpp/src/decisiontree/batched-levelalgo/split.cuhcpp/tests/sg/rf_test.cu
chyunsu3
left a comment
There was a problem hiding this comment.
LGTM. Global/local counts are nice abstractions, and I appreciate that we now have a single split type for both host and device. (No more HostSplit)
|
Caution Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted. Error details |
|
/merge |
Description
This PR prepares the random forest split representation for distributed tree building by separating the left-child sample count into two explicit fields:
global_nLeft: total number of samples assigned to the left childlocal_nLeft: rank-local number of samples assigned to the left childFor the current single-GPU/single-rank path, these values are intentionally the same. The objective call sites pass
nLeft, nLeftexplicitly so that staging assumption is visible in the code instead of hidden behind a convenience constructor.This also removes the duplicate host-side
HostSplitmirror used by tests. To make the realDT::Splittype usable in host-side test code, its plain value-type constructors and copy assignment are nowHDI; CUDA-specific methods remain device-only.Motivation
Distributed random forest training needs to distinguish the global split count used for tree metadata from the local split count used for partitioning this rank’s rows. This PR introduces that distinction without changing current single-rank behavior.
Testing
SG_RF_TESTRFEquivalentSplitRangeTest.*RfTest.EquivalentSplitRangePersistsThroughBuilderSG_RF_TEST:289/289passed