cuda-kernels

cuda-kernels is a skill for Claude Code from huggingface/kernels. It costs 120 tokens per session (7,419 once invoked), scanned A, original, Apache-2.0.

A guide to writing and benchmarking custom CUDA kernels for NVIDIA GPUs used with Hugging Face tools for machine-learning models. CUDA kernels are GPU functions that perform a focused computation.

In plain words
What is it for?
Use it when developing or benchmarking GPU code for NVIDIA H100, A100, or T4 hardware with Hugging Face diffusers or transformers, including models such as Stable Diffusion and LTX-Video.
Why use it?
It helps avoid build patterns that are incompatible with the required limited Python interface and the project’s kernel packaging rules.

Skill for Claude Code ✓ vendor

Written for Claude Code: allowed-tools in frontmatter. Also seen: reads .claude/ paths.

Good fit Use it when developing or benchmarking GPU code for NVIDIA H100, A100, or T4 hardware with Hugging Face diffusers or transformers, including models such as Stable Diffusion and LTX-Video.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/huggingface/kernels/cuda-kernels
About the project

Hugging Face Kernels is a system that lets Python libraries and applications load compute kernels directly from the Hugging Face Hub. It is used by Python and PyTorch developers who need portable kernels that can support multiple versions and build configurations. The catalogue skills help agents work with the kernels system and its kernel-building tools.

huggingface/kernels · 776 stars · on GitHub · huggingface.co

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add huggingface/kernels --skill cuda-kernels
Clone the repo
git clone --depth 1 https://github.com/huggingface/kernels

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for cuda-kernels

README.md
[![agentmods](https://agentmods.dev/badge/skills/huggingface/kernels/cuda-kernels/github.svg)](https://agentmods.dev/skills/huggingface/kernels/cuda-kernels)
Your own site
<a href="https://agentmods.dev/skills/huggingface/kernels/cuda-kernels"><img src="https://agentmods.dev/badge/skills/huggingface/kernels/cuda-kernels/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for cuda-kernels

Your own site · 80×15
<a href="https://agentmods.dev/skills/huggingface/kernels/cuda-kernels"><img src="https://agentmods.dev/badge/skills/huggingface/kernels/cuda-kernels.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 120 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 7,419 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00120 $0.07419
Opus 5.5 $0.00048 $0.02968
Sonnet 5.5 $0.00024 $0.01484
Haiku 4.5 $0.00012 $0.00742

Measured 1mo ago against content hash fba19d37df83, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

cuda-kernels scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

The scan reads SKILL.md. This mod also ships 5 executable files (scripts/benchmark_example.py, scripts/benchmark_rmsnorm.py, scripts/huggingface_kernels_example.py, …), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

kernel-builder/skills/cuda-kernels/SKILL.md · 664 lines

How it starts

The opening of the file, as written. The whole thing — 664 lines — stays where its author put it; the contents beside it link to each section on GitHub.

CUDA Kernels for Diffusers & Transformers

This skill provides patterns and guidance for developing optimized CUDA kernels targeting NVIDIA GPUs (H100, A100, T4) for use with HuggingFace diffusers and transformers libraries.

Hard Constraints — Read Before Writing Any Code

Kernels MUST build with kernel-builder and meet the Kernel Hub requirements. kernel-builder compiles against the Python limited API (ABI3) so a single binary works for Python 3.9+ across versions. Several patterns that are standard in generic PyTorch-extension tutorials are therefore hard build failures here. Do not use them, even if PyTorch documentation or your training data suggests them.

Disallowed patterns — never generate these

❌ Never use Why it fails ✅ Use instead
pybind11 in any form: #include <torch/extension.h>, #include <pybind11/...>, PYBIND11_MODULE(...), py::arg, any py:: symbol pybind11 is incompatible with the limited API (ABI3); the build does not compile TORCH_LIBRARY_EXPAND in torch-ext/torch_binding.cpp (see below). Note: torch/extension.h transitively includes pybind11 — include torch/torch.h + torch/library.h instead
Hand-written setup.py / pyproject.toml using torch.utils.cpp_extension (CUDAExtension, BuildExtension, cpp_extension.load, load_inline) setuptools extensions are not ABI3 and bypass build.toml; kernel-builder owns the build build.toml + nix run .#build-and-copy -L. For an editable dev install, generate the project files with kernel-builder create-pyproject -f — never write them by hand
TORCH_LIBRARY(my_kernel, m), TORCH_LIBRARY_FRAGMENT(...), or TORCH_LIBRARY_IMPL(...) with a hardcoded namespace kernel-builder suffixes the op namespace with a per-build hash (e.g. _my_kernel_a1b2c3d); a hardcoded name never resolves TORCH_LIBRARY_EXPAND(TORCH_EXTENSION_NAME, ops) from the generated registration.h
Hardcoded torch.ops.my_kernel.fn(...) calls in Python Same namespace mangling — the op namespace name is only known at build time from ._ops import ops then ops.fn(...)
Hand-written PyMODINIT_FUNC PyInit__... or any manual CPython module init Generated by REGISTER_EXTENSION; duplicating it breaks module loading REGISTER_EXTENSION(TORCH_EXTENSION_NAME) exactly once, in torch_binding.cpp
Non-limited CPython API calls (PyArg_ParseTuple, direct PyObject* manipulation) Violates ABI3 Stay within the torch C++ API: torch::Tensor, TORCH_CHECK, at::cuda::*
Absolute imports of your own package inside torch-ext/ (from my_kernel.utils import x) The package directory is renamed when loaded from the Hub; absolute imports break Relative imports only: from .utils import x, from ._ops import ops
Runtime Python deps beyond torch (and einops if truly needed) Hub compliance restricts kernel dependencies; imports of numpy, triton, packaging, etc. are rejected Standard library + torch only
Python-side @torch.library.custom_op as the primary binding The op must be registered in C++ so it ships in the compiled extension C++ registration via TORCH_LIBRARY_EXPAND; Python-side torch.library.register_fake is only for adding a fake/meta impl (see torch.compile section)

Read the full file on GitHub · 664 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 664 lines · 120 tokens per session scan A fba19d37df83

Subscribe to this mod's changes

cuda-kernels is a skill published in the GitHub repository huggingface/kernels (776 stars, last pushed today), licensed Apache-2.0. It adds 120 tokens to every session and 7,419 once invoked, about $0.0005 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.