You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CUDA graph phase N - explicit graph construction #1317
Instead of relying on stream capturing, which is considered an implementation detail (that in the future we could allow users to opt in or out), our graph builder APIs were designed to allow an alternative implementation based on explicitly constructing a graph by adding nodes.
The use cases are unclear atm, so just keeping this in the backlog for now.
I'm picking this up and trying to nail down the scope. The issue describes an alternative GraphBuilder backend that uses explicit graph construction (cuGraphCreate + cuGraphAddNode) instead of stream capture.
Although the graph interface is mostly independent of the construction method, I see two conceptual leaks:
The GraphBuilder.stream property is tightly coupled to capture. The entire usage pattern is kernel.launch(builder.stream, ...).
begin_building(mode=...) takes a mode parameter that maps directly to CUstreamCaptureMode.
If I understand the proposal correctly, we want to retain the same user-facing API while changing the construction method internally. That makes this a large cross-cutting change: every capturable operation needs a dispatch branch. For example, kernel launch becomes something like:
This would add overhead to the hot paths and would largely duplicate logic already handled by the driver's own graph capture machinery, in addition to creating new maintenance burdens.
Before starting the implementation, I'd like to understand the motivation better. What use cases or user stories would explicit construction enable that stream capture doesn't handle well today? What does a "win" look like here? A concrete example would help a lot.
Develop a private module for explicit graph construction (cuGraphCreate + cuGraphAddNode), not exposed as public API.
Test it in isolation.
Wire it into the public GraphBuilder interface in a follow-up.
Stream capture remains the public-facing mechanism for now. Explicit construction becomes an internal implementation detail that enables a unified interface later.
Activity
Andy-Jost commentedon Mar 3, 2026
I'm picking this up and trying to nail down the scope. The issue describes an alternative
GraphBuilderbackend that uses explicit graph construction (cuGraphCreate+cuGraphAddNode) instead of stream capture.Although the graph interface is mostly independent of the construction method, I see two conceptual leaks:
GraphBuilder.streamproperty is tightly coupled to capture. The entire usage pattern iskernel.launch(builder.stream, ...).begin_building(mode=...)takes a mode parameter that maps directly toCUstreamCaptureMode.If I understand the proposal correctly, we want to retain the same user-facing API while changing the construction method internally. That makes this a large cross-cutting change: every capturable operation needs a dispatch branch. For example, kernel launch becomes something like:
This would add overhead to the hot paths and would largely duplicate logic already handled by the driver's own graph capture machinery, in addition to creating new maintenance burdens.
Before starting the implementation, I'd like to understand the motivation better. What use cases or user stories would explicit construction enable that stream capture doesn't handle well today? What does a "win" look like here? A concrete example would help a lot.
Andy-Jost commentedon Mar 3, 2026
After discussion the plan is:
cuGraphCreate+cuGraphAddNode), not exposed as public API.GraphBuilderinterface in a follow-up.Stream capture remains the public-facing mechanism for now. Explicit construction becomes an internal implementation detail that enables a unified interface later.
Convert _graph.py to _graph/ package for explicit graph construction …
Convert _graph.py to _graph/ package for explicit graph construction …
Add RAII infrastructure for explicit graph construction