[BUG]: Program.compile(cache=...) returns another directory's binary when the source has a quoted #include
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 45/100
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- Cython
- Estrelas
- 3.4k
- Forks
- 353
- Merge médio
- 2d 3h
- PRs com merge (30d)
- 163
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de NVIDIA/cuda-python
-
[BUG]: the `__cuda_stream__` deprecation warning points to `Stream(obj)`, which always raisesTalvez já em andamento @Iamsohungrynow assumiu há 5 dias. Abertabug cuda.core P1
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 86/100
NVIDIA/cuda-python#3505 · 3 comentários · 1 reação · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
[BUG]: ProcessInfo.used_gpu_memory returns the NVML_VALUE_NOT_AVAILABLE sentinel as a byte countAbertatriage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 80/100
NVIDIA/cuda-python#3468 · 3 comentários ·
Mantenedores costumam responder em até 1 dia
-
triage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
NVIDIA/cuda-python#3409 ·
Mantenedores costumam responder em até 1 dia
-
[BUG]: cleanup-pr-previews never removes previews of deleted PRsTalvez livre de novo @rwgk assumiu há 48 dias e não há nenhum pull request aberto. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
NVIDIA/cuda-python#2952 · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
[BUG]: LocatedHeaderDir is mutable, so callers can poison the cached header-directory lookupTalvez já em andamento @rwgk assumiu há 62 dias. Abertatriage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
NVIDIA/cuda-python#2646 · 1 reação ·
Mantenedores costumam responder em até 1 dia
Todas as issues de NVIDIA/cuda-python
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
vllm-project/vllm#70030 ·
Mantenedores costumam responder em até 1 dia
-
help wanted small extra
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
Mantenedores costumam responder em até 1 dia
-
t: bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 3 dias
-
Retry an empty final answer when Gemini reports MALFORMED_RESPONSE (gemini-4-hydrogen)Talvez já em andamento @waleedkadous assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
iaser-ai/ansari#444 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 66/100
Mantenedores costumam responder em até 1 dia