fix(cuda.core): surface CUresult when graph instantiation fails - #2719
Merged
Conversation
…e to Tegra gpu not supporting a cuda graph feature
…or so that the message is not swallowed by RuntimeError
Contributor
Contributor
Author
|
/ok to test 6aa629f |
This comment has been minimized.
This comment has been minimized.
rwgk
approved these changes
Aug 28, 2026
rwgk
left a comment
Contributor
There was a problem hiding this comment.
I'm approving, but could you please add the test below, and apply the suggested change to the RuntimeError message before you merge?
diff --git a/cuda_core/tests/graph/test_options.py b/cuda_core/tests/graph/test_options.py
index 391f521b65c..a189eaf9160 100644
--- a/cuda_core/tests/graph/test_options.py
+++ b/cuda_core/tests/graph/test_options.py
@@ -7,6 +7,7 @@ import pytest
from helpers.graph_kernels import compile_common_kernels, compile_conditional_kernels
from cuda.core import Device, LaunchConfig, launch
+from cuda.core._utils.cuda_utils import CUDAError
from cuda.core.graph import GraphBuilder, GraphCompleteOptions, GraphDebugPrintOptions
@@ -65,6 +66,20 @@ def test_graph_complete_options(init_cuda):
gb.complete(options).close()
+@pytest.mark.agent_authored(model="gpt-5.6")
+def test_graph_complete_invalid_options_raise_cuda_error(init_cuda):
+ mod = compile_common_kernels()
+ empty_kernel = mod.get_kernel("empty_kernel")
+
+ gb = Device().create_graph_builder().begin_building()
+ launch(gb, LaunchConfig(grid=1, block=1), empty_kernel)
+ gb.end_building()
+
+ options = GraphCompleteOptions(auto_free_on_launch=True, device_launch=True)
+ with pytest.raises(CUDAError, match="CUDA_ERROR_INVALID_VALUE"):
+ gb.complete(options)
+
+
def test_graph_build_mode(init_cuda):
mod = compile_common_kernels()
empty_kernel = mod.get_kernel("empty_kernel")Co-authored-by: Ralf W. Grosse-Kunstleve <rwgkio@gmail.com>
Contributor
Author
|
/ok to test 6283221 |
lijinf2
enabled auto-merge (squash)
August 28, 2026 23:19
Contributor
Author
Sure. The error message becomes more accurate, and test coverage gets improved. I applied all the suggested edits. Thank you Ralf! |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
closes #2527
The Orin nightly failure is
test_graph_alloc_with_output: it allocates graph memory, leaves it unfreed so the buffer can be used outside the graph, and instantiates withGraphCompleteOptions(auto_free_on_launch=True). That combination is rejected on L4T Orin (CUDA_ERROR_INVALID_VALUE). Otherauto_free_on_launchcases on the same board still pass (empty graphs, alloc+free in the same graph). The test already skips onCUDAErrorwhose message containsCUDA_ERROR_INVALID_VALUE.After #2473,
_instantiate_graphmappedCUDA_GRAPH_INSTANTIATE_ERRORto a genericRuntimeErrorand dropped the driverCUresult. The skip no longer matched, so the same platform limitation became a FAIL.This PR calls
HANDLE_RETURNon the instantiate status first. A non-successCUresultis raised asCUDAErrorwith the driver name and message (e.g.CUDA_ERROR_INVALID_VALUE). The genericRuntimeErrorremains only when that status isCUDA_SUCCESS. Orin goes back to skip; the driver error is no longer swallowed.Checklist