Skip to content
AI Learning Ground Start learning

News ·

Control How Your GPU Shares Work with Green Contexts

NVIDIA's CUDA 13.1 brings green contexts to the Runtime API, letting developers partition GPU SMs and workqueues within a process; a demo cut critical kernel latency from 0.140 ms to 0.007 ms on a 148-SM Blackwell GPU.

Control How Your GPU Shares Work with Green Contexts
Image: NVIDIA

CUDA 13.1 exposes green contexts through the Runtime API. Green contexts, previously available only through the Driver API since CUDA 12.4, let a single process explicitly partition GPU execution resources such as streaming multiprocessors (SMs) and workqueues. Applications can assign a subset of SMs to a green context and target work to it, allowing a latency-sensitive kernel to run without waiting for a bulk workload occupying the whole GPU.

The programming model changes how streams are created: instead of relying on implicit thread-local device state set via cudaSetDevice(), an application creates a green context handle with cudaGreenCtxCreate() and passes it to cudaExecutionCtxStreamCreate(), with work on those streams bound to the context's resources. The existing stream-based workflow is otherwise preserved, and applications can still target the full device via cudaDeviceGetExecutionCtx(). Workqueue provisioning also avoids false serialization when independent stream-ordered workloads otherwise share the same underlying workqueues. Green contexts are lightweight to create and destroy without implicitly synchronizing unrelated GPU work, and they are opt-in and additive.

In a demonstration on a Blackwell GPU with 148 SMs, assigning dedicated SMs to a green context reduced a critical kernel's latency from 0.140 ms to 0.007 ms. Stream priorities alone cannot preempt blocks already executing on SMs, so partitioning offers a stronger guarantee for latency-sensitive work.

For AI builders, this matters for workloads where a small operator shares a GPU with bulk compute, such as communication/GEMM overlap in distributed training and inference, or latency-critical operators in sensor processing platforms like NVIDIA Holoscan. Green contexts offer a practical, incremental way to isolate critical paths without restructuring around heavyweight traditional contexts.

References

  • NVIDIA · developer.nvidia.com

Read the full story at NVIDIA ↗Like, save or discuss on Buzz

#hardware #inference