← Back to Pull requests

feat: sparse support for online oneDAL BasicStatistics #3723

Closed
unknown closed this pull request without merging on Sep 24, 2026 17:47 UTC
View on GitHub
unknown unknown commented on Jul 29, 2026 13:18 UTC
Author

Summary

Enables partial_compute + finalize_compute on csr_table inputs for the
basic_statistics algorithm on both CPU and GPU. Previously only method::dense
was wired through the online path; method::sparse was batch-only, so sklearnex
IncrementalBasicStatistics fell back to the dense path on sparse inputs.

The partial-result schema is unchanged (same six fields as dense: partial_n_rows,
partial_min, partial_max, partial_sum, partial_sum_squares,
partial_sum_squares_centered). For CSR:

  • sum / sum_squares over the stored NNZ values equal the same reductions over

  • the implicit densified matrix (missing entries are zeros).
  • sum_squares_centered is recovered exactly at finalize time via

  • sum2cent = sum_squares - sum^2 / n, so the intermediate carries no sparsity
    information and the dense finalize math is reused as-is.
  • min / max already clamp against implicit zeros in the existing CSR batch

  • kernel, so the per-batch partial values are already correct against a dense
    view.

    Changes

    CPU (routes through the existing DAAL fastCSR online kernel)

  • cpp/oneapi/dal/algo/basic_statistics/backend/cpu/partial_compute_kernel_csr.cpp — new.

  • Dispatches to daal_lom::internal::LowOrderMomentsOnlineKernel<Float, fastCSR, Cpu>
    with is_online = true; carries the previous partial state in when present.
    Rejects per-row weights (unimplemented) because the DAAL fastCSR online
    signature has no weighted overload.
  • cpp/oneapi/dal/algo/basic_statistics/backend/cpu/finalize_compute_kernel_csr.cpp — new.

  • Same DAAL finalize call as the dense CPU path but reading the CSR partials.
  • cpp/daal/src/algorithms/low_order_moments/low_order_moments_csr_fast_online_fpt_cpu.cpp —

  • added DAAL_EXPORT on the explicit LowOrderMomentsOnlineKernel<..., fastCSR, ...>
    instantiation so the symbol is visible to libonedal.so (matches the pattern
    in other *_fpt_cpu.cpp files whose kernels are called from oneAPI backends).

    GPU (reuses the dense GPU compute + finalize)

  • cpp/oneapi/dal/algo/basic_statistics/backend/gpu/partial_compute_kernel_csr_dpc.cpp — new.

  • Runs the existing GPU CSR batch kernel per partial then merges into the accumulated
    partial (elementwise min / max / sum); builds a trimmed per-batch descriptor
    that only asks for min / max / sum / sum_squares so higher-order results are
    derived once at finalize time.
  • cpp/oneapi/dal/algo/basic_statistics/backend/gpu/finalize_compute_kernel_csr_dpc.cpp — new.

  • One-line delegation to finalize_compute_kernel_dense_impl (same six-field
    layout ⇒ identical finalize math).

    Dispatch

  • detail/{partial,finalize}_compute_ops{,_dpc}.cpp — added

  • INSTANTIATE(float/double, method::sparse, task::compute) next to the existing
    dense instantiations.

    ---

    <!--
    PR should start as a draft, then move to ready for review state
    after CI is passed and all applicable checkboxes are closed.
    This approach ensures that reviewers don't spend extra time asking for regular requirements.

    You can remove a checkbox as not applicable only if it doesn't relate to this PR in any way.
    For example, a PR with docs update doesn't require checkboxes for performance
    while a PR with any change in actual code should list checkboxes and
    justify how this code change is expected to affect performance (or justification should be self-evident).
    -->

    <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.

  • 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.

  • 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.
  • </details>

    Diff: 608 lines (+456 / -152) across 7 files Reviewer: avolkov-intel Review duration: 82349m
    All Vouch review confidence checks passed
    Residual risk 0.20 = Change Risk (0.50) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 608 lines diff across 7 files
    0.50
    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.384
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #3723"
    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: 50.1% (MEDIUM) · Higher = larger blast radius
    50.1%
    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: 19.8% · Safe to merge
    19.8%