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 agentmods add skills/amd-agi/apex/triton-kernel-optimizationnpx skills add AMD-AGI/Apex --skill triton-kernel-optimizationgit clone --depth 1 https://github.com/AMD-AGI/ApexWhat 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 | $0.00056 | $0.03577 |
| Opus 5 | $0.00028 | $0.01788 |
| Sonnet 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 3d 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.
- 3d 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 (76 stars, last pushed 6d ago), licensed MIT. It adds 56 tokens to every session and 3,577 once invoked, about $0.0003 per session on Opus 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.
Other skills, from other repositories
dali-dynamic-mode
DALI imperative dynamic mode (nvidia.dali.experimental.dynamic, ndd): use when working on ndd code or migrating pipelines; skip pipeline-only tasks.
datachain-core
Use ONLY for abstract DataChain SDK questions — API usage, method signatures, or code patterns — when no specific dataset or bucket is referenced. If the request mentions creating, saving, listing, exploring datasets or buckets, use datachain-knowledge instead.
mflux-model-porting
Port ML models into mflux/MLX with correctness-first validation, then refactor toward mflux style.
minicpm5-finetune-trl
Fine-tune MiniCPM5-1B with bare-metal TRL + PEFT, including assistant-only loss via a chat-template patch. Use when the user wants minimal Python, no YAML, full control, or asks for "TRL", "SFTTrainer", "PEFT", "LoraConfig", "assistantonlyloss".
minicpm5-finetune-unsloth
Fine-tune MiniCPM5-1B with unsloth for tight-VRAM single-GPU LoRA / QLoRA. Use when the user wants "unsloth", "FastLanguageModel", QLoRA on a 24 GB consumer GPU, or asks for the smallest VRAM footprint.
minicpm5-deploy-transformers
Run MiniCPM5-1B with Hugging Face Transformers for one-shot Python generation on GPU (bfloat16) or CPU (float32). Use when the user wants a quick Python script, no server, no extra deps, or asks for "Transformers", "AutoModelForCausalLM", "model.generate" with MiniCPM5.