write-cuda-gemm-kernel

write-cuda-gemm-kernel is a skill for Claude Code, Codex from tensormux/kernel-skills. It costs 0 tokens per session (3,543 once invoked), scanned A, original, MIT.

A guide for designing and implementing a custom CUDA GPU kernel for GEMM, the matrix-multiplication operation C = alpha × A × B + beta × C.

In plain words
What is it for?
Use it for unusual matrix-multiplication layouts, fused operations, irregular batches, sparse masks, constrained hardware, or learning and research kernels.
Why use it?
It helps decide when a custom GPU implementation is justified and how to balance correctness, memory access, tiling, tensor cores, and existing libraries such as cuBLAS or CUTLASS.

Skill for Claude CodeCodex

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.

agentmods
npx agentmods add skills/tensormux/kernel-skills/write-cuda-gemm-kernel
Any agent
npx skills add tensormux/kernel-skills --skill write-cuda-gemm-kernel
Clone the repo
git clone --depth 1 https://github.com/tensormux/kernel-skills

Made for: Claude Code, Codex.

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 write-cuda-gemm-kernel

README.md
[![agentmods](https://agentmods.dev/badge/skills/tensormux/kernel-skills/write-cuda-gemm-kernel.svg)](https://agentmods.dev/skills/tensormux/kernel-skills/write-cuda-gemm-kernel)
Your own site
<a href="https://agentmods.dev/skills/tensormux/kernel-skills/write-cuda-gemm-kernel"><img src="https://agentmods.dev/badge/skills/tensormux/kernel-skills/write-cuda-gemm-kernel.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,543 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00000 $0.03543
Opus 5 $0.00000 $0.01772
Sonnet 5 $0.00000 $0.00709
Haiku 4.5 $0.00000 $0.00354

Measured 5d ago against content hash b812844ae7f3, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

write-cuda-gemm-kernel 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 5d ago.

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.

skills/cuda/write-cuda-gemm-kernel/SKILL.md · 122 lines

How it starts

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

Skill: Write CUDA GEMM Kernel

Purpose

Guide the agent through designing and implementing a correct, performance-aware CUDA GEMM kernel (C = alpha * A * B + beta * C) for a specific problem configuration, including decisions about tiling strategy, memory hierarchy usage, tensor core eligibility, and when to defer to cuBLAS or CUTLASS instead.

Use this when

  • You need a custom GEMM or GEMM-like operation that cuBLAS does not support (fused epilogue, custom accumulation, non-standard layouts, sparse masks)
  • You are implementing a batched GEMM variant with irregular batch structure
  • You need to fuse the GEMM with a downstream operation (bias add, activation, quantization) and cannot tolerate the memory round-trip of a separate kernel
  • You are on a constrained embedded or inference target where you control the tiling strategy precisely
  • You are building a learning or research kernel and need explicit control over every memory access

Do not use this when

  • Standard sgemm/hgemm/dgemm without custom epilogue: use cuBLAS (cublasGemmEx) — it will outperform any first-attempt custom kernel on all shipping hardware
  • GEMM with tensor core acceleration and standard epilogues: use CUTLASS — it exposes MMA-level tiling with a composable epilogue framework that is already highly tuned
  • Batch GEMM with fixed batch sizes and standard shapes: use cublasGemmStridedBatchedEx
  • FP8 GEMM on Hopper: use cublasLtMatmul with FP8 descriptors or CUTLASS 3.x FP8 kernels
  • The problem is memory-bound rather than compute-bound (small K relative to M and N): tiling will not help, and a simpler kernel may be better

Inputs the agent should gather first

  • M, N, K: exact or typical sizes; whether they are statically known or runtime-dynamic
  • dtypes: A dtype, B dtype, accumulator dtype, output C dtype (e.g., A=fp16, B=fp16, acc=fp32, C=fp16)
  • Layout of A and B: row-major or column-major; leading dimension stride if non-standard
  • Transpose flags: transA, transB (determines which dimension is the inner product dimension)
  • Hardware target: SM architecture (SM70/Volta, SM75/Turing, SM80/Ampere, SM89/Ada, SM90/Hopper) — determines warp MMA availability, shared memory capacity, async copy support
  • Precision requirements: is fp32 accumulation required for fp16 inputs, or is fp16 accumulation acceptable
  • Epilogue requirements: is there an alpha/beta scaling, bias addition, activation function, quantization step, or other per-element operation to fuse
  • Batch dimension: is this a single GEMM or batched; are batch strides uniform
  • Tensor core eligibility: does the problem shape and dtype satisfy alignment requirements (K divisible by 8 for fp16 wmma, 16 for MMA with specific fragment sizes)

Read the full file on GitHub · 122 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 5d ago First seen · 122 lines · 0 tokens per session scan A b812844ae7f3

Subscribe to this mod's changes

write-cuda-gemm-kernel is a skill published in the GitHub repository tensormux/kernel-skills (73 stars, last pushed 2mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 3,543 tokens. 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.