write-cuda-softmax-kernel

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

Guidance for designing and implementing a custom CUDA softmax kernel. Softmax turns a group of numbers into values that add up to one, often for attention in machine-learning models.

In plain words
What is it for?
Building stable softmax kernels, masked softmax, row-parallel GPU work, and softmax fused with attention operations.
Why use it?
It helps address cases where standard library softmax does not fit the data layout, masking needs, precision requirements, or performance target.

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-softmax-kernel
Any agent
npx skills add tensormux/kernel-skills --skill write-cuda-softmax-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-softmax-kernel

README.md
[![agentmods](https://agentmods.dev/badge/skills/tensormux/kernel-skills/write-cuda-softmax-kernel.svg)](https://agentmods.dev/skills/tensormux/kernel-skills/write-cuda-softmax-kernel)
Your own site
<a href="https://agentmods.dev/skills/tensormux/kernel-skills/write-cuda-softmax-kernel"><img src="https://agentmods.dev/badge/skills/tensormux/kernel-skills/write-cuda-softmax-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,690 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.03690
Opus 5 $0.00000 $0.01845
Sonnet 5 $0.00000 $0.00738
Haiku 4.5 $0.00000 $0.00369

Measured 4d ago against content hash 75a385153654, 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-softmax-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 4d 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-softmax-kernel/SKILL.md · 113 lines

How it starts

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

Skill: Write CUDA Softmax Kernel

Purpose

Guide the agent through designing and implementing a correct, numerically stable CUDA softmax kernel, covering online (single-pass) computation, row-parallel decomposition, warp-level reductions, fp16/bf16 precision pitfalls, masked softmax variants, and when to fuse with attention versus implementing standalone.

Use this when

  • You need softmax along the last dimension of a 2D or 3D tensor and need a custom kernel for fusion or layout reasons
  • You are implementing masked softmax (e.g., causal attention mask, padding mask) where the mask pattern is not supported by existing library routines
  • You need to fuse softmax with the subsequent matrix multiply in an attention kernel (flash attention pattern) to avoid materializing the full attention score matrix
  • You are targeting a specific hardware or latency budget where you need to control the decomposition precisely
  • The input shape (sequence length, number of heads) does not match the assumptions of available library softmax implementations

Do not use this when

  • Standard softmax on well-shaped inputs with no custom masking: cuDNN cudnnSoftmaxForward and cudnnSoftmaxBackward are highly optimized for common attention shapes
  • The softmax is part of a standard multi-head attention block: use FlashAttention-2 (or equivalent) which fuses QK^T, softmax, and AV into a single tiled kernel with O(seq_len) memory instead of O(seq_len^2)
  • The sequence dimension is very small (< 32): the warp reduction overhead is not worth it; a simple sequential kernel or even a CPU-side computation may be appropriate

Inputs the agent should gather first

  • Input shape: exact dimensions — e.g., [batch, heads, seq_len] for attention scores, or [N, D] for a 2D input. Which axis is the softmax axis (almost always the last dimension)?
  • Dtype: fp32, fp16, or bf16 for input and output; whether the accumulator (for exp sum and max) must be fp32 regardless of input dtype
  • Masking requirements: is there an additive mask (e.g., -inf for invalid positions), a boolean mask, or no masking? Is the mask shape the same as the input or broadcast?
  • Downstream operation: is the softmax output consumed by another matrix multiply (attention pattern), or written to memory for a standalone use?
  • Sequence length: is it fixed or variable at runtime? Variable lengths require either padding to a max length or a segmented/jagged dispatch
  • Hardware target: SM architecture, to determine warp size, available reduction primitives, and shared memory capacity

Read the full file on GitHub · 113 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. 4d ago First seen · 113 lines · 0 tokens per session scan A 75a385153654

Subscribe to this mod's changes

write-cuda-softmax-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,690 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.

Related

Other skills, from other repositories

design-impl-audit

The Design-vs-Implementation Audit Copilot. A universal skill for any project, any language, any design document. Before work starts, it reminds engineers what must be delivered; after code lands, it checks what was actually delivered, what drifted, and what silently went beyond the design. Feed it a design doc plus a…

MagicKidd/Rokid-agentic-workflow · 0 tokens

skill-creator

Guide for creating effective skills. This skill should be used when users want to create a new skill (or update an existing skill) that extends Claude's capabilities with specialized knowledge, workflows, or tool integrations.

MagicKidd/Rokid-agentic-workflow · 45 tokens

diagnose

Disciplined diagnosis loop for hard bugs and performance regressions. Reproduce → minimise → hypothesise → instrument → fix → regression-test. Use when user says "diagnose this" / "debug this", reports a bug, says something is broken/throwing/failing, or describes a performance regression.

MagicKidd/Rokid-agentic-workflow · 66 tokens

prompt-engineering

Prompt engineering techniques and patterns. Use when writing agent commands, hooks, skills, subagent prompts, or any LLM interaction: optimizing prompts, improving output reliability, and designing production-grade prompt templates. Trigger words: prompt engineering, prompt, prompt optimization, LLM interaction.

MagicKidd/Rokid-agentic-workflow · 0 tokens

setup-matt-pocock-skills

Sets up an ## Agent skills block in AGENTS.md/CLAUDE.md and docs/agents/ so the engineering skills know this repo's issue tracker (GitHub or local markdown), triage label vocabulary, and domain doc layout. Run before first use of to-issues, to-prd, triage, diagnose, tdd, improve-codebase-architecture, or zoom-out — or…

MagicKidd/Rokid-agentic-workflow · 124 tokens

brainstorming

Brainstorming design process. Must be used before any creative work - creating features, building components, adding functionality, or modifying behavior. Transforms ideas into complete designs and specifications through collaborative dialogue. Trigger words: brainstorm, design discussion, requirement analysis…

MagicKidd/Rokid-agentic-workflow · 0 tokens