From 94452c7314e32436812aa64141f8fa805f96992b Mon Sep 17 00:00:00 2001 From: Rui Luo Date: Thu, 12 Nov 2026 16:20:40 +0800 Subject: [PATCH] test(cuda.core): query green stream contexts with v2 Signed-off-by: Rui Luo --- cuda_core/tests/helpers/contexts.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cuda_core/tests/helpers/contexts.py b/cuda_core/tests/helpers/contexts.py index f613f0ac336..d1e73de926a 100644 --- a/cuda_core/tests/helpers/contexts.py +++ b/cuda_core/tests/helpers/contexts.py @@ -71,9 +71,17 @@ def assert_device_operations_use_bound_context(device): # Live check: query the driver directly, rather than comparing cached # metadata, to confirm the stream was actually created in the bound # context rather than whatever was ambient. - driver_stream_ctx = handle_return(driver.cuStreamGetCtx(stream.handle)) + if bound_context.is_green: + # The legacy query rejects green streams on CUDA 12.9. In v2, + # pCtx is the primary context; pGreenCtx identifies the green context. + _, driver_green_ctx = handle_return(driver.cuStreamGetCtx_v2(stream.handle)) + assert int(driver_green_ctx) != 0, "The stream must be associated with a green context." + driver_stream_ctx = handle_return(driver.cuCtxFromGreenCtx(driver_green_ctx)) + else: + # Keep the legacy query for regular contexts on older drivers. + driver_stream_ctx = handle_return(driver.cuStreamGetCtx(stream.handle)) assert int(driver_stream_ctx) == int(bound_context.handle), ( - "cuStreamGetCtx reports a context other than the one the stream was created in." + "The driver reports a context other than the one the stream was created in." ) event = device.create_event()