cuda-python icon indicating copy to clipboard operation
cuda-python copied to clipboard

Reorganize graph tests and add device-side launch support

Open Andy-Jost opened this issue 2 weeks ago • 5 comments

Summary

This PR reorganizes the graph tests into a new tests/graph/ subdirectory, adds a public Graph.handle property, and introduces tests for device-side graph launch.

Closes #1331

Changes

Test Reorganization

  • Create new tests/graph/ subdirectory following the pattern of tests/memory_ipc/
  • Break apart test_graph.py into logical groupings:
    • test_basic.py: basic graph construction and topology tests
    • test_conditional.py: conditional node tests (if, if-else, switch, while)
    • test_advanced.py: child graphs, update, stream lifetime
    • test_options.py: debug print, complete options, build mode
  • Incorporate test_graph_mem.py (renamed to test_capture_alloc.py)
  • Add shared kernel compilation helpers in tests/helpers/graph_kernels.py

API Addition

  • Add Graph.handle property to expose the underlying CUgraphExec handle
  • Follows the existing pattern of Stream.handle and Event.handle
  • Forward-compatible with future RAII handle refactoring

Device-Side Graph Launch Tests

  • Add test_device_launch.py with tests for device-side graph launch
  • Uses cudaGraphLaunch() from device code via cudaStreamGraphTailLaunch
  • Requires Hopper (sm_90+) architecture
  • Uses cuda.pathfinder.find_nvidia_header_directory() to locate libcudadevrt.a

Test Coverage

  • 58 tests total in tests/graph/
  • All tests pass on Hopper (H200)
  • Device launch tests skip on pre-Hopper architectures

Andy-Jost avatar Jan 16 '26 21:01 Andy-Jost