cuda-python
cuda-python copied to clipboard
Reorganize graph tests and add device-side launch support
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 oftests/memory_ipc/ - Break apart
test_graph.pyinto 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 totest_capture_alloc.py) - Add shared kernel compilation helpers in
tests/helpers/graph_kernels.py
API Addition
- Add
Graph.handleproperty to expose the underlyingCUgraphExechandle - Follows the existing pattern of
Stream.handleandEvent.handle - Forward-compatible with future RAII handle refactoring
Device-Side Graph Launch Tests
- Add
test_device_launch.pywith tests for device-side graph launch - Uses
cudaGraphLaunch()from device code viacudaStreamGraphTailLaunch - Requires Hopper (sm_90+) architecture
- Uses
cuda.pathfinder.find_nvidia_header_directory()to locatelibcudadevrt.a
Test Coverage
- 58 tests total in
tests/graph/ - All tests pass on Hopper (H200)
- Device launch tests skip on pre-Hopper architectures