[BUG]: Program.compile(cache=...) returns another directory's binary when the source has a quoted #include
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
Start with make_program_cache_key and the tests in test_program_cache.py; trace how quoted includes and extra_digest affect cache keys, including the debug and lineinfo path that adds the working directory as an include path. Then review test_program_compile_cache.py and run the reported cases with and without caching. Done means the cache cannot return a binary compiled against another working directory's header, while source without quoted includes remains unaffected.
由索引模型根據 Issue 內容生成。
描述
For a name without a directory component (the default "default_program"), NVRTC resolves #include "x.h" against the current working directory. make_program_cache_key does not account for that header. The docstring of test_make_program_cache_key_accepts_nvrtc_name_without_dir_component says relative includes don't reach outside the in-memory program, but they do. So two projects that compile the same kernel text through the default FileStreamProgramCache() (shared per user) can get each other's binaries.
The #1912 review raised this case. The guard was scoped to names with a directory component on the premise that the working directory is "the same search root every NVRTC compile sees". But the default cache is per user and outlives any one working directory, so that premise does not hold.
Repro (cuda-core 1.2.2 wheel and a main 303fbdac source build, NVRTC 13.5, x86_64 Linux, compile only):
# run once in dir A with val.h = "#define VAL 111", then in dir B with "#define VAL 222"
import sys
from cuda.core import Program, ProgramOptions
from cuda.core.utils import FileStreamProgramCache
src = '#include "val.h"\nextern "C" __global__ void k(int *p){ *p = VAL; }\n'
for cache in (None, FileStreamProgramCache(sys.argv[1])):
obj = Program(src, "c++", options=ProgramOptions(arch="sm_90")).compile("ptx", cache=cache)
print([l.strip() for l in bytes(obj.code).decode().splitlines() if "mov.u32" in l])
Results:
- Dir A: 111 both uncached and cached.
- Dir B: 222 uncached, but 111 cached.
- Same result in a single process when
val.his edited between two cached compiles.
debug=True / lineinfo=True hit the same problem through a second path. For default_program, Program adds --include-path=<cwd>, which is not part of the key, so even <val.h> and no_source_include=True resolve from the working directory there.
Possible fix, mirroring the existing directory-component guard: make_program_cache_key raises ValueError for NVRTC source containing a quoted #include when there is no extra_digest. no_source_include=True is accepted, except for that debug/lineinfo case. Source without quoted includes is unaffected. I have this with unit tests in test_program_cache.py and an integration test in test_program_compile_cache.py: they fail before (5 tests) and pass after. The rest of both files has the same results before and after; I ran them without a GPU, so the 3 GPU tests were not exercised. I can share the patch if that direction is acceptable.
- 主要語言
- Cython
- 星號
- 3.4k
- 分支
- 353
- 平均合併
- 2 天 3 小時
- 30 天內合併 PR
- 163
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
NVIDIA/cuda-python 的其他 Issue
-
[BUG]: the `__cuda_stream__` deprecation warning points to `Stream(obj)`, which always raises可能已有人在做 @Iamsohungrynow 於 5 天前認領。 未關閉bug cuda.core P1
難度 1/5 1 小時以內 新手友好度 86/100
NVIDIA/cuda-python#3505 · 3 則留言 · 1 個 reaction · 已指派 1 人 ·
維護者通常 1 天內回覆
-
[BUG]: ProcessInfo.used_gpu_memory returns the NVML_VALUE_NOT_AVAILABLE sentinel as a byte count未關閉triage
難度 2/5 1-3 小時 新手友好度 80/100
NVIDIA/cuda-python#3468 · 3 則留言 ·
維護者通常 1 天內回覆
-
triage
難度 2/5 1-3 小時 新手友好度 68/100
NVIDIA/cuda-python#3409 ·
維護者通常 1 天內回覆
-
[BUG]: cleanup-pr-previews never removes previews of deleted PRs可能重新可做 @rwgk 於 48 天前認領,目前沒有進行中的 PR。 未關閉
難度 2/5 1-3 小時 新手友好度 84/100
NVIDIA/cuda-python#2952 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
[BUG]: LocatedHeaderDir is mutable, so callers can poison the cached header-directory lookup可能已有人在做 @rwgk 於 62 天前認領。 未關閉triage
難度 2/5 1-3 小時 新手友好度 82/100
NVIDIA/cuda-python#2646 · 1 個 reaction ·
維護者通常 1 天內回覆
查看 NVIDIA/cuda-python 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 72/100
vllm-project/vllm#70030 ·
維護者通常 1 天內回覆
-
help wanted small extra
難度 2/5 1-3 小時 新手友好度 70/100
維護者通常 1 天內回覆
-
t: bug
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 3 天內回覆
-
Retry an empty final answer when Gemini reports MALFORMED_RESPONSE (gemini-4-hydrogen)可能已有人在做 @waleedkadous 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 62/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 66/100
維護者通常 1 天內回覆