[FIX]: cuda.core: simplify _check_runtime_error logic#2003
Merged
rwgk merged 2 commits intoNVIDIA:mainfrom May 1, 2026
Merged
Conversation
Use the generated runtime error enum as the name source for known CUDA Runtime errors so error messages remain stable when the runtime name table differs from the installed bindings. Made-with: Cursor
Contributor
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
Contributor
Author
|
/ok to test |
This comment has been minimized.
This comment has been minimized.
`_check_error()` only routes `runtime.cudaError_t` instances into `_check_runtime_error()`, so consulting `cudaGetErrorName()` and keeping a fallback for unknown values does not improve the normal `cuda.core` path. The Windows hybrid cudart issue is that the runtime name table can lag the generated enum table, so using `error.name` directly is both simpler and a better match for the values the code already has. With the runtime path now relying on enum members, the runtime-side tests no longer need to account for `UNEXPECTED ERROR CODE` in this loop or keep a separate monkeypatch test for avoiding the runtime name lookup. Made-with: Cursor
Contributor
Author
|
/ok to test |
leofang
approved these changes
May 1, 2026
|
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.
Summary
While investigating nvbugs 6115382, inspecting the
cuda.coreerror-handling path revealed that_check_runtime_error()can be simplified structurally._check_error()only routesruntime.cudaError_tvalues into_check_runtime_error(). Because the function already receives aruntime.cudaError_tenum member, it can useerror.namedirectly instead of callingruntime.cudaGetErrorName()first and decoding the returned string.This keeps runtime error formatting aligned with the generated bindings enum and removes a runtime name lookup that is unnecessary in the normal
cuda.corepath.Rationale
Before this change,
_check_runtime_error()asked the runtime library for the error name even though the function had already been given aruntime.cudaError_tenum member. In the expected path, the name lookup was therefore recovering information already present on the enum object.Using
error.nameis also a better fit for the situation that prompted this investigation. When the Windows runtime library's error-name table lags the generatedcuda.bindingsenum table, the enum member still carries the correct installed-bindings name, so the raisedCUDAErrorcontinues to use a stable and specific error name.Test Simplification
The runtime-side test can be simplified for the same reason. Since
test_check_runtime_error()iterates overruntime.cudaError_tmembers, it now exercises a path where the error name always comes fromerror.name.That means the runtime test no longer needs to account for an
UNEXPECTED ERROR CODEbranch in this loop. The test can directly assert that each non-success runtime error message includeserror.name.Side Note
The same structural simplification does not apply to
_check_driver_error(). The driver-side path still performs meaningful lookup through the driver API and retains explicit handling for unexpected codes, so its currentcuGetErrorName()/cuGetErrorString()structure remains appropriate.