Kernel validation with corrupted cache detection
Skill kjuhwa/skills-hub/skills/gpu-kernels/kernel-validation-with-corrupted-cache-detection
On JIT cache load, validate that every expected artifact (kernel.cu + kernel.cubin) is present and abort with an actionable 'rm -rf CACHE_PATH' error if not.From its SKILL.md
npx -y skills add kjuhwa/skills-hub --skill kernel-validation-with-corrupted-cache-detectionAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
2.4 KB, 435 tokens by cl100k_base, as published. Nobody here has run it
Kernel Validation With Corrupted-Cache Detection
What / Why
A JIT cache with an empty entry (compilation interrupted, SIGKILL, out-of-disk) is worse than no cache: the load path silently succeeds with garbage and fails deep in cuModuleLoad with an opaque error. Validate the cache-directory contents before trying to use them, and fail fast with a message that tells the user exactly how to recover.
Procedure
- Define expected artifacts per compile path:
- NVCC path:
kernel.cu,kernel.cubin(plus optionalkernel.ptx). - NVRTC path:
kernel.cu,kernel.cubinfrom in-memory compile.
- NVCC path:
- Validate at load.
static bool check_validity(const std::filesystem::path& dir) { if (!std::filesystem::exists(dir)) return false; if (!std::filesystem::exists(dir / "kernel.cu")) return false; if (!std::filesystem::exists(dir / "kernel.cubin")) return false; return true; } - On validation failure inside the runtime constructor (not check_validity, which just returns bool): abort with a specific message:
Corrupted JIT cache directory (missing kernel.cu or kernel.cubin): <path>, please run `rm -rf <path>` and restart your task. - Fast-path hit uses check_validity to decide whether to skip the compile; this also means a half-populated dir forces recompilation, healing itself.
Key design points
- Include the directory path in the error — grep-able and directly actionable.
- Point to
rm -rfexplicitly; don't make the user guess whether it's safe to delete. - Don't auto-delete corrupt caches without user confirmation — a disk fault could mask a deeper issue.
References
csrc/jit/kernel_runtime.hpp—KernelRuntime::check_validityand the assert site.
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.