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-elementwisegit 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-elementwise)<a href="https://agentmods.dev/skills/mindspore-ai/akg/triton-cuda-elementwise"><img src="https://agentmods.dev/badge/skills/mindspore-ai/akg/triton-cuda-elementwise/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-elementwise"><img src="https://agentmods.dev/badge/skills/mindspore-ai/akg/triton-cuda-elementwise.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.00071 | $0.02043 |
| Opus 5.5 | $0.00028 | $0.00817 |
| Sonnet 5.5 | $0.00014 | $0.00409 |
| Haiku 4.5 | $0.00007 | $0.00204 |
Grade A, and why
triton-cuda-elementwise 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 — 234 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Element-wise 算子优化
适用于逐元素独立计算的算子
适用算子
算术运算: add, mul, div, sub, pow
激活函数: relu, sigmoid, tanh(需用 tl.extra.cuda.libdevice.tanh), gelu, silu, swish
数学函数: exp, log, sqrt, sin, cos, abs
优化策略
1. 连续内存访问优化
张量在内存中连续存储时,可用一维指针遍历,避免多维索引开销。
方案 1: 转连续 + 一维访问(推荐)
class ModelNew(torch.nn.Module):
def __init__(self):
super().__init__()
def forward(self, input_tensor):
# 非连续张量转为连续(一次性开销)
if not input_tensor.is_contiguous():
input_tensor = input_tensor.contiguous()
output_tensor = torch.empty_like(input_tensor)
n_elements = input_tensor.numel()
grid = (triton.cdiv(n_elements, BLOCK_SIZE),)
elementwise_kernel[grid](input_tensor, output_tensor, n_elements, BLOCK_SIZE)
return output_tensor
@triton.jit
def elementwise_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)
result = compute(data) # 你的计算逻辑
tl.store(output_ptr + offsets, result, mask=mask)
优势:
.contiguous()一次性开销 vs stride 每次访问都有开销- 更好的合并访问(coalesced access)
- 编译器优化更容易
方案 2: 使用 stride 访问(不推荐)
仅当无法调用 .contiguous() 时使用。
2. BLOCK_SIZE 选择
- 推荐值: 256, 512, 1024
- 原则: 平衡并行度和资源占用
- GPU 考量:
- 更大的 BLOCK_SIZE → 更少的 block 启动开销,但可能降低 occupancy
- 更小的 BLOCK_SIZE → 更细粒度的并行,但启动开销增加
- 确保 Grid 大小足够大以充分利用 GPU
3. Warp 配置
Element-wise 算子通常使用较少的 warp:
@triton.autotune(
configs=[
triton.Config({'BLOCK_SIZE': 1024}, num_warps=4),
triton.Config({'BLOCK_SIZE': 512}, num_warps=2),
triton.Config({'BLOCK_SIZE': 2048}, num_warps=8),
],
key=['n_elements'],
restore_value=['output_ptr'], # 必须:列出所有输出指针参数名
)
@triton.jit
def optimized_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)
result = compute(data)
tl.store(output_ptr + offsets, result, mask=mask)
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 · 234 lines · 71 tokens per session scan A 55b54b496a0d
triton-cuda-elementwise is a skill published in the GitHub repository mindspore-ai/akg (269 stars, last pushed today), licensed Apache-2.0. It adds 71 tokens to every session and 2,043 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-elementwise compared with skills from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| triton-cuda-elementwisemindspore-ai/akg | Skill | 269 | today | Apache-2.0 | A | 71 | Claude Code, Codex |
| hatch3r-ai-featurehatch3r/hatch3r | Skill | 26 | 2mo ago | MIT | A | 39 | Claude Code |
| AI Integration Specialisteddiebelaval/squire | Skill | 21 | 3mo ago | MIT | A | 15 | Claude Code, Codex |
| triton-cuda-attentionwenyi-li/awesome-agent-kernel-skills | Skill | 11 | 6mo ago | none | A | 59 | Claude Code, Codex |
| triton-cuda-reducewenyi-li/awesome-agent-kernel-skills | Skill | 11 | 6mo ago | none | A | 68 | Claude Code, Codex |
| AI Integration Specialistjmsktm/claude-settings | Skill | 11 | 10mo ago | none | A | 15 | Claude Code, Codex |
| agent-platform-model-registrygoogle/skills | Skill | 25k | today | Apache-2.0 | A | 60 | Claude Code, Codex |