triton-kernel-optimization

triton-kernel-optimization is a skill for Claude Code, Codex from AMD-AGI/Apex. It costs 56 tokens per session (3,577 once invoked), scanned A, original, MIT.

A guide for writing and tuning Triton GPU kernels, which are GPU programs written with Triton's Python-based programming system. It covers automatic block-size tuning, tiled matrix multiplication, fused operations, reductions, attention, quantization, gradients, and profiling.

In plain words
What is it for?
Use it when creating, porting, profiling, or benchmarking Triton kernels for PyTorch or standalone use.
Why use it?
It provides concrete ways to test different GPU configurations and improve memory access and computation in Triton kernels.

Skill for Claude CodeCodex

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

Good fit Use it when creating, porting, profiling, or benchmarking Triton kernels for PyTorch or standalone use.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/amd-agi/apex/triton-kernel-optimization
View source ↗ AMD-AGI/Apex
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 AMD-AGI/Apex --skill triton-kernel-optimization
Clone the repo
git clone --depth 1 https://github.com/AMD-AGI/Apex

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 triton-kernel-optimization

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

Your own site · 80×15
<a href="https://agentmods.dev/skills/amd-agi/apex/triton-kernel-optimization"><img src="https://agentmods.dev/badge/skills/amd-agi/apex/triton-kernel-optimization.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 56 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,577 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.00056 $0.03577
Opus 5.5 $0.00022 $0.01431
Sonnet 5.5 $0.00011 $0.00715
Haiku 4.5 $0.00006 $0.00358

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

Security

Grade A, and why

triton-kernel-optimization 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.

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.

tools/skills/triton-kernel-optimization/SKILL.md · 386 lines

How it starts

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

Triton Kernel Optimization

Purpose

Provide production-validated patterns and tuning tactics for performant Triton kernels on AMD MI-series GPUs.

When to Use

  • Authoring new Triton kernels for PyTorch or standalone use
  • Porting CUDA/HIP concepts into Triton with equivalent performance
  • Profiling and benchmarking Triton kernels

Optimization Priority

Phase 1: Foundation (correct and basic performance)

  1. Use @triton.autotune with configs covering key block sizes (64/128/256)
  2. Use @triton.heuristics for compile-time optimizations (e.g., EVEN_K)
  3. Apply tl.assume for stride positivity to help compiler optimize
  4. Separate boundary handling from main computation path
  5. Use tl.constexpr for all compile-time constants

Phase 2: Memory Optimization 6. Implement cache modifiers (.ca, .cg) for L2 cache control 7. Use split-K for improved L2 reuse on large K dimensions 8. Apply XCD remapping (remap_xcd) for multi-die GPUs (MI250X, MI300) 9. Optimize GROUP_SIZE_M for better L2 locality 10. Pre-shuffle weight layouts for better vectorization

Phase 3: Advanced Techniques 11. Implement persistent kernels for repeated operations 12. Use attention sink for stable long-context attention 13. Fuse quantization with GEMM (e.g., blockscale + matmul) 14. Apply per-token or per-tensor quantization strategies 15. Use grouped GEMM for mixture-of-experts workloads

Anti-patterns:

  • Hardcoding block sizes without autotune
  • Ignoring tail handling (non-divisible shapes)
  • Not using tl.assume for known constraints
  • Excessive register pressure from large tile sizes
  • Unnecessary synchronization or atomic operations

Core Optimization Patterns

1. Autotuning and Heuristics

Autotune configuration:

@triton.autotune(
    configs=[
        triton.Config({'BLOCK_SIZE_M': 128, 'BLOCK_SIZE_N': 256, 'BLOCK_SIZE_K': 64,
                       'GROUP_SIZE_M': 8}, num_warps=8, num_stages=4),
        triton.Config({'BLOCK_SIZE_M': 64, 'BLOCK_SIZE_N': 256, 'BLOCK_SIZE_K': 32,
                       'GROUP_SIZE_M': 8}, num_warps=4, num_stages=5),
        triton.Config({'BLOCK_SIZE_M': 128, 'BLOCK_SIZE_N': 128, 'BLOCK_SIZE_K': 32,
                       'GROUP_SIZE_M': 4}, num_warps=4, num_stages=3),
    ],
    key=['M', 'N', 'K'],  # Tune based on problem dimensions
)
@triton.heuristics({
    'EVEN_K': lambda args: args['K'] % args['BLOCK_SIZE_K'] == 0,
    'GRID_MN': lambda args: triton.cdiv(args['M'], args['BLOCK_SIZE_M'])
                          * triton.cdiv(args['N'], args['BLOCK_SIZE_N']),
})
@triton.jit
def gemm_kernel(..., EVEN_K: tl.constexpr, GRID_MN: tl.constexpr):
    # Use EVEN_K to skip boundary checks in hot loop
    if EVEN_K:
        a = tl.load(a_ptrs)  # No mask needed
    else:
        a = tl.load(a_ptrs, mask=mask_k)

Read the full file on GitHub · 386 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 · 386 lines · 56 tokens per session scan A 6e7d269fc2a2

Subscribe to this mod's changes

triton-kernel-optimization is a skill published in the GitHub repository AMD-AGI/Apex (78 stars, last pushed 23d ago), licensed MIT. It adds 56 tokens to every session and 3,577 once invoked, about $0.0002 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.

Related

Other skills, from other repositories

accelerate

Run PyTorch training across GPUs with minimal changes.

NousResearch/hermes-agent · 13 tokens

pytorch-patterns

PyTorch deep learning patterns and best practices for building robust, efficient, and reproducible training pipelines, model architectures, and data loading.

affaan-m/ECC · 32 tokens

optimize-for-gpu

GPU-accelerates scientific Python on NVIDIA hardware and verifies that the result is correct and faster. Use for CUDA/GPU optimization; CPU-bound NumPy, SciPy, pandas, scikit-learn, NetworkX, scikit-image, vector-search, image-processing, graph, simulation, or file-I/O workloads; CuPy, cuDF, cuML, cuGraph, cuVS…

K-Dense-AI/scientific-agent-skills · 151 tokens

developing-genkit-python

Develop AI-powered applications using Genkit in Python. Use when the user asks about Genkit, AI agents, flows, or tools in Python, or when encountering Genkit errors, import issues, or API problems.

google/skills · 49 tokens

marimo-pair

Work inside the user's live marimo notebook from the code editor: run Python in the same kernel the user does, inspect live notebook state, and commit durable notebook changes through code mode. Use whenever you create, analyze, or improve the user's marimo notebook.

marimo-team/marimo · 57 tokens

azure-mgmt-fabric-py

Azure Fabric Management SDK for Python. Use for managing Microsoft Fabric capacities and resources. Triggers: "azure-mgmt-fabric", "FabricMgmtClient", "Fabric capacity", "Microsoft Fabric", "Power BI capacity".

microsoft/skills · 51 tokens