fix(linear_regression): keep the partial result unchanged in the GPU ridge finalize #4010
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 · 392 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.357
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #4010"
general
weight: 0.35
david-cortes-intel
Description
finalize_train/finalize_computemust leave the partial result as it was: the same partial can be finalized again, or extended with morepartial_train/partial_computecalls and finalized later (scikit-learn-intelex does this whenever a fitted attribute is read between twopartial_fitcalls, and when an estimator is pickled). Two GPU kernels wrote into the partial result's device buffers instead, becausetable2ndarraywraps a device table without copying.Ridge regression (GPU, single process), wrong results.
add_ridge_penaltyadds alpha to the diagonal ofxtxin place, and outside the SPMD branchxtxwas the partial result's own buffer. Every finalize of the same partial therefore added alpha again: the second finalize solved with 2 * alpha, andpartial_trainafter a finalize carried the extra penalty into the next result. Through scikit-learn-intelex,IncrementalRidge(alpha=a)on GPU fitted asalpha=2aafterpartial_fit, readingcoef_, andpartial_fitagain. The penalty is now added to a copy ofxtx; the SPMD branch already copied before itsallreduce.The other finalize kernels (linear regression without a penalty, PCA, covariance on CPU and GPU, basic statistics on CPU, ridge on CPU) already copy or only read the partial result.
The GPU basic statistics finalize had the same pattern (it wrote into the partial's
sum_squares_centered); that part moved to #4014, where the merge formula it depends on is being fixed.Tests
RR finalize twice on the same partial result(linear_regression/test/online.cpp): finalizes the same ridge partial twice and requires identical coefficients and intercept. On GPU it fails without the fix (5.2410vs5.2562on the first coefficient).Run locally on an Intel GPU and CPU, all passing with the fix:
bazel test --config=dpc --device=gpuforlinear_regression:test_online_dpc,test_batch_dpc,test_online_spmd_dpc.bazel test --config=hostforlinear_regression:test_online_host.---
<details>
<summary>Checklist:</summary>
Completeness and readability
Testing
Performance
</details>
🤖 Generated with Claude Code