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-ascend-examples-mindsporegit 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-ascend-examples-mindspore)<a href="https://agentmods.dev/skills/mindspore-ai/akg/triton-ascend-examples-mindspore"><img src="https://agentmods.dev/badge/skills/mindspore-ai/akg/triton-ascend-examples-mindspore/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-ascend-examples-mindspore"><img src="https://agentmods.dev/badge/skills/mindspore-ai/akg/triton-ascend-examples-mindspore.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.00075 | $0.01184 |
| Opus 5 | $0.00037 | $0.00592 |
| Sonnet 5 | $0.00015 | $0.00237 |
| Haiku 4.5 | $0.00007 | $0.00118 |
Grade A, and why
triton-ascend-examples-mindspore 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 7d 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 — 145 lines — stays where its author put it; the contents beside it link to each section on GitHub.
MindSpore + Triton Ascend 示例代码
MindSpore vs PyTorch 差异
| 特性 | PyTorch | MindSpore |
|---|---|---|
| 基类 | torch.nn.Module |
mindspore.nn.Cell |
| 前向函数 | forward |
construct |
| 张量创建 | torch.empty |
mindspore.ops.zeros 或 numpy |
| 设备 | device='cuda'/'npu' |
自动管理或 context.set_context |
| 数据类型 | torch.float16 |
mindspore.float16 |
示例列表
1. Vector Add(向量加法)
MindSpore 实现:
import mindspore as ms
from mindspore import nn
import triton
import triton.language as tl
@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)
class ModelNew(nn.Cell):
def __init__(self):
super().__init__()
def construct(self, a, b):
# 注意:使用 numpy 创建输出张量
import numpy as np
c = ms.Tensor(np.empty_like(a.asnumpy()), dtype=a.dtype)
n_elements = a.size
grid = (triton.cdiv(n_elements, BLOCK_SIZE),)
vector_add_kernel[grid](a, b, c, n_elements, BLOCK_SIZE=1024)
return c
2. MatMul(矩阵乘法)
关键差异:
class ModelNew(nn.Cell):
def __init__(self):
super().__init__()
def construct(self, x0, x1): # 注意:使用 construct 而非 forward
B, C = x0.shape
C2, D = x1.shape
assert C == C2, f"矩阵维度不匹配: {C} != {C2}"
# MindSpore 张量创建
import numpy as np
output = ms.Tensor(np.empty((B, D), dtype=np.float32))
matmul_kernel[1, 1, 1](output, x0, x1, 1, B, C, D)
return output
3. Layer Norm(层归一化)
MindSpore 特有处理:
class ModelNew(nn.Cell):
def __init__(self, normalized_shape, eps=1e-5):
super().__init__()
self.eps = eps
self.normalized_shape = normalized_shape
# MindSpore 参数初始化
ms.set_seed(0) # 注意:使用 ms.set_seed 而非 torch.manual_seed
self.weight = ms.Parameter(ms.ops.ones(normalized_shape, ms.float32))
self.bias = ms.Parameter(ms.ops.zeros(normalized_shape, ms.float32))
def construct(self, x):
M, N = x.shape
import numpy as np
output = ms.Tensor(np.empty_like(x.asnumpy()), dtype=x.dtype)
grid = (M,)
layernorm_kernel[grid](
x, output, self.weight, self.bias,
N, self.eps, BLOCK_SIZE=triton.next_power_of_2(N)
)
return output
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.
- 7d ago First seen · 145 lines · 75 tokens per session scan A 1a28d1fec28e
triton-ascend-examples-mindspore is a skill published in the GitHub repository mindspore-ai/akg (259 stars, last pushed 1mo ago), licensed Apache-2.0. It adds 75 tokens to every session and 1,184 once invoked, about $0.0004 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-09-03.
Other skills, from other repositories
triton-cuda-examples-torch
A set of complete examples showing how Triton CUDA kernels work inside PyTorch, including vector addition, matrix multiplication, layer normalization, and softmax.
triton-ascend-examples-mindspore
Integration examples for using Triton Ascend kernels inside MindSpore, a machine-learning framework. They show how to register a custom operation and pass tensors in and out.
pypto-case-norm-batchnorm
A worked example of BatchNorm, a machine-learning step that normalizes values in groups, for three-dimensional data. It demonstrates reducing dimensions, summing across several axes, and copying values across expanded dimensions.
pypto-case-loss-crossentropy
An example of implementing cross-entropy loss, a calculation commonly used to measure classification errors. It covers multiple inputs, tiled processing, softmax, selecting target values, summing, and producing one scalar result.
pypto-case-norm-layernorm
A PyPTO example showing how LayerNorm normalises values across a two-dimensional input using a loop. LayerNorm is a machine-learning operation that rescales values to help a model process them consistently.
pypto-case-elemwise-gelu
A PyPTO example for applying the GELU activation function element by element to a one-dimensional array. It demonstrates flattening, a hand-written formula without tanh, and operator use.