Summary
We observed a reproducible increase in eager AllToAll latency when an idle CUDA Graph was retained on the same NCCL communicator. On two nodes with 16 NVIDIA B-series GPUs, capturing 1,728 Zero-CTA AllToAll calls increased subsequent eager AllToAll latency from 0.455 ms to 1.087 ms. The graph was never instantiated or replayed. Destroying it restored latency to approximately 0.453 ms.
An independent communicator using the same GPUs, rank membership, and registered buffers remained close to its baseline. Both communicators were measured sequentially.
The behavior has been reproduced with a vendor-modified NCCL 2.30.7 build. We have not yet verified it on an unmodified upstream release. We are reporting the reproducer and observations to help determine whether the behavior originates upstream and whether a fix or mitigation is available.
Test environment
| Component | Configuration |
|---|---|
| Hardware | 2 nodes, each with 8 NVIDIA B-series GPUs |
| PyTorch | 2.9.0 |
| CUDA version reported by PyTorch | 13.0 |
| NCCL | 2.30.7, vendor-modified build |
| Network backend | Built-in RMA backend; no external network plugin |
| Communication group | 8 ranks: 4 GPUs on each node |
| AllToAll input | 64 MiB per rank, split equally among 8 peers |
| Captured graph | 1,728 AllToAll calls; never instantiated or replayed |
| NVLS | Disabled |
| Other workloads during measurement | None |
Driver and NIC firmware versions, as well as the vendor patch set, are not included in this report. The program uses synthetic data and has no model, checkpoint, or training-framework dependency.
Reproduction procedure
Each process creates two independent native NCCL communicators, A and B, with identical rank membership. Both use CTAPolicy=2 (Zero CTA). The same input and output buffers are registered separately with each communicator.
- Measure eager AllToAll latency on A, then B, before capturing a graph.
- Capture 1,728 AllToAll calls on A using
torch.cuda.CUDAGraph(keep_graph=True). - Retain the graph without calling
instantiate()orreplay(). - Measure additional eager AllToAll calls on A, then B, while the graph remains idle.
- Destroy the graph with
graph.reset(), release its Python reference, and repeat the measurements twice.
The timed operations are always the additional eager calls, not graph replay. A and B never run concurrently. Buffer allocations, rank membership, and the communication stream remain unchanged across stages.
Results
We expected eager communication latency to remain close to baseline while a captured graph was idle. Instead, latency increased substantially on A and recovered after graph destruction, while B remained largely unaffected.
| Stage | A: mean latency (ms/call) | B: mean latency (ms/call) |
|---|---|---|
| Before capture | 0.455076 | 0.453264 |
| Captured graph retained, never executed | 1.087212 | 0.457663 |
| After graph destruction | 0.453008 | 0.452161 |
| Second check after destruction | 0.457584 | 0.453025 |
During idle graph retention, latency was 2.389× baseline on A and 1.010× baseline on B. A’s second measurement after destruction was 1.006× baseline. All 16 ranks passed exact output checks in every warmup and measured batch.
These results come from the standalone reproducer below. They demonstrate an effect tied to the graph-owning communicator and the graph’s lifetime; they do not establish the underlying mechanism by themselves.
How latency was measured
For each stage and communicator, the program runs 5 warmup batches and 20 measured batches. Two CUDA Events on the communication stream bracket 16 consecutive AllToAll calls. Each interval is divided by 16, and the reported result is the arithmetic mean across all 20 batches and 16 ranks. The program also reports per-rank means and host submission time.
Before each batch, inputs change according to a deterministic source/destination-rank pattern, the output is cleared, and all ranks synchronize. After completion, each rank checks the output for exact equality with the expected result. A CPU control collective propagates any failure. Data preparation, synchronization, and correctness checks are outside the timed interval.
The event interval includes communication waiting and gaps between submissions, so it should not be interpreted as pure network transfer time. No CPU profiler was active during these measurements.
Additional observation
In a separate diagnostic run with the same vendor NCCL build, instruction-address samples from an idle CPU progress thread repeatedly landed in ncclRmaProxyProgress, around readiness checks followed by traversal to the next persistent work record. This hotspot appeared after graph capture and disappeared after graph destruction. Sampling took place outside the communication timing intervals and is not part of the minimal reproducer.
This is consistent with polling of graph-associated persistent RMA work adding overhead to the owning communicator’s progress loop. It remains a hypothesis about the delay mechanism, rather than a conclusion established by the timing experiment alone.
Questions for NCCL maintainers
- Are persistent RMA work records for a captured but uninstantiated graph expected to be polled while the graph is idle?
- Could that polling delay eager communication on the same communicator? Is there a related fix in a newer upstream release?
- Is there a recommended way to retain a large graph without incurring this eager-communication penalty?
Running the reproducer
Save run.sh and repro.py below in the same directory on both nodes, or extract the accompanying nccl-idle-graph-repro.zip.
The script requires PyTorch support for CUDAGraph(keep_graph=True) and the private NCCL symmetric-memory allocator. It resolves NCCL symbols through libtorch_cuda.so and requires matching NCCL >= 2.30.6 with ncclAlltoAll and ncclCommWindowRegister available. Builds that do not expose these capabilities are unsupported.
Replace NODE0_ADDRESS with a reachable address of node 0. Use the same port and benchmark arguments on both nodes:
# Node 0
MASTER_ADDR=NODE0_ADDRESS NODE_RANK=0 bash run.sh
# Node 1
MASTER_ADDR=NODE0_ADDRESS NODE_RANK=1 bash run.sh
The program forms two groups: [0,1,2,3,8,9,10,11] and [4,5,6,7,12,13,14,15]. It checks that ranks 0–7 and 8–15 belong to different nodes. Defaults are --resident-calls 1728 --mib 64 --samples 20 --repeats 16; pass any overrides identically on both nodes.
Configuration used for validation
run.sh sets the following before starting CUDA processes:
export NCCL_PXN_DISABLE=1
export NCCL_WIN_ENABLE=1
export CUDA_DEVICE_MAX_CONNECTIONS=128
export NCCL_NVLS_ENABLE=0
export NCCL_GRAPH_REGISTER=0
The measured run also used these network settings, which can be exported on both nodes before invoking run.sh:
export NCCL_IB_QPS_PER_CONNECTION=8
export NCCL_NETDEVS_POLICY=MAX:1
export NCCL_P2P_NET_CHUNKSIZE=524288
export NCCL_IB_OOO_RQ=0
export NCCL_IB_AR_THRESHOLD=0
We have not isolated which of these additional settings, if any, are necessary to reproduce the issue. Select network interfaces for your own environment and use consistent settings on both nodes. The validation used no external NCCL network plugin.
The native communicator configuration combines minCTAs=maxCTAs=1 with CTAPolicy=2, preserving the configuration used in the experiment. Zero CTA is selected by CTAPolicy.
Validation scope
The Python reproducer was tested on two nodes with B-series GPUs using a platform-specific torchrun rendezvous launcher that supplied the environment settings above. The portable run.sh was checked for shell syntax but was not the entry point used for that GPU run. The code below has the same executable logic as the validated script; only comments have been edited.
Output consists of JSON records for baseline, captured_idle, destroyed, and destroyed_recheck. Successful correctness checks alone do not establish reproduction of the latency issue. If both communicators slow down, if A does not recover, or if latency remains unchanged, report that outcome along with the software and network configuration. The measured latencies above are observations, not fixed acceptance thresholds.
Source code
run.sh
#!/usr/bin/env bash
set -euo pipefail
: "${MASTER_ADDR:?Set MASTER_ADDR to the first node address}"
: "${NODE_RANK:?Set NODE_RANK to 0 or 1}"
export NCCL_PXN_DISABLE=1
export NCCL_WIN_ENABLE=1
export CUDA_DEVICE_MAX_CONNECTIONS=128
export NCCL_NVLS_ENABLE=0
export NCCL_GRAPH_REGISTER=0
export NCCL_DEBUG="${NCCL_DEBUG:-WARN}"
exec python3 -m torch.distributed.run \
--nnodes=2 --nproc-per-node=8 --node-rank="$NODE_RANK" \
--master-addr="$MASTER_ADDR" --master-port="${MASTER_PORT:-29500}" \
"$(dirname "$0")/repro.py" "$@"
repro.py
"""Reproduce idle CUDA Graph interference on a Zero-CTA communicator."""
import argparse
import ctypes as C
import json
import os
import socket
import statistics
import time
from datetime import timedelta
from pathlib import Path
import torch
import torch.distributed as dist
import torch.distributed._symmetric_memory as symm
class UniqueId(C.Structure):
_fields_ = [("data", C.c_char * 128)]
class Config(C.Structure):
# Versioned NCCL configuration prefix; omitted trailing fields use NCCL defaults
_fields_ = [
("size", C.c_size_t), ("magic", C.c_uint), ("version", C.c_uint),
("blocking", C.c_int), ("cgaClusterSize", C.c_int),
("minCTAs", C.c_int), ("maxCTAs", C.c_int),
("netName", C.c_char_p), ("splitShare", C.c_int),
("trafficClass", C.c_int), ("commName", C.c_char_p),
("collnetEnable", C.c_int), ("CTAPolicy", C.c_int),
("shrinkShare", C.c_int), ("nvlsCTAs", C.c_int),
]
def __init__(self):
super().__init__()
for name, kind in self._fields_:
if kind is C.c_int:
setattr(self, name, -(2**31))
self.size, self.magic, self.version = C.sizeof(self), 0xCAFEBEEF, 22700
self.blocking = 1
self.CTAPolicy = 2 # NCCL_CTA_POLICY_ZERO
self.minCTAs = self.maxCTAs = 1
class Communicator:
def __init__(self, library, group, tensors):
self.lib, self.group = library, group
self.size = dist.get_world_size(group)
self.comm = C.c_void_p()
self.windows = []
uid = UniqueId()
if dist.get_rank(group) == 0:
self.check(library.ncclGetUniqueId(C.byref(uid)))
payload = [bytes(uid)]
leader = dist.get_process_group_ranks(group)[0]
dist.broadcast_object_list(payload, src=leader, group=group)
uid = UniqueId.from_buffer_copy(payload[0])
config = Config()
self.check(library.ncclCommInitRankConfig(
C.byref(self.comm), self.size, uid, dist.get_rank(group), C.byref(config)
))
for tensor in tensors:
handle = C.c_void_p()
self.check(library.ncclCommWindowRegister(
self.comm, tensor.data_ptr(), tensor.nbytes, C.byref(handle), 1
))
self.windows.append(handle)
def check(self, result):
if result:
raise RuntimeError(self.lib.ncclGetErrorString(result).decode())
def exchange(self, source, output, stream):
self.check(self.lib.ncclAlltoAll(
source.data_ptr(), output.data_ptr(), source.numel() // self.size,
1, self.comm, stream.cuda_stream, # ncclUint8
))
def close(self):
for handle in self.windows:
self.check(self.lib.ncclCommWindowDeregister(self.comm, handle))
self.check(self.lib.ncclCommDestroy(self.comm))
def load_nccl():
# Resolve the NCCL library already linked by PyTorch
lib = C.CDLL(str(Path(torch.__file__).parent / "lib/libtorch_cuda.so"))
ptr = C.c_void_p
signatures = {
"ncclGetUniqueId": [C.POINTER(UniqueId)],
"ncclGetVersion": [C.POINTER(C.c_int)],
"ncclCommInitRankConfig": [C.POINTER(ptr), C.c_int, UniqueId, C.c_int, C.POINTER(Config)],
"ncclCommWindowRegister": [ptr, ptr, C.c_size_t, C.POINTER(ptr), C.c_int],
"ncclCommWindowDeregister": [ptr, ptr],
"ncclAlltoAll": [ptr, ptr, C.c_size_t, C.c_int, ptr, ptr],
"ncclCommDestroy": [ptr],
}
for name, args in signatures.items():
fn = getattr(lib, name)
fn.argtypes, fn.restype = args, C.c_int
lib.ncclGetErrorString.argtypes = [C.c_int]
lib.ncclGetErrorString.restype = C.c_char_p
version = C.c_int()
if lib.ncclGetVersion(C.byref(version)):
raise RuntimeError("ncclGetVersion failed")
a, b, c = torch.cuda.nccl.version()[:3]
if version.value != a * 10000 + b * 100 + c or version.value < 23006:
raise RuntimeError("Requires matching PyTorch NCCL >= 2.30.6")
return lib, version.value
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--resident-calls", type=int, default=1728)
parser.add_argument("--mib", type=int, default=64)
parser.add_argument("--samples", type=int, default=20)
parser.add_argument("--repeats", type=int, default=16)
args = parser.parse_args()
if min(vars(args).values()) < 1:
parser.error("all parameters must be positive")
required = {"NCCL_PXN_DISABLE": "1", "NCCL_WIN_ENABLE": "1", "NCCL_NVLS_ENABLE": "0"}
for key, value in required.items():
if os.environ.get(key) != value:
raise RuntimeError(f"Set {key}={value} before starting torchrun")
if int(os.environ.get("CUDA_DEVICE_MAX_CONNECTIONS", "0")) < 128:
raise RuntimeError("Set CUDA_DEVICE_MAX_CONNECTIONS >= 128 before torchrun")
torch.set_num_threads(1)
torch.cuda.set_device(int(os.environ["LOCAL_RANK"]))
dist.init_process_group("nccl", timeout=timedelta(minutes=10))
if dist.get_world_size() != 16:
raise RuntimeError("Run on exactly two nodes with eight GPUs each")
rank = dist.get_rank()
control = dist.new_group(backend="gloo", timeout=timedelta(minutes=10))
hosts = [None] * 16
dist.all_gather_object(hosts, socket.gethostname(), group=control)
if len(set(hosts[:8])) != 1 or len(set(hosts[8:])) != 1 or hosts[0] == hosts[8]:
raise RuntimeError("Ranks 0..7 and 8..15 must belong to two different nodes")
groups = []
for peers in ([0, 1, 2, 3, 8, 9, 10, 11], [4, 5, 6, 7, 12, 13, 14, 15]):
group = dist.new_group(peers, backend="gloo", timeout=timedelta(minutes=10))
groups.append(group)
if rank in peers:
selected, members = group, peers
library, version = load_nccl()
symm.set_backend("NCCL")
symm.enable_symm_mem_for_group(dist.group.WORLD.group_name)
source = symm.empty(args.mib * 1024**2, dtype=torch.uint8, device=torch.device("cuda", torch.cuda.current_device()))
output = symm.empty(source.numel(), dtype=torch.uint8, device=torch.device("cuda", torch.cuda.current_device()))
expected = torch.empty_like(source)
stream = torch.cuda.Stream()
stream.wait_stream(torch.cuda.current_stream())
comms = [Communicator(library, selected, (source, output)) for _ in range(2)]
if rank == 0:
print(json.dumps({"environment": {"torch": str(torch.__version__),
"cuda": torch.version.cuda, "nccl": version,
"gpu": torch.cuda.get_device_name(), "world_size": 16,
"group_size": 8, "parameters": vars(args)}}), flush=True)
sequence = 0
def measure(stage):
nonlocal sequence
rows = []
for name, comm in zip(("A", "B"), comms):
device_ms, host_ms = [], []
for index in range(args.samples + 5):
sequence += 1
mask = (sequence * 17) & 255
with torch.cuda.stream(stream):
for chunk, peer in zip(source.chunk(8), members):
chunk.fill_((rank * 16 + peer) ^ mask)
for chunk, peer in zip(expected.chunk(8), members):
chunk.fill_((peer * 16 + rank) ^ mask)
output.fill_(0)
torch.cuda.synchronize()
dist.barrier(group=control)
begin, end = [torch.cuda.Event(enable_timing=True) for _ in range(2)]
with torch.cuda.stream(stream):
begin.record()
start = time.perf_counter()
for _ in range(args.repeats):
comm.exchange(source, output, stream)
host_elapsed = time.perf_counter() - start
end.record()
end.synchronize()
valid = torch.tensor(int(torch.equal(output, expected)), dtype=torch.int32)
dist.all_reduce(valid, op=dist.ReduceOp.MIN, group=control)
if valid.item() != 1:
raise RuntimeError(f"Incorrect output: {stage}/{name}/{index}")
if index >= 5:
device_ms.append(begin.elapsed_time(end) / args.repeats)
host_ms.append(host_elapsed * 1000 / args.repeats)
rows.append({"stage": stage, "comm": name, "rank": rank,
"samples_ms": device_ms,
"mean_ms": statistics.mean(device_ms),
"host_submit_ms": statistics.mean(host_ms), "correct": True})
collected = [None] * 16
dist.all_gather_object(collected, rows, group=control)
if rank == 0:
for index, name in enumerate(("A", "B")):
reports = [row[index] for row in collected]
print(json.dumps({"stage": stage, "comm": name,
"mean_ms": statistics.mean(r["mean_ms"] for r in reports),
"host_submit_ms": statistics.mean(r["host_submit_ms"] for r in reports),
"per_rank_mean_ms": [r["mean_ms"] for r in reports],
"correct": True}), flush=True)
measure("baseline")
graph = torch.cuda.CUDAGraph(keep_graph=True)
dist.barrier(group=control)
with torch.cuda.graph(graph, stream=stream):
for _ in range(args.resident_calls):
comms[0].exchange(source, output, stream)
# Never instantiate or replay this graph; time only additional eager calls
measure("captured_idle")
graph.reset()
del graph
dist.barrier(group=control)
measure("destroyed")
measure("destroyed_recheck")
torch.cuda.synchronize()
for comm in reversed(comms):
comm.close()
dist.barrier(group=control)
for group in reversed(groups):
if group != dist.GroupMember.NON_GROUP_MEMBER:
dist.destroy_process_group(group)
dist.destroy_process_group(control)
dist.destroy_process_group()
if __name__ == "__main__":
main()