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
Commit 230f0eb
Browse filesBrowse the repository at this point in the historyBrowse files
feat(cuda.core): add host_launch for stream-ordered host functions (#3258)
* feat(cuda.core): add host_launch for stream-ordered host functions
Add cuda.core.host_launch(stream, fn, *, user_data=None), the stream-side
counterpart of GraphBuilder.callback. It enqueues a Python callable or a
ctypes function pointer with the CUhostFn prototype on a stream through
cuLaunchHostFunc; a GraphBuilder argument forwards to its callback. The
callable and a copied user_data stay alive until the function has run and
are released afterwards on the main thread through the deferred-cleanup
queue, never on the driver thread. A plain stream under active capture is
rejected, because the owners could not be attached to the captured node.
The shared callback helper moves from cuda/core/graph/_host_callback to
cuda/core/_host_callback, since a core module must not import the graph
package at module level. The launch record and trampoline live in
_cpp/rt/host_launch.cpp, and cuLaunchHostFunc joins the driver table.
Written by Codex (gpt-6.1-sol); reviewed by Claude.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
* cuda.core: address the self-review of host_launch
State that a ctypes callback that wraps a Python function acquires the GIL
through ctypes, so the deadlock rule applies to it; complete the Raises
section; say the driver may reject CUDA calls from the callback rather than
that it does. Upcast the launch record to the cleanup base before the void*
parameter, as the graph producers do. Prove the user_data copy by changing
the caller's buffer while the stream is held, pin the unraisable type and
message, and link the example from the examples page.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
* cuda.core: say that a CUDA call from a host callback may deadlock
CodeRabbit's review of host_launch: the driver does not guarantee an error
for a CUDA call made from a host function; such a call may also deadlock.
State both outcomes in the warning.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
---------
Co-authored-by: Claude Fable 5.1 <[email protected]>
0 commit comments