iris icon indicating copy to clipboard operation
iris copied to clipboard

Add CUDA graph capture probe for iris collectives

Open mawad-amd opened this issue 7 months ago • 0 comments

Summary

  • Adds tests/graph_capture_probe.py — a probe script that tests which iris operations can be captured in a CUDA graph
  • Uses hipStreamBeginCapture detection (authoritative from HIP runtime) plus fresh-data replay validation to catch stale results
  • Run with: torchrun --nproc_per_node=2 --standalone tests/graph_capture_probe.py

Results (MI355X, 2 GPUs)

Operation Status Blocker
device_barrier CAPTURABLE —
host_barrier NOT CAPTURABLE Uses NCCL
ccl.all_reduce(atomic) NOT CAPTURABLE refresh_peer_access CPU↔CUDA copy
ccl.all_reduce(two_shot) NOT CAPTURABLE same
ccl.all_reduce(one_shot) NOT CAPTURABLE same
ccl.all_gather NOT CAPTURABLE same
ccl.all_to_all NOT CAPTURABLE same
ccl.reduce_scatter NOT CAPTURABLE same
ops.matmul_all_reduce NOT CAPTURABLE same

Root cause

SymmetricHeap.allocate() calls refresh_peer_access() every time, which does:

self.heap_bases[self.cur_rank] = int(all_bases_arr[self.cur_rank])

This is a CPU↔CUDA tensor copy, which is illegal during hipStreamBeginCapture. It gets triggered when any ctx.zeros() allocation happens inside the CCL launch path (workspace creation in preamble).

Fix direction

To make CCL ops graph-capturable, we need to:

  1. Ensure all workspace allocation happens before graph capture (pre-allocate via preamble)
  2. Make get_heap_bases() return a pre-built CUDA tensor without any CPU interaction during the kernel launch path
  3. Add async_op=True to skip the trailing ctx.barrier() (already supported)

🤖 Generated with Claude Code

mawad-amd avatar Apr 30 '26 07:04 mawad-amd