← Back to Pull requests

perf(df): convert decision forest responses to the training float type once per fit #3872

Closed
unknown closed this pull request without merging on Oct 19, 2026 15:14 UTC
View on GitHub
unknown unknown commented on Oct 12, 2026 09:00 UTC
Author

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 through ReadRows over the [first, last] sampled row range, which spans almost the whole column, and each out-of-bag row was read again through its own ReadRows. With small max_samples and many trees, these conversions dominated tree building.

The classification and regression kernels now convert such a response table to algorithmFPType once per fit, next to the existing normalizeWeights call, 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 through normalizeWeights, which returns an algorithmFPType table. The GPU backend already converts responses once per fit and is not affected.

New helper: convertResponses in df_train_dense_default_impl.i, next to normalizeWeights: one ReadRows over the column and a serial copy into a HomogenNumericTableCPU. The existing data_management::convertToHomogen is 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.01 and 1.04x at 0.1, and 1.43x / 1.31x with oob_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's HomogenNumericTable::getBlockOfRows, and every other table kind is already converted once in convert_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.py passes y in its own dtype with fptype = 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

  • I have commented my code, particularly in hard-to-understand areas.

  • I have updated the documentation to reflect the changes or created a separate PR with updates and provided its number in the description, if necessary. (not applicable)

  • Git commit message contains an appropriate signed-off-by string _(see CONTRIBUTING.md for details)_.

  • I have resolved any merge conflicts that might occur with the base branch.
  • Testing

  • I have run it locally and tested the changes extensively.

  • All CI jobs are green or I have provided justification why they aren't.

  • I have extended testing suite if new functionality was introduced in this PR.
  • Performance

  • I have measured performance for affected algorithms using scikit-learn_bench and provided at least a summary table with measured data, if performance change is expected. (summary table in the PR comments)

  • I have provided justification why performance and/or quality metrics have changed or why changes are not expected.

  • I have extended the benchmarking suite and provided a corresponding scikit-learn_bench PR if new measurable functionality was introduced in this PR. (not applicable)
  • </details>

    🤖 Generated with Claude Code

    Diff: 517 lines (+387 / -130) across 6 files Reviewer: Vika-F Review duration: 10453m
    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
    0.48
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 47.7% (MEDIUM) · Higher = larger blast radius
    47.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 18.9% · Safe to merge
    18.9%