perf(df): convert decision forest responses to the training float type once per fit #3872
All Vouch review confidence checks passed
Residual risk 0.19 = Change Risk (0.48) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.48 · 517 lines diff across 6 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.374
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #3872"
general
weight: 0.35
Vika-F
Description
When the response table's type differs from the training float type (for example float32 X with float64 y, the common sklearnex case, see uxlfoundation/scikit-learn-intelex#3461), CPU decision forest training converted y over and over.
DataHelper::init(dtrees_train_data_helper.i) reads each tree's responses throughReadRowsover the[first, last]sampled row range, which spans almost the whole column, and each out-of-bag row was read again through its ownReadRows. With smallmax_samplesand many trees, these conversions dominated tree building.The classification and regression kernels now convert such a response table to
algorithmFPTypeonce per fit, next to the existingnormalizeWeightscall, so the per-tree and per-OOB-row reads are zero-copy. Tables that already have the training type are not copied. Weights already go throughnormalizeWeights, which returns analgorithmFPTypetable. The GPU backend already converts responses once per fit and is not affected.New helper:
convertResponsesindf_train_dense_default_impl.i, next tonormalizeWeights: oneReadRowsover the column and a serial copy into aHomogenNumericTableCPU. The existingdata_management::convertToHomogenis not reused because it drops the allocation and read status and is not CPU-dispatched.scikit-learn_bench through sklearnex on CPU (2M x 20 regression, 100 trees, float32 X with float64 y): RandomForestRegressor 1.09x faster at
max_samples=0.01and 1.04x at 0.1, and 1.43x / 1.31x withoob_score=True; ExtraTreesRegressor the same as RandomForest. Matching dtypes and classification are unchanged, and predictions are identical. Full table in the PR comments.Tests: no oneDAL test is added. The change is not observable from the oneAPI side: a host float32/float64/int32 response table is wrapped zero-copy (
host_homogen_table_adapter), so the repeated conversions happen inside DAAL'sHomogenNumericTable::getBlockOfRows, and every other table kind is already converted once inconvert_to_daal_table. Results are unchanged; correctness is covered by the existing DF tests and the sklearnex forest tests, and the speedup by scikit-learn_bench results.In sklearnex,
onedal/ensemble/forest.pypasses y in its own dtype withfptype = X.dtype, so regression with float32 X and float64 y takes this path. Classification labels arrive as int64 indices, which the interop layer already converts once, so sklearnex classification is unaffected. oneAPI and DAAL callers that pass float64 or int32 labels with float32 training are affected.No public API or ABI changes.
---
<details>
<summary>Checklist:</summary>
Completeness and readability
Testing
Performance
</details>
🤖 Generated with Claude Code