CUDA graph hangs with cross-green-context edges on R610 driver; works on R580

Hi all,

I encountered a CUDA graph replay hang issue when cross-green-context edges are used. It only happens on the R610 driver or CUDA 13.3. The same code runs to completion on R580, and it also completes when not using green context. Using containers with other CUDA versions on R610 driver hangs too.

Setup

The graph has three kernels on two streams. Each stream comes from its own green context, made by splitting the device’s SMs:

stream A (green ctx, 64 SMs): kernel a ---------+
                                                | (event)
                                                v
stream B (green ctx, rest)  : kernel b ----> kernel c

Kernel c depends on a (an event edge that crosses partitions) and on b (same stream).

  • Eager execution completes every time.
  • On the first graph.replay(), a and b run but c never does (verified with a triton kernel version running a print statement, and c never prints; repro code below doesn’t use triton to keep it minimal)
  • With --green 0, the script uses ordinary torch.cuda.Stream()s and all 10 replays complete.

Environment

Result
R610 driver, CUDA UMD 13.3 Hangs
Driver 580.95.05, CUDA 13.0 Works
  • Container: nvcr.io/nvidia/pytorch:26.02-py3 (CUDA 13.1.1). The same container hangs on R610 and works on R580. Other containers with different CUDA versions also hang on R610, so the trigger looks like the driver, not the toolkit.
  • GPU: <GPU model> (132 SMs, split 64 + 68)

NVIDIA-SMI on an R610 environment with H200 where it hangs:

+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 610.57.04              KMD Version: 610.57.04     CUDA UMD Version: 13.3     |
+-----------------------------------------+------------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|=========================================+========================+======================|
|   0  NVIDIA H200                    On  |   00000000:64:00.0 Off |                    0 |
| N/A   26C    P0             74W /  700W |       4MiB / 143771MiB |      0%      Default |
|                                         |                        |             Disabled |
+-----------------------------------------+------------------------+----------------------+

+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI              PID   Type   Process name                        GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|  No running processes found                                                             |
+-----------------------------------------------------------------------------------------+

Repro Code:

"""Three-kernel CUDA graph that hangs on its first replay with green-context streams.

    stream A (green ctx, 64 SMs): kernel a ---------+
                                                    | (event)
                                                    v
    stream B (green ctx, rest)  : kernel b ----> kernel c

Kernel c depends on a (cross-partition edge) and b (same-stream edge). Eager runs
complete; the first graph.replay() runs a and b, never c, and the following
synchronize blocks forever. --green 0 uses ordinary streams and passes.

    python repro-3kernel-green-graph-hang.py            # hangs after "replay 1"
    python repro-3kernel-green-graph-hang.py --green 0  # prints ALL DONE
"""

import argparse
import sys
import time

import torch
from cuda.bindings import driver


def dummy_kernel(x):
    x.zero_()


def check(ret):
    err, *vals = ret
    assert err == driver.CUresult.CUDA_SUCCESS, err
    return vals[0] if len(vals) == 1 else vals


def green_stream(cu_dev, resource):
    desc = check(driver.cuDevResourceGenerateDesc([resource], 1))
    ctx = check(
        driver.cuGreenCtxCreate(
            desc, cu_dev, driver.CUgreenCtxCreate_flags.CU_GREEN_CTX_DEFAULT_STREAM
        )
    )
    stream = check(
        driver.cuGreenCtxStreamCreate(
            ctx, driver.CUstream_flags.CU_STREAM_NON_BLOCKING, 0
        )
    )
    return torch.cuda.get_stream_from_external(stream)


def main():
    p = argparse.ArgumentParser()
    p.add_argument("--green", type=int, default=1, choices=[0, 1])
    p.add_argument("--sms", type=int, default=64)
    p.add_argument("--iters", type=int, default=10)
    args = p.parse_args()

    torch.cuda.set_device(0)
    torch.zeros(1, device="cuda")
    if args.green:
        cu_dev = check(driver.cuDeviceGet(0))
        sm_resource = check(
            driver.cuDeviceGetDevResource(
                cu_dev, driver.CUdevResourceType.CU_DEV_RESOURCE_TYPE_SM
            )
        )
        groups, _, remaining = check(
            driver.cuDevSmResourceSplitByCount(1, sm_resource, 0, args.sms)
        )
        A = green_stream(cu_dev, groups[0])
        B = green_stream(cu_dev, remaining)
        print(
            f"green ctx streams: A={groups[0].sm.smCount} SMs, B={remaining.sm.smCount} SMs",
            flush=True,
        )
    else:
        A, B = torch.cuda.Stream(), torch.cuda.Stream()
    bufs = [torch.zeros(1024, dtype=torch.int32, device="cuda") for _ in range(3)]

    def fwd():
        cur = torch.cuda.current_stream()
        A.wait_stream(cur)
        B.wait_stream(cur)
        with torch.cuda.stream(A):
            dummy_kernel(bufs[0])
            a_done = torch.cuda.Event()
            a_done.record(A)
        with torch.cuda.stream(B):
            dummy_kernel(bufs[1])
        B.wait_event(a_done)
        with torch.cuda.stream(B):
            dummy_kernel(bufs[2])
        cur.wait_stream(A)
        cur.wait_stream(B)

    def sync(label):
        print(f"{time.strftime('%H:%M:%S')} {label}: synchronize", flush=True)
        torch.cuda.synchronize()

    for i in range(5):
        fwd()
        sync(f"eager {i + 1}")

    graph = torch.cuda.CUDAGraph()
    with torch.cuda.graph(graph):
        fwd()
    sync("capture")

    for i in range(args.iters):
        graph.replay()
        sync(f"replay {i + 1}")
    print("ALL DONE", flush=True)
    return 0


if __name__ == "__main__":
    sys.exit(main())

Output with green contexts (hangs on R610):

green ctx streams: A=64 SMs, B=68 SMs
03:25:48 eager 1: synchronize
03:25:48 eager 2: synchronize
03:25:48 eager 3: synchronize
03:25:48 eager 4: synchronize
03:25:48 eager 5: synchronize
03:25:48 capture: synchronize
03:25:48 replay 1: synchronize
<never returns>

Output with --green 0 (passes):

03:28:12 eager 1: synchronize
...
03:28:12 capture: synchronize
03:28:12 replay 1: synchronize
...
03:28:12 replay 10: synchronize
ALL DONE

Questions

  • Is this a known driver bug in R610? And is there a recommended workaround on R610 that keeps both green contexts and CUDA graphs?
  • Is an event dependency between streams in different green contexts officially supported inside one captured graph?

Thanks!

Your reproducer appears to isolate the stall to the captured cross-context dependency rather than to the three kernels themselves.

One useful discriminator may be the representation of the event during CUDA Graph capture. In the current reproducer, `torch.cuda.Event()` uses `external=False` by default, which creates an internal cross-stream dependency during capture.

Could you repeat the same test with explicit event nodes by changing the initialization to:

a_done = torch.cuda.Event(external=True)

Please leave the SM split, streams, kernels, and synchronization sequence unchanged. With `external=True`, PyTorch creates explicit event-record and event-wait nodes in the captured graph.

The resulting matrix would help narrow down the issue:

- R580, external=False: completes

- R610, external=False: hangs

- R580, external=True: to be tested

- R610, external=True: to be tested

If R610 completes only with `external=True`, that would narrow the issue toward how the internal cross-stream dependency is represented across the two Green Contexts.

If both forms hang on R610, the next layer to isolate would be the context-aware graph topology or its instantiation/replay path.