fix(cuda.core): write NVRTC source to a temp file when debug or lineinfo is enabled - #2679
Merged
Conversation
Contributor
Keep materialize/unlink next to the Program lifetime that owns the temp file, instead of as module-level functions.
…urce
Skip when cuda-gdb is missing, and use shorter {caller}_{kernel}_ temp names.
Contributor
Author
|
/ok to test 7a5877c |
This comment has been minimized.
This comment has been minimized.
rparolin
approved these changes
Aug 21, 2026
This comment has been minimized.
This comment has been minimized.
1 similar comment
|
Contributor
Author
|
Thank you @rparolin! |
This was referenced Aug 27, 2026
brandon-b-miller
added a commit
to brandon-b-miller/cuda-python
that referenced
this pull request
Aug 31, 2026
NVIDIAgh-2385 and NVIDIAgh-2422 were filed for the same NVBug (6420444) and assigned to two people. NVIDIA#2679 landed the temp-file fix from NVIDIAgh-2422 first, so this branch's parallel implementation is dropped in favor of the one on main: keeping both would have left two mechanisms writing a source file on every debug compile, with the NVRTC name deciding which one was actually used. Resolved by taking main's side for every overlapping file and removing _jit_source.py, leaving this branch identical to main. What remains of NVIDIAgh-2385 is handled in follow-up commits.
brandon-b-miller
added a commit
to brandon-b-miller/cuda-python
that referenced
this pull request
Aug 31, 2026
Redirecting the NVRTC program name at a temp .cu (NVIDIA#2679) left two problems. Quoted includes stopped resolving. NVRTC searches the directory of the name it is handed for #include "...", so moving that name into the temp dir moved the search with it, and merely enabling debug or lineinfo broke a compile that worked without it. The directory the name used to denote is now passed back as --include-path. It is added to the compile options only, never to ProgramOptions, so the program cache key is unchanged; the cwd was already an unkeyed input to these compiles before the redirect. Teardown deleted files it did not create. The name given to NVRTC doubled as the cleanup target, but that slot still holds the caller's options.name whenever the source was not redirected, so a name like "matmul.cu" matching a real file meant close() or collection deleted the caller's own source. The temp path is tracked separately now and is the only path unlinked. Removal on close() is left as it was, since NVIDIAgh-2422 asked for it and the tests added with NVIDIA#2679 assert it.
lijinf2
pushed a commit
that referenced
this pull request
Sep 1, 2026
…2678) * test and a narrowish fix * marker * switch to pyelftools so we dont require a new ctk component * fix(cuda.core): repair two regressions in the NVRTC debug source path Redirecting the NVRTC program name at a temp .cu (#2679) left two problems. Quoted includes stopped resolving. NVRTC searches the directory of the name it is handed for #include "...", so moving that name into the temp dir moved the search with it, and merely enabling debug or lineinfo broke a compile that worked without it. The directory the name used to denote is now passed back as --include-path. It is added to the compile options only, never to ProgramOptions, so the program cache key is unchanged; the cwd was already an unkeyed input to these compiles before the redirect. Teardown deleted files it did not create. The name given to NVRTC doubled as the cleanup target, but that slot still holds the caller's options.name whenever the source was not redirected, so a name like "matmul.cu" matching a real file meant close() or collection deleted the caller's own source. The temp path is tracked separately now and is the only path unlinked. Removal on close() is left as it was, since gh-2422 asked for it and the tests added with #2679 assert it. * address reviews
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 #2422
When
Programcompiles C++ withdebug=Trueorlineinfo=Trueand the callerdoes not pass
name=, NVRTC recorded the labeldefault_program. That pathdoes not exist on disk, so cuda-gdb reported
No such file or directory.This change writes the in-memory source to a unique temp file
(
caller_py__kernel_XXXXXXXX.cu,mkstemp, mode 0600) and passes that realpath to
nvrtcCreateProgram.ProgramOptions.nameis left unchanged so theprogram cache key is unaffected. An explicit
name=still wins. Writefailures fall back to the old label-only behavior. The temp file is removed
on
close()/ deallocation.No public API or signature changes.
Checklist