write-triton-fused-add-rmsnorm-kernel

write-triton-fused-add-rmsnorm-kernel is a skill for Claude Code, Codex from tensormux/kernel-skills. It costs 0 tokens per session (4,262 once invoked), scanned A, original, MIT.

A guide for writing a Triton GPU kernel that adds a transformer residual, applies RMSNorm, and saves the summed result for the next block. Triton is a language for writing custom GPU operations; RMSNorm is a common way to scale neural-network values.

In plain words
What is it for?
Use it when implementing or optimizing LLaMA-, Mistral-, Qwen-, Gemma-, or similar decoder models and their residual-plus-normalization steps.
Why use it?
It combines two operations that would otherwise read and write the same data separately, which can reduce memory traffic and kernel launches in transformer inference.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when implementing or optimizing LLaMA-, Mistral-, Qwen-, Gemma-, or similar decoder models and their residual-plus-normalization steps.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/tensormux/kernel-skills/write-triton-fused-add-rmsnorm-kernel
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 tensormux/kernel-skills --skill write-triton-fused-add-rmsnorm-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-triton-fused-add-rmsnorm-kernel

README.md
[![agentmods](https://agentmods.dev/badge/skills/tensormux/kernel-skills/write-triton-fused-add-rmsnorm-kernel/github.svg)](https://agentmods.dev/skills/tensormux/kernel-skills/write-triton-fused-add-rmsnorm-kernel)
Your own site
<a href="https://agentmods.dev/skills/tensormux/kernel-skills/write-triton-fused-add-rmsnorm-kernel"><img src="https://agentmods.dev/badge/skills/tensormux/kernel-skills/write-triton-fused-add-rmsnorm-kernel/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 write-triton-fused-add-rmsnorm-kernel

Your own site · 80×15
<a href="https://agentmods.dev/skills/tensormux/kernel-skills/write-triton-fused-add-rmsnorm-kernel"><img src="https://agentmods.dev/badge/skills/tensormux/kernel-skills/write-triton-fused-add-rmsnorm-kernel.svg" alt="Reviewed on agentmods" width="80" 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 4,262 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.
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.00000 $0.04262
Opus 5.5 $0.00000 $0.01705
Sonnet 5.5 $0.00000 $0.00852
Haiku 4.5 $0.00000 $0.00426

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

Security

Grade A, and why

write-triton-fused-add-rmsnorm-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 2mo 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/inference/write-triton-fused-add-rmsnorm-kernel/SKILL.md · 190 lines

How it starts

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

Skill: Write a Triton Fused Add+RMSNorm Kernel

Purpose

Guide the agent through implementing a single Triton kernel that computes y = rmsnorm(x + residual) while also writing back x + residual for the next transformer block's residual stream. This fusion is the dominant pattern in LLaMA, Mistral, Qwen, and similar decoder blocks: every attention sub-block and every MLP sub-block ends with residual_add -> rmsnorm. Done correctly, the kernel saves one full read+write pass over the activation tensor compared to a naive add kernel followed by an rmsnorm kernel, and removes one launch.


Use this when

  • You are implementing a transformer inference path (LLaMA-family, Mistral, Qwen, Gemma, DeepSeek, etc.) and the block structure is h = x + residual; out = rmsnorm(h) with h becoming the residual into the next block.
  • Profiling shows the unfused add and rmsnorm kernels each touching the full activation tensor and the pipeline is HBM-bandwidth bound.
  • You need a custom Triton implementation because the framework path (PyTorch eager, vendor library) does not fuse these two ops, or torch.compile is unavailable, partial, or breaks the graph.
  • You are matching the kernel surface of vLLM (fused_add_rms_norm), FlashInfer, or Liger-Kernel and need a Triton equivalent.
  • You want to keep the residual write as part of the same kernel pass to avoid an extra launch and an extra read of x in the next block.

Do not use this when

  • The next operation is itself fusable with the normalization output (e.g., RMSNorm immediately followed by a QKV projection where the matmul's loader can ingest unnormalized values from the epilogue of a previous kernel). Prefer a larger fused block over a chain of small ones.
  • Hidden dimension is small (< 512). The kernel is launch-overhead bound at that size, and a generic add + framework rmsnorm is fine — the saved bandwidth is dwarfed by launch latency.
  • Training is required and you have not designed a backward that handles gradients through both the add and the norm. Forward fusion is straightforward; backward fusion is materially harder (see Common failure modes).
  • Mean subtraction is needed (LayerNorm, not RMSNorm). Use the standard Triton LayerNorm skill instead — RMSNorm omits the mean.
  • The residual is on a different dtype, layout, or device than x. Resolve the layout mismatch before fusing.

Read the full file on GitHub · 190 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. 2mo ago First seen · 190 lines · 0 tokens per session scan A d74da83f81ca

Subscribe to this mod's changes

write-triton-fused-add-rmsnorm-kernel is a skill published in the GitHub repository tensormux/kernel-skills (89 stars, last pushed 4mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 4,262 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

write-triton-fused-add-rmsnorm-kernel compared with skills from other repositories

write-triton-fused-add-rmsnorm-kernel next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
write-triton-fused-add-rmsnorm-kerneltensormux/kernel-skillsSkill894mo agoMITA0Claude Code, Codex
prompt-engineeringMagicKidd/Rokid-agentic-workflowSkill34mo agononeA0Claude Code, Codex
sglang-diffusion-cache-ditsgl-project/sglangSkill39ktodayApache-2.0A161Claude Code
recon-ai-enrichmentsamugit83/redamonSkill3.3kyesterdayMITA188Claude Code, Codex
pgvector-semantic-searchtimescale/pg-aiguideSkill1.9k3d agoApache-2.0A190Cursor
postgres-hybrid-text-searchtimescale/pg-aiguideSkill1.9k3d agoApache-2.0A162Cursor
building-agentsericrisco/rsc-harnessSkill5032d agoMITA85Claude Code, Codex