Skip to content

test(cuda.core): query green stream contexts with v2 - #3448

Merged
Andy-Jost merged 4 commits into
NVIDIA:mainfrom
rluo8:fix/green-stream-context-query
Nov 17, 2026
Merged

Andy-Jost merged 4 commits into
NVIDIA:mainfrom
rluo8:fix/green-stream-context-query

Conversation

@rluo8

@rluo8 rluo8 commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Description

This is to fix internal bug 7080277 which is a test helper issue.

On CUDA 12.9, test_device_receiver_targets_stored_green_context fails because the shared helper calls cuStreamGetCtx on a stream created by cuGreenCtxStreamCreate.

The CUDA 12.9 documentation states that this query returns CUDA_ERROR_NOT_SUPPORTED and recommends cuStreamGetCtx_v2. CUDA 13.0 supports these streams with the legacy query, but the helper should also work on CUDA 12.9.

Use cuStreamGetCtx_v2 for green contexts, require a non-null pGreenCtx, and convert it with cuCtxFromGreenCtx before comparing it with the bound context handle. The returned pCtx is the device primary context. Keep the legacy query for regular contexts to preserve compatibility with older drivers.

Validation

Reran all three tests using this helper:

  • Windows, Tesla T4, CUDA 12.9, cuda-core 1.3.0, cuda-bindings 12.9.8: 3 passed on each of Python 3.11, 3.12, 3.13, 3.14, and free-threaded 3.14.
  • Windows, CUDA 13.4 driver and development wheels, Python 3.14: 2 passed, 1 skipped (requires two GPUs).

Signed-off-by: Rui Luo <ruluo@nvidia.com>
@github-actions github-actions Bot added the cuda.core Everything related to the cuda.core module label Nov 12, 2026
@rluo8 rluo8 self-assigned this Nov 12, 2026
@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 8c8facf and 40288d5.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Tests
    • Improved validation that streams created with green contexts belong to the device’s bound context.

The test helper now uses cuStreamGetCtx_v2 and cuCtxFromGreenCtx to check green-context streams against the device’s bound context. Regular-context streams continue to use cuStreamGetCtx.

Changes: Green-context validation

Layer / File(s) Summary
Stream context check
cuda_core/tests/helpers/contexts.py
For green-context streams, the helper checks the returned handle and converts it to a CUDA context before comparison. Regular-context streams continue to use cuStreamGetCtx. The mismatch assertion no longer names a specific API.

Possibly related issues

  • NVIDIA/cuda-python#2366 — This change covers the issue’s context-query audit for green-context streams by using cuStreamGetCtx_v2.

Suggested labels: test, cuda.core

Suggested reviewers: andy-jost

Change: Other

Merge Risk: Minimal · previous review 94452

This updates a test helper so the green-context test works on CUDA 12.9. It does not change product behavior. No concrete merge-blocking risk was found. The PR metadata check should be satisfied before merging.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 303fbda and 94452c7.

Files selected for processing: 1

  • cuda_core/tests/helpers/contexts.py

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.

@github-actions

Copy link
Copy Markdown
Contributor

@rluo8
rluo8 requested a review from Andy-Jost November 13, 2026 09:14

@Andy-Jost Andy-Jost left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. The helper is right on both driver lines. cuStreamGetCtx_v2 returns the green context in pGreenCtx, and cuCtxFromGreenCtx is the same conversion cuda.core uses to build Context.handle, so the comparison is exact. Regular contexts keep the legacy query, so nothing changes for them. The check is also stronger than before, because it now requires a green context.

@Andy-Jost Andy-Jost added the test Improvements or additions to tests label Nov 16, 2026
@Andy-Jost Andy-Jost added this to the cuda.core 1.3.1 milestone Nov 16, 2026
@Andy-Jost Andy-Jost added the to-be-backported Trigger the bot to raise a backport PR upon merge label Nov 16, 2026
@Andy-Jost
Andy-Jost enabled auto-merge (squash) November 17, 2026 00:16
@Andy-Jost
Andy-Jost merged commit 7076a67 into NVIDIA:main Nov 17, 2026
221 of 224 checks passed
Andy-Jost pushed a commit to Andy-Jost/cuda-python that referenced this pull request Nov 17, 2026
Signed-off-by: Rui Luo <ruluo@nvidia.com>
(cherry picked from commit 7076a67)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cuda.core Everything related to the cuda.core module test Improvements or additions to tests to-be-backported Trigger the bot to raise a backport PR upon merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants