← Back to Pull requests

fix(low_order_moments): keep online dispersion finite for one-row blocks #3875

Closed
unknown closed this pull request without merging on Oct 13, 2026 14:14 UTC
View on GitHub
unknown unknown commented on Oct 13, 2026 08:36 UTC
Author

Description

Fixes NaN dispersion statistics in online low order moments when a compute() call gets a one-row block (ChipLab report CLAB-2026-922).

With DAAL low_order_moments::Online fed [1, 2, 3] one row at a time, sumSquaresCentered, variance, standardDeviation and variation came out NaN instead of 2, 1, 1 and 0.5, although the finalized sample has three rows. The oneAPI basic_statistics partial_compute / finalize_compute flow returned a NaN variance for the same data, since the CPU backend runs the same DAAL online kernels (defaultDense for dense input, fastCSR for sparse). Blocks of sizes [2, 1] failed too; blocks of two or more rows were correct.

Cause. Every online method turns the current block's sample variance back into its centered sum of squares as variance * (n - 1), where n is the number of rows in the current call. For a one-row block that variance is NaN:

  • defaultDense (low_order_moments_estimates_online.i) divides by n - 1 = 0 while merging its thread-local buffers;

  • singlePassDense, fastCSR and singlePassCSR (low_order_moments_impl.i) get 0 / 0 from the math backend's xSumAndVariance.
  • The NaN then entered the accumulated centered sum of squares, so the whole stream stayed NaN.

    Fix. A single row's centered sum of squares is exactly 0, so both places now use 0 when the block has one row. Blocks of two or more rows are computed as before.

    Tests. basic_statistics online with one-row blocks (dense) and basic_statistics online CSR flow with one-row blocks: a fixed 2 x 2 table fed as two one-row partial_compute calls, checked against the exact centered sum of squares and variance. Both fail without the fix (nan == 2). With a Make build (GCC, MKL), the DAAL defaultDense, singlePassDense, fastCSR and singlePassCSR online methods returned NaN on the reported stream before this change and the variance 1 after it; the reporter's DAAL and oneAPI reproducers both pass. The GPU online path was not 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.

  • 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 provided justification why performance and/or quality metrics have changed or why changes are not expected. (A per-block branch on the row count; no measurable change expected.)
  • </details>

    🤖 Generated with Claude Code

    Diff: 378 lines (+283 / -95) across 4 files Reviewer: Vika-F Review duration: 338m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.43) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.43 · 378 lines diff across 4 files
    0.43
    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.355
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #3875"
    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: 42.9% (MEDIUM) · Higher = larger blast radius
    42.9%
    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: 17.0% · Safe to merge
    17.0%