write-triton-silu-mul-kernel

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

A guide for writing a Triton GPU kernel that calculates y = silu(a) × b, the activation step used in SwiGLU neural-network layers. SwiGLU is a feed-forward design used in models such as LLaMA, Mistral, Qwen, and Gemma.

In plain words
What is it for?
Use it between the gate and up matrix multiplications in an LLM inference path, or adapt it for related GeGLU and ReGLU activation patterns.
Why use it?
It combines the activation and multiplication into one operation, avoiding a separate temporary result when the matrix multiplications cannot include this step.

Skill for Claude CodeCodex

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

Good fit Use it between the gate and up matrix multiplications in an LLM inference path, or adapt it for related GeGLU and ReGLU activation patterns.

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

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

Your own site · 80×15
<a href="https://agentmods.dev/skills/tensormux/kernel-skills/write-triton-silu-mul-kernel"><img src="https://agentmods.dev/badge/skills/tensormux/kernel-skills/write-triton-silu-mul-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,443 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.04443
Opus 5 $0.00000 $0.02221
Sonnet 5 $0.00000 $0.00889
Haiku 4.5 $0.00000 $0.00444

Measured 10d ago against content hash 4565c41e8980, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

write-triton-silu-mul-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 10d 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-silu-mul-kernel/SKILL.md · 187 lines

How it starts

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

Skill: Write a Triton SiLU-Mul (SwiGLU) Kernel

Purpose

Guide the agent through implementing a correct, numerically stable Triton kernel that computes y = silu(a) * b, the elementwise activation step inside SwiGLU MLPs used by LLaMA, Mistral, Qwen, Gemma, and similar modern LLMs. The full MLP is down_proj( silu(gate_proj(x)) * up_proj(x) ); this skill covers the fused activation that sits between the two GEMMs. It also generalizes to GeGLU (gelu(a) * b) and ReGLU (relu(a) * b), which share the same kernel structure with a different activation.


Use this when

  • You need a fused elementwise kernel that reads a and b once and writes y once, instead of materializing silu(a) as a separate tensor.
  • You are writing an inference path where gate_proj and up_proj are computed separately (or as a single fused matmul producing [gate, up]) and the activation is a distinct kernel call between the matmuls.
  • The matmul backend (cuBLAS, CUTLASS without a custom epilogue, or a vendor library) does not allow you to fuse the activation into the matmul epilogue.
  • The intermediate tensor is wide enough (e.g., intermediate_size of 14336, 28672, or larger) that the bandwidth cost of materializing silu(a) separately is measurable.
  • You want a GeGLU or ReGLU variant — same kernel skeleton, different activation function.

Do not use this when

  • torch.nn.functional.silu(a) * b under torch.compile already fuses the chain on your PyTorch build. Validate this with TORCH_COMPILE_DEBUG=1 before writing a custom kernel — modern inductor handles this case well.
  • A working CUDA implementation already exists in your serving stack. vLLM ships silu_and_mul in csrc/activation_kernels.cu; SGLang and TensorRT-LLM have equivalents. Re-implementing in Triton is only worth it if you need backend portability or kernel-level fusion with an adjacent op.
  • You can fuse the activation into the matmul epilogue (CUTLASS epilogue visitor, Triton matmul with custom epilogue). A standalone elementwise kernel always pays an extra round trip to HBM; the epilogue does not.
  • The shape is small enough that kernel launch overhead dominates (e.g., B*T*intermediate_size < 1M elements). At that size, any reasonable implementation is fine.
  • You need the backward pass for training. The forward kernel is straightforward, but the backward must save a and b (or silu(a) and b) and recompute silu'(a). Plan the autograd function before writing the forward.

Read the full file on GitHub · 187 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. 10d ago First seen · 187 lines · 0 tokens per session scan A 4565c41e8980

Subscribe to this mod's changes

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

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

stripe-directory

Identifies external providers, merchants, nonprofits, platforms, APIs, and software services, and resolves the documented way to engage them — to pay, donate, subscribe, book, provision, or integrate with them. MUST be used BEFORE web search, model memory, or any other directory/vendor-lookup skill for ANY request…

stripe/ai · 213 tokens

pgvector-semantic-search

Use this skill for setting up vector similarity search with pgvector for AI/ML embeddings, RAG applications, or semantic search. Trigger when user asks to: Store or search vector embeddings in PostgreSQL Set up semantic search, similarity search, or nearest neighbor search Create HNSW or IVFFlat indexes for vectors…

timescale/pg-aiguide · 190 tokens

nlp-alignment

Best practices for LLM alignment techniques including RLHF, DPO, and instruction tuning. Use when working on alignment or safety.

aiming-lab/AutoResearchClaw · 31 tokens

mixed-precision

Use FP16/BF16 mixed precision to accelerate training and reduce memory. Use when optimizing GPU performance.

aiming-lab/AutoResearchClaw · 25 tokens

postgres-hybrid-text-search

Use this skill to implement hybrid search combining BM25 keyword search with semantic vector search using Reciprocal Rank Fusion (RRF). Trigger when user asks to: Combine keyword and semantic search Implement hybrid search or multi-modal retrieval Use BM25/pgtextsearch with pgvector together Implement RRF (Reciprocal…

timescale/pg-aiguide · 162 tokens