fix(low_order_moments): keep online dispersion finite for one-row blocks #3875
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
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.355
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #3875"
general
weight: 0.35
Vika-F
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::Onlinefed[1, 2, 3]one row at a time,sumSquaresCentered,variance,standardDeviationandvariationcame out NaN instead of 2, 1, 1 and 0.5, although the finalized sample has three rows. The oneAPIbasic_statisticspartial_compute/finalize_computeflow returned a NaN variance for the same data, since the CPU backend runs the same DAAL online kernels (defaultDensefor dense input,fastCSRfor 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), wherenis 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 byn - 1 = 0while merging its thread-local buffers;singlePassDense,fastCSRandsinglePassCSR(low_order_moments_impl.i) get0 / 0from the math backend'sxSumAndVariance.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) andbasic_statistics online CSR flow with one-row blocks: a fixed 2 x 2 table fed as two one-rowpartial_computecalls, checked against the exact centered sum of squares and variance. Both fail without the fix (nan == 2). With a Make build (GCC, MKL), the DAALdefaultDense,singlePassDense,fastCSRandsinglePassCSRonline 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
Testing
Performance
</details>
🤖 Generated with Claude Code