Repository navigation
Description
Currently, we use 32-bit int for the n_rows parameter of the random forest:
cuml/cpp/include/cuml/ensemble/randomforest.hpp
Lines 145 to 156 in 93418ba
| void fit(const raft::handle_t& user_handle, | |
| RandomForestClassifierF* forest, | |
| float* input, | |
| int n_rows, | |
| int n_cols, | |
| int* labels, | |
| int n_unique_labels, | |
| RF_params rf_params, | |
| rapids_logger::level_enum verbosity = rapids_logger::level_enum::info, | |
| bool* bootstrap_masks = nullptr, | |
| const double* sample_weight = nullptr, | |
| bool input_row_major = false); |
On the other hand, we use 64-bit integers to store row IDs in the internals of random forest implementation:
cuml/cpp/src/randomforest/randomforest.cuh
Lines 65 to 71 in 93418ba
| RowSampler(const raft::handle_t& handle, | |
| const RF_params& rf_params, | |
| std::int64_t n_rows, | |
| std::int64_t n_sampled_rows, | |
| int n_streams, | |
| bool* bootstrap_masks, | |
| const double* sample_weight) |
cuml/cpp/src/randomforest/randomforest.cuh
Line 113 in 93418ba
| rmm::device_uvector<std::int64_t>& sample(int tree_id, int stream_id, cudaStream_t stream) |
cuml/cpp/src/decisiontree/batched-levelalgo/kernels/builder_kernels.cuh
Lines 100 to 108 in 93418ba
| template <typename DataT, typename LabelT, int TPB> | |
| void launchNodeSplitKernel(const Dataset<DataT, LabelT>& dataset, | |
| const NodeWorkItem* work_items, | |
| Split<DataT>* splits, | |
| const WorkloadInfo* workload_info, | |
| size_t n_blocks_dimx, | |
| size_t n_work_items, | |
| std::int64_t* partition_row_ids, | |
| cudaStream_t builder_stream); |
| inline void sample_features(std::int64_t* column_samples, | |
| const NodeWorkItem* work_items, | |
| size_t work_items_size, | |
| std::int64_t treeid, | |
| uint64_t seed, | |
| std::int64_t sample_offset, | |
| std::int64_t n, | |
| std::int64_t k, | |
| cudaStream_t stream) |
cuml/cpp/src/decisiontree/batched-levelalgo/builder.cuh
Lines 318 to 319 in 93418ba
| auto partition_row_ids_bytes = | |
| ML::checked_mul<std::size_t>(sizeof(std::int64_t), dataset.n_sampled_rows); |
TODO: We need to decide whether to use 32-bit or 64-bit integer to store n_rows and row IDs and apply the consistent type everywhere.
If we were to choose 32-bit, we'd allocate smaller memory for row IDs in the builder kernel.
TODO: Add assertion in the Python-C++ boundary to ensure that the Python integer is representable as the integer type used in the C++ implementation.
Activity
shrutiudupa26 commentedon Nov 6, 2026
Hi @chyunsu3 , I would like to take this one, if it is still free.
I am planning to keep the 64-bit row IDs in the Random forest internals, and change public
n_rowsparameter frominttostd::int64_tso the API matches. I am not planning to shrink row IDs to 32-bit (that would fight the current kernels and reintroduce large-n_rowsoverflow from #2459).I'll also add a Python check that the row count fits in that type.
Please assign this to me if it sounds good.
chyunsu3 commentedon Nov 6, 2026
Let's not start the work yet. The team has not decided on this issue.