Replace RF global quantile sort with deterministic sampled quantiles - #8111
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. |
2240c85 to
2527a39
Compare
|
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 (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughSummary by CodeRabbit
WalkthroughExtracts FNV1a hashing to a shared header, implements seeded uniform per-column sampling for quantile computation (new kernel and API), updates RandomForest to pass oversampling and seed, and adjusts/extends tests to validate sampling behavior and determinism. ChangesSampled quantile computation and utilities
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
…quantile-sampling # Conflicts: # cpp/src/decisiontree/batched-levelalgo/quantiles.cuh
There was a problem hiding this comment.
🧹 Nitpick comments (1)
cpp/src/decisiontree/batched-levelalgo/quantiles.cuh (1)
91-108: ⚡ Quick winAdd null pointer validation for
dataparameter.The function validates
max_n_bins,n_rows,n_cols, andoversampling_factorbut does not check ifdatais null. Dereferencing a null pointer in the sampling kernel or cudaMemcpyAsync would cause undefined behavior.🛡️ Proposed fix
{ raft::common::nvtx::push_range("computeQuantiles"); + RAFT_EXPECTS(data != nullptr, "data pointer must not be null"); RAFT_EXPECTS(max_n_bins > 0, "max_n_bins must be positive"); RAFT_EXPECTS(n_rows > 0, "n_rows must be positive");As per coding guidelines: "Implement proper input validation for negative dimensions and null pointers".
🤖 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/quantiles.cuh` around lines 91 - 108, computeQuantiles currently validates sizes but not the input pointer; add a null-pointer check for the data parameter at the top of computeQuantiles (before any use of data, sampling kernels or cudaMemcpyAsync) and fail fast using the same RAFT_EXPECTS style used for other inputs (e.g., RAFT_EXPECTS(data != nullptr, "data pointer must not be null")). This ensures any dereference of data in functions like computeQuantiles or downstream sampling logic is protected.
🤖 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.
Nitpick comments:
In `@cpp/src/decisiontree/batched-levelalgo/quantiles.cuh`:
- Around line 91-108: computeQuantiles currently validates sizes but not the
input pointer; add a null-pointer check for the data parameter at the top of
computeQuantiles (before any use of data, sampling kernels or cudaMemcpyAsync)
and fail fast using the same RAFT_EXPECTS style used for other inputs (e.g.,
RAFT_EXPECTS(data != nullptr, "data pointer must not be null")). This ensures
any dereference of data in functions like computeQuantiles or downstream
sampling logic is protected.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: d83acae8-cdaf-4e79-930e-1d79f3b880ae
📒 Files selected for processing (2)
cpp/src/decisiontree/batched-levelalgo/quantiles.cuhcpp/tests/sg/rf_test.cu
dantegd
left a comment
There was a problem hiding this comment.
Very nice PR, just had a few (very) minor questions and suggestions.
|
@dantegd thanks can you merge? |
|
/merge |
|
/merge |
## Summary Builds on #8111 by making RF quantile sampling produce a shared global sample in distributed runs. This updates computeQuantiles to detect distributed RAFT comms, compute global row counts, split the target sample count proportionally across ranks, and all-reduce the sampled values before sorting. That keeps all ranks using the same quantile cut points while preserving the existing single-GPU path. In the subsampled path, all columns now share the same sampled rows; exact mode (sample_count == n_rows) is unchanged. ## Changes - Compute distributed RF quantile sample counts from global row counts. - Gather per-rank sampled values into a shared global sample before quantile generation. - Add an MG RF quantile test that verifies all ranks produce identical quantiles for float and double with uneven row counts. ## Testing - git diff --check upstream/main...HEAD Not run locally: CUDA/MG test target. Authors: - Rory Mitchell (https://github.com/RAMitchell) Approvers: - Dante Gama Dessavre (https://github.com/dantegd) URL: #8190
This PR replaces Random Forest's per-feature full-column quantile sort with deterministic uniform sampled quantiles. This prepares the RF training path for distributed row-global training, where global sorting is not viable.
Refs #7969.
Changes
lower_boundclamping for values outside the quantile range.Distributed Direction
The intended distributed extension is to assign a fixed global sample budget per feature across workers, have each worker fill its assigned sample slots from local rows, then combine those samples so every worker builds identical quantile bins. A later histogram all-reduce can then make workers build identical trees.
Validation
200/200passed.51/51passed.100/100passed.100/100passed.Accuracy
Held-out C++ accuracy experiments comparing baseline exact quantiles vs current sampled quantiles:
1.000000acc1.000000acc1.000000acc1.000000acc0.566670R20.566935R20.567602R20.571527R21.000000acc1.000000acc1.000000acc1.000000acc0.422733R20.422221R20.422830R20.423043R2Accuracy is unchanged for classification and neutral for regression.
Performance
RFClassifier<float>/blobs/02018.6 ms2029.2 msRFClassifier<float>/blobs/12379.8 ms2341.1 msRFClassifier<double>/blobs/02265.9 ms2218.1 msPerformance is broadly neutral.