← Back to Pull requests

[libcu++] cuda_error: carry the exact status, its domain, and the source location #11825

Open
unknown opened this pull request with 283 lines diff across 3 files
View on GitHub
unknown unknown commented on Oct 02, 2026 20:47 UTC
Author

Description

cuda::cuda_error stores one cudaError_t. Driver failures are cast to it before being thrown, and statuses from other CUDA libraries (cuBLAS, cuFFT, ...) have no home at all, which is why cudax/stf keeps its own cuda_exception type. This PR makes cuda_error able to carry any CUDA-family status exactly, so that one exception type can serve all of CCCL.

What changes

  • The exception stores the failing status object as given (any enumeration, or a trivially copyable struct of up to sixteen bytes), its code, and the source location of the failure.

  • New constructor template from any status, and new accessors holds<S>(), status<S>(), raw_code() (a cuda::std::int64_t), status_type_name() and location().

  • The per-status rules (code, success test, error text) are internal for now (__cuda_status_traits / __cuda_status_defaults), not a customization point. libcu++ supplies text for cudaError_t and CUresult.

  • A driver-call failure keeps its CUresult, so a caught error can tell driver from runtime: __throw_if_failed (from #11933) throws the CUresult, and cuda_error has a constructor from the no-throw APIs' __driver_status that does the same.

  • The CUDA Runtime family has one identity whether or not a translation unit saw the toolkit: holds<cudaError_t>() and holds<int>() agree, and both are named "cudaError_t". A CUresult is named "CUresult".
  • Backward compatibility

  • cuda_error(cudaError_t, msg, api, loc) and status() keep their signatures and meaning.

  • status() on a driver status returns the same numeric conversion the wrappers always produced; on another library's status it returns cudaErrorUnknown. status<S>() gives the exact value.

  • The what() format changes from file:line api text(code): msg to file:line api status_type(code): text: msg, so the status type is part of every message. Code that parses what() needs to follow.
  • Tests: libcudacxx/test/libcudacxx/cuda/ccclrt/utility/cuda_error.c2h.cu covers runtime, driver and other-library statuses, a struct status, the historical interface, and catching through the base class. Docs: docs/libcudacxx/extended_api/exceptions.rst.

    🤖 Generated with Claude Code

    Diff: 283 lines (+212 / -71) across 3 files Reviewer: andralex Review duration: 32748m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.40) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 283 lines diff across 3 files
    0.40
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    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
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.338
    Real PR Conversation Timeline
    1 comments
    "Review active on #11825"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% 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: 39.7% (MEDIUM) · Higher = larger blast radius
    39.7%
    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: 46.7% · Lower = rushed or shallow review
    46.7%
    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: 21.2% · Safe to merge
    21.2%
    Repository