You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Implement green context v1 API
* Refine green context split compatibility
* Encode green context handle dependencies
* Simplify green context view handles
* Simplify green context descriptor handling
* Expand green context test coverage with proper pytest patterns
Restructure tests into fixtures + classes with full resource cleanup:
- Fixtures: sm_resource, wq_resource, green_ctx (with CUDAError skip),
green_ctx_active (with try/finally restore), fill_kernel
- _use_green_ctx context manager for safe push/pop in all tests
- TestSMResourceQuery: properties, arch constraints per CC
- TestSMResourceSplit: single/two-group splits, discovery, alignment,
dry-run vs real parity
- TestGreenContextKernelLaunch: compile + launch + verify in green ctx,
two independent green contexts, SM + workqueue combined
All set_current calls are paired with restore in finally blocks to
prevent context stack leaks on test failure.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Lower green context handling to Cython and simplify Context
- Convert ContextOptions and SMResourceOptions/WorkqueueResourceOptions
to cdef dataclasses for check_or_create_options compatibility.
- Cache SM metadata in typed cdef fields; fall back to arch-based
granularity on CUDA 12.x where CUdevSmResource lacks
minSmPartitionSize/smCoscheduledAlignment.
- Simplify Context to hold only ContextHandle (remove _h_green_ctx
and _is_green fields). Green ctx association lives in ContextBox;
is_green queries get_context_green_ctx() on demand.
- ContextOptions.resources accepts Sequence only (no bare resource).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Add explicit green context model: ctx.create_stream and ctx.resources
Switch from the push model (dev.set_current + dev.create_stream) to the
explicit model (ctx.create_stream + ctx.resources) as the primary way
to use green contexts.
Context.create_stream(options):
- Only supported on green contexts (raises on primary contexts).
- Delegates to Stream._init, which calls create_stream_handle in C++.
- C++ create_stream_handle auto-dispatches: checks get_context_green_ctx
and calls cuGreenCtxStreamCreate for green contexts, or
cuStreamCreateWithPriority for primary. Single function, no duplication.
Context.resources:
- Returns a DeviceResources namespace querying this context's resources
(cuCtxGetDevResource / cuGreenCtxGetDevResource), not the full device.
dev.set_current(green_ctx) still works but is not the recommended path.
Tests rewritten to use the explicit model throughout. Push-model
set_current kept as regression tests with _use_green_ctx helper.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Harden green context stream creation and resource queries
- Let the driver validate the nonblocking flag for green context streams:
cuGreenCtxStreamCreate rejects CU_STREAM_DEFAULT. On failure, check if
the context is green + nonblocking is False and raise a clear ValueError.
- cuCtxGetStreamPriorityRange failure (CUDA_ERROR_INVALID_CONTEXT) now
raises: "No current CUDA context. Call dev.set_current() before
creating streams."
- C++ create_stream_handle returns CUDA_ERROR_NOT_SUPPORTED if the
context is green but cuGreenCtxStreamCreate is unavailable (CUDA < 12.5),
instead of falling through to cuStreamCreateWithPriority.
- ctx.resources.workqueue now dispatches to cuGreenCtxGetDevResource for
green contexts, matching the SM query path.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Add Stream.resources property
Stream.resources delegates to DeviceResources._init_from_ctx via the
stream's tracked context handle, returning the same resource view as
ctx.resources for the stream's parent context.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Polish green context API: docs, error handling, simplification
- dev.create_context raises ValueError (not NotImplementedError) when
options or resources are missing.
- Cache version checks (_check_green_ctx_support, _check_workqueue_support)
at module level; raise ValueError instead of NotImplementedError.
- Simplify _device_resources.pyx: merge _as_uint and _count_to_sm_count
into _to_sm_count; inline unsigned int casts for coscheduled params.
- Add green context classes to api.rst (Context, ContextOptions,
DeviceResources, SMResource, SMResourceOptions, WorkqueueResource,
WorkqueueResourceOptions).
- Update all docstrings to NumPy style with Attributes/Parameters/Returns
sections matching the existing codebase convention.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Address review comments: consolidate context handles, GIL ordering, std::vector
Review comment 1: Consolidate create_context_handle_from_green_ctx with
create_context_handle_ref by adding a private overload that takes an
optional GreenCtxHandle. The green ctx path now delegates to it after
calling cuCtxFromGreenCtx, ensuring registry lookup and deduplication.
Review comments 2-4: Move GILReleaseGuard to the first line in
create_green_ctx_handle and create_context_handle_from_green_ctx for
consistency with the rest of the file.
Review comment 6: Keep is_green check inline in _context.pyx using
get_context_green_ctx (cannot add a C++ is_green function across
separate .so boundaries without linker issues).
Review comment 8: Replace malloc/free with std::vector<CUdevResource>
in Device.create_context for automatic cleanup.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Fix stream registry corruption for owner-backed handles
Owner-backed stream handles (from create_stream_handle_with_owner) are
no longer registered in the stream_registry. Multiple Python owners can
wrap the same CUstream independently, each stacking its own
Py_INCREF/Py_DECREF without competing for a single registry slot.
The registry lookup at the top is preserved to reuse existing
cuda-core-owned handles that carry context metadata.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
0 commit comments