agentsclimarketplace

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

Install
npx -y skills add kjuhwa/skills-hub --skill kernel-validation-with-corrupted-cache-detection

Assembled 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

  1. Define expected artifacts per compile path:
    • NVCC path: kernel.cu, kernel.cubin (plus optional kernel.ptx).
    • NVRTC path: kernel.cu, kernel.cubin from in-memory compile.
  2. 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;
    }
    
  3. 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.
    
  4. 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 -rf explicitly; 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.hppKernelRuntime::check_validity and the assert site.

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 326,835. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.