You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cuda.core: materialize NVRTC source to a real path when debug info is enabled #2422
When a user compiles a kernel via cuda.core.Program with debug=True or lineinfo=True, cuda-gdb cannot show source lines because the program name= defaults to the literal string "default_program" and no file with that name exists on disk. The debugger reports default_program:10 — No such file or directory and users lose source-level debugging.
This is tracked in NVBugs 6420444 (originally reported by Linaro). The customer was unblocked by a workaround: pass a real file path as name= and write the source there manually. We want this to work by default.
Proposed fix
When debug=True or lineinfo=True is set on Program(...):
Derive a meaningful filename from the caller's Python frame + a sanitized kernel identifier (e.g. train_py__matmul.cu).
Materialize the NVRTC source to a temp file at that path.
Pass that real path as NVRTC's name=.
Clean up the temp file on program destruction.
When neither debug flag is set, behavior is unchanged (no disk I/O, same label as today).
Impact on existing users
No API or signature changes.
Users who already pass name= explicitly: zero change (their value wins).
Users who don't request debug info: zero change (no temp file written).
Users who do request debug info: the label in cuda-gdb / traces / logs changes from default_program to a real path. Cosmetic; easily searchable.
Edge cases to handle
Read-only /tmp or sandboxed environments: fall back to today's label-only behavior on write failure, do not crash.
Concurrent compiles of the same-named kernel: use unique suffix (tempfile.mkstemp or PID+hash).
Respect TMPDIR; user-only permissions on the temp file.
Cleanup on both normal destruction and process exit.
Acceptance criteria
cuda-gdb shows source lines when stepping into a kernel compiled with debug=True, without any user-side workaround.
Existing behavior preserved when debug flags are off.
Graceful fallback when the filesystem isn't writable.
Program.__init__ (NVRTC): debug/lineinfo + default name → dump source to a temp .cu and pass that path to nvrtcCreateProgram. Explicit name= wins; ProgramOptions.name unchanged.
_try_materialize_nvrtc_debug_source / _cleanup_debug_source: mkstemp, fallback on write failure, unlink on close().
Tests — cuda_core/tests/test_program.py
test_nvrtc_debug_materializes_source_to_temp_file — debug off / explicit name= / debug on
Activity
lijinf2 commentedon Aug 21, 2026
Hi @rparolin — fix is in #2679.
options.nameObjectCode.name"default_program""default_program""default_program"name="/tmp/a.cu""/tmp/a.cu""/tmp/a.cu""/tmp/a.cu""default_program""/tmp/{caller}__{kernel}_xxx.cu""/tmp/{caller}__{kernel}_xxx.cu"Suggested review order:
Implementation —
cuda_core/cuda/core/_program.pyxProgram.__init__(NVRTC):debug/lineinfo+ defaultname→ dump source to a temp.cuand pass that path tonvrtcCreateProgram. Explicitname=wins;ProgramOptions.nameunchanged._try_materialize_nvrtc_debug_source/_cleanup_debug_source:mkstemp, fallback on write failure, unlink onclose().Tests —
cuda_core/tests/test_program.pytest_nvrtc_debug_materializes_source_to_temp_file— debug off / explicitname=/ debug ontest_nvrtc_debug_falls_back_when_tmp_not_writable— unwritable temptest_nvrtc_debug_concurrent_compile_uses_unique_temp_files— concurrent unique pathscuda-gdb — helper
cuda_core/tests/helpers/cuda_gdb_src.py+test_cuda_gdb_shows_nvrtc_debug_source_lines(skips if gdb/ptrace unavailable).Merge upstream/main into fix-program-debug, superseded by NVIDIA#2679
fix(cuda.core): repair two regressions in the NVRTC debug source path
fix(cuda.core): let cuda-gdb display source for JIT-compiled kernels (#…