Repository navigation
Conversation
…HostFunc unchanged The two wrappers routed the call through an internal trampoline that freed its (fn, userData) record after the first call. A host function captured into a CUDA graph is called again on every launch of that graph, so the second launch used freed memory and crashed. The wrappers now pass fn and userData to the driver unchanged, as the _v2 variants already do. The bindings change equals the output of the cybind generator with the matching fix. Two tests capture a host function into a graph and launch it repeatedly, through the driver and the runtime API. Fixes NVIDIA#790 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Summary
Priority: ⬆️ High Change: Bug fix · Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to
|
|
Does this fix need to be backported to the 12.9.x branch? |
|
Yes. I would apply the |
mdboom
left a comment
There was a problem hiding this comment.
LGTM, assuming tests pass.
|
Follow-ups (not blocking):
|
|
Based on this that @juenglin found, I'm retracting my approval, since without that I think the fact that the tests are passing is meaningless.
|
mdboom
left a comment
There was a problem hiding this comment.
See my comment -- I think we should block on this until the tests don't swallow exceptions.
Keep coverage of cudaStreamAddCallback and cudaLaunchHostFunc while checking callback results on the test thread. Check every captured graph replay and clean up CUDA resources on failure. Document callback and user data lifetimes for captured graphs. Signed-off-by: Andy Jost <ajost@nvidia.com>
…nc-trampoline Signed-off-by: Andy Jost <ajost@nvidia.com>
Summary
driver.cuLaunchHostFuncandruntime.cudaLaunchHostFuncrouted the host function through an internal trampoline that freed its(fn, userData)record after the first call. A host function captured into a CUDA graph is called again on every launch of that graph, so the second launch used freed memory and crashed (#790). The wrappers now passfnanduserDatato CUDA unchanged, as the_v2variants already do.Changes
cuda/bindings/driver.pyx,cuda/bindings/runtime.pyx: remove thecuHostCallbackWrapperandcudaStreamRtHostCallbackWrappertrampolines and their records; the two wrappers call CUDA with the caller's function pointer and user data. The generated-file seals are updated. The delta equals the output of the cybind generator with the matching fix (cybind MR !587), applied to the current bindings; the generator change reaches the public bindings through the regular regeneration.tests/test_cuda.py,tests/test_cudart.py: capture a host function into a graph and launch it five times through the driver API and through the runtime API; the function must run once per launch. Both tests crash on the second launch without the fix.Related Work
Fixes #790. The generator side is cybind MR !587; review there asked for this PR to carry the output and a regression test that runs real code.
🤖 Generated with Claude Code