ReadingResearchRadarInvestment framework
Sign in / Sign up
← Back to reading
NewsTopic · 英伟达CUDA绿色上下文2 min read·2026-10-18DisconfirmAI Editorial

NVIDIA Technical Blog: How CUDA Green Contexts Cut Critical Kernel Latency to Microseconds via Explicit Partitioning

NVIDIA engineers explain the Green Contexts mechanism introduced in CUDA 13.1. By explicitly allocating Streaming Multiprocessors (SMs) and workqueues, the mechanism allows applications to isolate latency-sensitive tasks from high-throughput background jobs within a single process. Tests on a Blackwell GPU show that compared to using only high-priority streams, Green Contexts reduce critical kernel wait time from 0.140 ms to 0.007 ms by bypassing the scheduler's need to wait for existing blocks to drain.

ImportanceMaterialEvidenceE3 inspectableWrite-upQuick

Original publication time 2026-10-06 23:00 GMT+8

Modern GPU applications often run multiple independent components simultaneously within a single process: communication overlap in distributed training, real-time inference in AI sensor platforms, or parallel data preprocessing and model inference. Traditionally, developers relied on CUDA stream priorities to ensure critical tasks weren't blocked, but this approach has a physical ceiling. When high-throughput bulk workloads saturate all Streaming Multiprocessors (SMs), even a highest-priority critical kernel must wait for at least one SM to free up before it can begin execution. This 'drain wait' causes unpredictable latency jitter.

To address this limitation, NVIDIA officially introduced Green Contexts in the CUDA 13.1 Runtime API. Unlike traditional heavy device contexts, Green Contexts are a lightweight programming model that allows applications to explicitly define and partition GPU execution resources. Developers can query device resources, package a specific subset of SMs and workqueue configurations into a descriptor, and create independent execution contexts based on it. Subsequently, application-created streams bind directly to these contexts, clearly specifying which compute units serve which types of tasks.

Sign in / Sign up
ReadingResearchRadarInvestment framework

To quantify the actual effect of this mechanism, the NVIDIA team conducted comparative tests on a Blackwell GPU with 148 SMs. The experiment set up a tiny integer operation as the 'critical kernel' and a series of square root loops designed to saturate the device as the 'bulk kernel'. Results showed that in the default context without resource partitioning, even with high-priority streams, the average latency of the critical kernel was 0.140 ms; after adopting Green Contexts to dedicate 8 SMs specifically to the critical task, the latency dropped sharply to 0.007 ms. This means that through physical isolation rather than scheduling priority, approximately 20 times the additional wait time was eliminated.

However, this performance gain comes at a cost. The core logic of Green Contexts is a zero-sum game of resources: the more SMs reserved for the critical path, the lower the parallelism left for bulk tasks. Therefore, this mechanism is best suited for operations that are extremely latency-sensitive and relatively small in computational load, or scenarios requiring strict Service Level Agreement (SLA) guarantees. For pure compute-intensive tasks pursuing maximum overall throughput, forced partitioning may actually lead to efficiency losses. Additionally, while the code changes appear minor, they require developers to shift from implicit thread-local state management to explicit resource planning, increasing the complexity of application architecture design.

Sources

  • 原始出处developer.nvidia.com↗
Topic

英伟达CUDA绿色上下文

英伟达在 CUDA 13.1 中正式将“绿色上下文”(Green Contexts)引入 Runtime API,允许开发者在同一进程内显式划分 GPU 执行资源(如流多处理器 SM 和工作队列),以隔离延迟敏感型任务与高吞吐量后台任务。

2 steps1 piecesUpdated 2026-10-18 05:44

How it got here

  1. 2026-10-06NVIDIA 发布技术博客,详细解释 CUDA 13.1 中绿色上下文如何通过显式分区降低关键内核延迟。
  2. 2026-10-18新闻汇总确认:相比仅使用高优先级流,绿色上下文能将 Blackwell GPU 上的关键内核等待时间从 0.140ms 降至 0.007ms。

What is still unsettled

  • 在非 Blackwell 架构(如 Hopper 或 Ada Lovelace)上,绿色上下文的延迟改善幅度是否一致?
  • 对于依赖 MPS(多进程服务)的环境,如何精确控制 `CUDA_MPS_ACTIVE_THREAD_PERCENTAGE` 与绿色上下文 SM 分区的冲突?
  • Runtime API 暴露后,第三方深度学习框架(如 PyTorch/TensorFlow)何时会原生支持基于绿色上下文的资源隔离?
Read the full topic →
Continue researching →