← Back to Pull requests

[CUB] Migrate two-phase scan-by-key APIs to execution environments #11811

Open
unknown opened this pull request with 367 lines diff across 4 files
View on GitHub
unknown unknown commented on Oct 02, 2026 09:15 UTC
Author

Description

Closes #11709. Part of #9875.

Migrate the explicit-storage overloads of DeviceScan::ExclusiveScanByKey, ExclusiveSumByKey, InclusiveScanByKey, and InclusiveSumByKey to a defaulted const EnvT& parameter.

Each overload uses the existing explicit-storage detail::dispatch_with_env helper to extract the stream and tuning before calling scan_by_key_impl. This allows callers to query and supply temporary storage while using the same stream and tuning environment as the single-phase API. Temporary storage remains caller-owned, and an environment memory resource is not queried or used.

Compatibility

Existing calls with an omitted stream, raw cudaStream_t, nullptr, literal 0, or a const-convertible stream wrapper continue to work. The mutable-lvalue-only and rvalue-only stream conversion corner case is tracked separately in #11824; the additional compatibility overloads were removed as requested in review.

The scan algorithms, dispatch internals, ordinary non-key scans, and single-phase APIs are unchanged. Doxygen parameter and template documentation is updated for all four migrated overloads.

Tests

The environment regression tests exercise every migrated API with:

  • The existing custom-stream matrix, including raw streams, stream objects/references, convertible wrappers, accessors, and composed environments

  • Default environments, nullptr, and literal 0

  • A throwing memory resource to check that explicit-storage calls do not allocate through the environment

  • Custom key grouping, custom multiplication, and a nonzero exclusive initial value

  • Combined stream and tuning environments with 64- and 128-thread policies, checking the block size on device
  • Stream routing is checked through the existing launch registry and explicit synchronization of the requested stream.

    Validation

    Revalidated the review revision with CUDA 13.0.88, GCC 13.3.0, C++20, and sm_75. All eight focused binaries passed on a Tesla T4 with NVIDIA driver 580.82.07: 65 test cases and 14,620 assertions.

  • cub.test.device.scan_by_key_env.lid_{0,1,2}

  • cub.test.device.scan_by_key.lid_{0,1,2}.types_1

  • cub.test.device.scan_by_key_env_api.lid_0

  • thrust.test.cuda.scan_by_key.cdp_0
  • The existing suites cover host, device/CDP, and graph launch modes; the added direct explicit-storage environment cases run in the host-launch target. The changed environment test translation unit also compiles in C++17 with the same CUDA/host compilers and warning-as-error flags. The C++17 check is compile-only.

    All applicable pre-commit hooks and git diff --check pass.

    Full upstream CI, other toolchains/architectures, the full functional type matrix, sanitizer runs, and performance benchmarks have not been run.

    Checklist

  • New or existing tests cover these changes.

  • The documentation is up to date with these changes.
  • Diff: 367 lines (+275 / -92) across 4 files Reviewer: Seanium Review duration: 26869m
    All Vouch review confidence checks passed
    Residual risk 0.35 = Change Risk (0.66) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.66 · 367 lines diff across 4 files
    0.66
    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
    Diff Size diff_size
    0.353
    Shallow Review Depth shallow_review_depth
    0.344
    Sensitive Paths sensitive_paths
    0.066
    Real PR Conversation Timeline
    1 comments
    "Review active on #11811"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: medium confidence: 46.7% reviewed sensitive_module
    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: 65.9% (HIGH) · Higher = larger blast radius
    65.9%
    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: 35.1% · Moderate risk
    35.1%
    Repository