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.
npx skills add AMD-AGI/Apex --skill triton-kernel-optimizationgit clone --depth 1 https://github.com/AMD-AGI/ApexWrote 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.
[](https://agentmods.dev/skills/amd-agi/apex/triton-kernel-optimization)<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.
<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>- NVIDIA SkillSpector pass
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.
| Model | Per session | Once 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 |
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 3mo 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.
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)
- Use
@triton.autotunewith configs covering key block sizes (64/128/256) - Use
@triton.heuristicsfor compile-time optimizations (e.g.,EVEN_K) - Apply
tl.assumefor stride positivity to help compiler optimize - Separate boundary handling from main computation path
- Use
tl.constexprfor 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.assumefor 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)
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.
- 3mo ago First seen · 386 lines · 56 tokens per session scan A 6e7d269fc2a2
triton-kernel-optimization is a skill published in the GitHub repository AMD-AGI/Apex (80 stars, last pushed 2mo 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.
triton-kernel-optimization compared with skills from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| triton-kernel-optimizationAMD-AGI/Apex | Skill | 80 | 2mo ago | MIT | A | 56 | Claude Code, Codex |
| pytorch-patternsaffaan-m/ECC | Skill | 315k | yesterday | MIT | A | 32 | Claude Code, Kiro |
| accelerateNousResearch/hermes-agent | Skill | 268k | today | MIT | A | 13 | Claude Code, Codex |
| optimize-for-gpuK-Dense-AI/scientific-agent-skills | Skill | 59k | 3d ago | MIT | A | 151 | Claude Code, Codex |
| developing-genkit-pythongoogle/skills | Skill | 25k | today | Apache-2.0 | A | 96 | Claude Code, Codex |
| marimo-pairmarimo-team/marimo | Skill | 24k | today | Apache-2.0 | A | 57 | Claude Code, Codex |
| cudnn-installNVIDIA/skills | Skill | 4.3k | today | Apache-2.0 | A | 49 | Claude Code, Codex |