Uh oh!
There was an error while loading. Please reload this page.
fix(examples): standardize explicit resource cleanup - #1711
Conversation
Auto-sync is disabled for ready for review pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
cpcloud
commented
Mar 3, 2026
/ok to test |
This comment has been minimized.
This comment has been minimized.
cpcloud
commented
Mar 3, 2026
/ok to test |
1 similar comment
cpcloud
commented
Mar 3, 2026
/ok to test |
Ensure cuda.core and cuda.bindings examples deterministically release streams, buffers, and loaded modules so examples remain safe when copied into long-running programs. Made-with: Cursor
Accept pre-commit auto-fixes from the nix run to keep the cleanup PR fully hook-clean. Made-with: Cursor
Replace manual KernelHelper close calls with context-managed usage so modules are unloaded consistently even on early exits and cleanup stays centralized. Made-with: Cursor
8800c46 to
3865524Comparecpcloud
commented
Mar 4, 2026
/ok to test |
mdboom
left a comment
There was a problem hiding this comment.
Approved, modulo fixing whatever is causing the tests to fail.
Not something for this PR, because it's clear this PR is trying to only make changes to cuda_bindings/examples. This PR definitely highlights places where cuda.core objects /should/ have context managers, and I will probably create a new issue to identify those and implement them (and then update these examples accordingly at that point).
Move CUBIN/PTX extraction back into the successful compile path in KernelHelper so example tests do not crash with UnboundLocalError when compilation succeeds. Made-with: Cursor
cpcloud
commented
Mar 4, 2026
/ok to test |
Uh oh!
There was an error while loading. Please reload this page.
|
Summary
Closes#1676.
cuda_coreexamples usingtry/finallyso streams, buffers, and graph resources are always releasedcuda_bindings/examples/common/common.pyKernelHelperwith explicit lifetime management (close, context-manager support) and deterministic NVRTC program teardownsimpleCudaGraphs_test.py)Test plan
pixi run --manifest-path cuda_core -e cu13 python -m compileall <all touched example/helper files>pixi run --manifest-path cuda_core -e cu13 pytest cuda_core/tests/example_tests/test_basic_examples.py -qMade with Cursor