← Back to Pull requests

fix(spblas): return the MKL sparse status from the DAAL wrappers #4054

Closed
unknown closed this pull request without merging on Nov 23, 2026 13:25 UTC
View on GitHub
unknown unknown commented on Nov 23, 2026 07:59 UTC
Author

Description

The DAAL sparse BLAS wrappers (cpp/daal/src/externals/service_spblas_mkl.h) ignored every sparse_status_t. When mkl_sparse_?_create_csr, mkl_sparse_?_mm, _mv or _spmmd failed, for example on an allocation failure, the output buffer was left unset and the algorithm returned it as a valid result.

No associated issue. No documentation or benchmark PR is needed.

Change

  • xxcsrmm, xcsrmv and xcsrmultd return a services::Status and are marked [[nodiscard]], so a caller that drops the status fails the -Werror builds:

  • - SPARSE_STATUS_ALLOC_FAILED maps to ErrorMemoryAllocationFailed;
    - any other failure maps to ErrorIncorrectInternalFunctionParameter.

    No new error ids. Handles are released on every path, and an earlier failure is kept over the release status.

  • The reference backend returns success, as before. The SpBlas facade forwards the status.

  • The call sites pass the status on:

  • - k-means Lloyd training (kmeans_lloyd_impl.i) and the final CSR assignment (kmeans_lloyd_postprocessing.h), through SafeStatus inside the threaded loops. The per-thread buffers of the final assignment are released before the status is checked;
    - the k-means batch kernel (kmeans_lloyd_batch_impl.i) checks the final assignment and the exact objective, and returns a failed training iteration instead of running the postprocessing on unwritten centroids;
    - k-means|| init (kmeans_plusplus_init_impl.i, callGemm);
    - covariance CSR (updateCSRCrossProductAndSums in covariance_impl.i).
  • The unused xcsrmm wrapper is removed from all three headers.
  • Test. New private suite //cpp/oneapi/dal/algo/kmeans:internal_tests (test/internal_spblas.cpp) calls the wrappers directly:

  • A valid 2 x 2 CSR product returns success and the right values.

  • A matrix with a negative row count makes MKL return SPARSE_STATUS_INVALID_VALUE, and all three wrappers report the failure.

  • - It is skipped on the reference backend, which does not validate its arguments.
    - Without the change it does not compile, because the wrappers return void.

    There is no deterministic way to make MKL fail an allocation inside an algorithm, so the end-to-end path is covered only by the existing algorithm tests, which still pass.

    Checks:

  • bazel test --config=host for kmeans (including internal_tests), kmeans_init and covariance pass.

  • //:release builds with GCC.

  • The reference-backend wrappers were not built locally: OpenBLAS is not available on the development machine, so the OpenBLAS CI jobs cover that build.
  • No public API or ABI changes.

    ---

    <details>
    <summary>Checklist:</summary>

    Completeness and readability

  • I have commented my code, particularly in hard-to-understand areas.

  • Documentation: not applicable, internal headers only.

  • 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

  • scikit-learn_bench: not applicable, no performance change is expected.

  • I have provided justification why performance and/or quality metrics have changed or why changes are not expected: the change adds one status comparison per MKL call and only changes the failure paths; the successful paths run the same MKL calls in the same order.

  • Benchmarking suite: not applicable, no new functionality.
  • </details>

    🤖 Generated with Claude Code

    Diff: 481 lines (+360 / -121) across 6 files Reviewer: icfaust Review duration: 326m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.47) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.47 · 481 lines diff across 6 files
    0.47
    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.370
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #4054"
    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: 47.3% (MEDIUM) · Higher = larger blast radius
    47.3%
    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: 18.7% · Safe to merge
    18.7%