[BUG]: Program.compile(cache=...) returns another directory's binary when the source has a quoted #include
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 45/100
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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.
- Langage dominant
- Cython
- Étoiles
- 3.4k
- Forks
- 353
- Merge moyen
- 2 j 3 h
- PR mergées (30 j)
- 163
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de NVIDIA/cuda-python
-
[BUG]: the `__cuda_stream__` deprecation warning points to `Stream(obj)`, which always raisesPeut-être pris @Iamsohungrynow l’a pris il y a 5 jours. Ouvertebug cuda.core P1
Difficulté 1/5 Moins d'une heure Accessibilité débutants 86/100
NVIDIA/cuda-python#3505 · 3 commentaires · 1 réaction · 1 personne assignée ·
Les mainteneurs répondent en général sous 1 jour
-
[BUG]: ProcessInfo.used_gpu_memory returns the NVML_VALUE_NOT_AVAILABLE sentinel as a byte countOuvertetriage
Difficulté 2/5 1-3 heures Accessibilité débutants 80/100
NVIDIA/cuda-python#3468 · 3 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
triage
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
NVIDIA/cuda-python#3409 ·
Les mainteneurs répondent en général sous 1 jour
-
[BUG]: cleanup-pr-previews never removes previews of deleted PRsPeut-être à nouveau libre @rwgk l’a pris il y a 48 jours, et aucune pull request n’est ouverte. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
NVIDIA/cuda-python#2952 · 1 personne assignée ·
Les mainteneurs répondent en général sous 1 jour
-
[BUG]: LocatedHeaderDir is mutable, so callers can poison the cached header-directory lookupPeut-être pris @rwgk l’a pris il y a 62 jours. Ouvertetriage
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
NVIDIA/cuda-python#2646 · 1 réaction ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de NVIDIA/cuda-python
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
vllm-project/vllm#70030 ·
Les mainteneurs répondent en général sous 1 jour
-
help wanted small extra
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
Les mainteneurs répondent en général sous 1 jour
-
t: bug
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 3 jours
-
Retry an empty final answer when Gemini reports MALFORMED_RESPONSE (gemini-4-hydrogen)Peut-être pris @waleedkadous l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
iaser-ai/ansari#444 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 66/100
Les mainteneurs répondent en général sous 1 jour