Repository navigation
Commit 5e8f7e9
cuda.core: define the error handling policy and report failures that cannot be raised
Write down how cuda.core handles CUDA failures (docs/source/error_handling.rst
for users, a "Failure handling" section in AGENTS.md and _cpp/DESIGN.md for
contributors) and bring the code into line with it:
- Add cuda.core.CUDAWarning, emitted for CUDA errors that cannot be raised
(destructors, CUDA callbacks, cleanup after an earlier failure). The C++
handle layer reports through one helper that uses the Python warnings
machinery when the interpreter is usable, delivers an escalated warning as an
unraisable exception, and falls back to stderr otherwise.
CUDA_ERROR_DEINITIALIZED is not reported.
- Wrap every destroy call made from a deleter (pw_*) so its failure is
reported instead of discarded, including memory pools, green contexts,
graphs, graph execs, graphics resources, the linker, user objects, the
NVRTC/NVVM/nvJitLink handles and file descriptors; release the GIL around
the compiler-handle destroys like the CUDA ones.
- When the caller's context cannot be restored after a successful operation,
undo the creation and raise a CUDAError that says which context is current;
report the same failure as a warning in deleters; report a skipped
context-sensitive undo instead of leaking silently.
- Add context_get_device and graph_node_set_params so Stream_get_ctx_device
and _set_definition_node_params stop hand-rolling cuCtxPush/Pop/SetCurrent.
The node update now publishes its attachment before raising a restoration
failure, closing a window that left the node referencing released owners.
- Device.set_current(ctx) switches with a single cuCtxSetCurrent, so a failure
leaves the previous context current and the call works without one.
- Report failed cuStreamEndCapture in GraphBuilder.__dealloc__ and failed
child-graph rollbacks; warn from _mr_dealloc_callback instead of printing.
- Add a test hook that makes the next context restoration fail, tests for the
policy, and release notes for 1.3.0.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>1 parent 83a3d46 commit 5e8f7e9
23 files changed
Lines changed: 1050 additions & 131 deletions
File tree
- cuda_core
- cuda/core
- _cpp
- _memory
- _utils
- graph
- docs/source
- release
- tests
- helpers
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
104 | 160 | | |
105 | 161 | | |
106 | 162 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| 105 | + | |
105 | 106 | | |
106 | 107 | | |
| 108 | + | |
107 | 109 | | |
108 | 110 | | |
109 | 111 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
275 | 275 | | |
276 | 276 | | |
277 | 277 | | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
278 | 309 | | |
279 | 310 | | |
280 | 311 | | |
| |||
0 commit comments