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 mindspore-ai/akg --skill triton-cuda-patternsgit clone --depth 1 https://github.com/mindspore-ai/akgWrote 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/mindspore-ai/akg/triton-cuda-patterns)<a href="https://agentmods.dev/skills/mindspore-ai/akg/triton-cuda-patterns"><img src="https://agentmods.dev/badge/skills/mindspore-ai/akg/triton-cuda-patterns/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/mindspore-ai/akg/triton-cuda-patterns"><img src="https://agentmods.dev/badge/skills/mindspore-ai/akg/triton-cuda-patterns.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.00070 | $0.01789 |
| Opus 5.5 | $0.00028 | $0.00716 |
| Sonnet 5.5 | $0.00014 | $0.00358 |
| Haiku 4.5 | $0.00007 | $0.00179 |
Grade A, and why
triton-cuda-patterns 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 — 194 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Triton CUDA 编程模式
3.1 向量操作模式
适用于元素级运算:加法、乘法、激活函数等。
标准代码结构
@triton.jit
def vector_add_kernel(a_ptr, b_ptr, c_ptr, n_elements, BLOCK_SIZE: tl.constexpr):
pid = tl.program_id(0)
offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)
mask = offsets < n_elements
a = tl.load(a_ptr + offsets, mask=mask)
b = tl.load(b_ptr + offsets, mask=mask)
c = a + b
tl.store(c_ptr + offsets, c, mask=mask)
适用算子
- 算术运算: add, mul, sub, div
- 激活函数: relu, sigmoid, tanh(需用
tl.extra.cuda.libdevice.tanh), gelu - 数学函数: exp, log, sqrt, pow
关键要点
- 使用一维索引和偏移
- 边界处理用
mask - 简单直接的数据流:加载 → 计算 → 存储
3.2 归约模式
适用于求和、最大值、最小值等聚合操作。
标准代码结构
@triton.jit
def reduction_kernel(input_ptr, output_ptr, n_elements, BLOCK_SIZE: tl.constexpr):
pid = tl.program_id(0)
offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)
mask = offsets < n_elements
# 加载数据
data = tl.load(input_ptr + offsets, mask=mask, other=0.0)
# 块内归约
block_sum = tl.sum(data, axis=0)
# 原子操作写回全局内存
tl.atomic_add(output_ptr, block_sum)
适用算子
- 基础归约: sum, mean, max, min
- 归一化: softmax, logsoftmax, layernorm, batchnorm
- 统计: variance, std
关键要点
- 块内归约:使用
tl.sum,tl.max等 - 原子操作:使用
tl.atomic_add等写回全局内存 - 数值稳定性:减去最大值防止溢出(见 triton-cuda-reduce)
3.3 矩阵乘法模式
适用于矩阵乘法等多维块计算。
标准代码结构
@triton.jit
def matmul_kernel(
a_ptr, b_ptr, c_ptr,
M, N, K,
stride_am, stride_ak, stride_bk, stride_bn, stride_cm, stride_cn,
BLOCK_SIZE_M: tl.constexpr,
BLOCK_SIZE_N: tl.constexpr,
BLOCK_SIZE_K: tl.constexpr,
):
# 获取程序 ID
pid_m = tl.program_id(0)
pid_n = tl.program_id(1)
# 初始化累加器
accumulator = tl.zeros((BLOCK_SIZE_M, BLOCK_SIZE_N), dtype=tl.float32)
# K 维度循环
for k in range(0, K, BLOCK_SIZE_K):
# 创建块指针
a_block_ptr = tl.make_block_ptr(
base=a_ptr, shape=(M, K), strides=(stride_am, stride_ak),
offsets=(pid_m * BLOCK_SIZE_M, k),
block_shape=(BLOCK_SIZE_M, BLOCK_SIZE_K), order=(1, 0)
)
b_block_ptr = tl.make_block_ptr(
base=b_ptr, shape=(K, N), strides=(stride_bk, stride_bn),
offsets=(k, pid_n * BLOCK_SIZE_N),
block_shape=(BLOCK_SIZE_K, BLOCK_SIZE_N), order=(1, 0)
)
# 加载数据块
a = tl.load(a_block_ptr, boundary_check=(0, 1))
b = tl.load(b_block_ptr, boundary_check=(0, 1))
# 矩阵乘累加
accumulator += tl.dot(a, b)
# 存储结果(需显式转换类型,匹配输出 dtype)
c = accumulator.to(c_ptr.dtype.element_ty)
c_block_ptr = tl.make_block_ptr(
base=c_ptr, shape=(M, N), strides=(stride_cm, stride_cn),
offsets=(pid_m * BLOCK_SIZE_M, pid_n * BLOCK_SIZE_N),
block_shape=(BLOCK_SIZE_M, BLOCK_SIZE_N), order=(1, 0)
)
tl.store(c_block_ptr, c, boundary_check=(0, 1))
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 · 194 lines · 70 tokens per session scan A bccd4d792cfd
triton-cuda-patterns is a skill published in the GitHub repository mindspore-ai/akg (269 stars, last pushed yesterday), licensed Apache-2.0. It adds 70 tokens to every session and 1,789 once invoked, about $0.0003 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-09-03.
triton-cuda-patterns compared with skills from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| triton-cuda-patternsmindspore-ai/akg | Skill | 269 | yesterday | Apache-2.0 | A | 70 | Claude Code, Codex |
| agent-platform-model-registrygoogle/skills | Skill | 26k | yesterday | Apache-2.0 | A | 60 | Claude Code, Codex |
| llm-evaluationsickn33/agentic-awesome-skills | Skill | 51k | today | MIT | A | 25 | Claude Code |
| google-cloud-solution-agentic-analytics-spark-knowledge-cataloggoogle/skills | Skill | 26k | yesterday | Apache-2.0 | A | 132 | Claude Code, Codex |
| training-checkwanshuiyin/Auto-claude-code-research-in-sleep | Skill | 20k | 4d ago | MIT | A | 35 | Claude Code |
| tao-run-inference-serviceNVIDIA/skills | Skill | 4.4k | yesterday | Apache-2.0 | A | 92 | Claude Code |
| nemo-automodel-launcher-configNVIDIA/skills | Skill | 4.4k | yesterday | Apache-2.0 | A | 30 | Claude Code |