← Back to Pull requests

fix(linear_regression): keep the partial result unchanged in the GPU ridge finalize #4010

Closed
unknown closed this pull request without merging on Nov 17, 2026 14:54 UTC
View on GitHub
unknown unknown commented on Nov 09, 2026 17:16 UTC
Author

Description

finalize_train / finalize_compute must leave the partial result as it was: the same partial can be finalized again, or extended with more partial_train / partial_compute calls and finalized later (scikit-learn-intelex does this whenever a fitted attribute is read between two partial_fit calls, and when an estimator is pickled). Two GPU kernels wrote into the partial result's device buffers instead, because table2ndarray wraps a device table without copying.

Ridge regression (GPU, single process), wrong results. add_ridge_penalty adds alpha to the diagonal of xtx in place, and outside the SPMD branch xtx was the partial result's own buffer. Every finalize of the same partial therefore added alpha again: the second finalize solved with 2 * alpha, and partial_train after a finalize carried the extra penalty into the next result. Through scikit-learn-intelex, IncrementalRidge(alpha=a) on GPU fitted as alpha=2a after partial_fit, reading coef_, and partial_fit again. The penalty is now added to a copy of xtx; the SPMD branch already copied before its allreduce.

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.2410 vs 5.2562 on the first coefficient).
  • Run locally on an Intel GPU and CPU, all passing with the fix:

  • bazel test --config=dpc --device=gpu for linear_regression:test_online_dpc, test_batch_dpc, test_online_spmd_dpc.

  • bazel test --config=host for linear_regression:test_online_host.
  • ---

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

  • 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: see Tests above.

  • 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: two regression tests added.
  • Performance

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

    🤖 Generated with Claude Code

    Diff: 392 lines (+294 / -98) across 4 files Reviewer: david-cortes-intel Review duration: 11378m
    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
    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.357
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #4010"
    general weight: 0.35
    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: 43.1% (MEDIUM) · Higher = larger blast radius
    43.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: 17% · Safe to merge
    17%