triton-ascend-examples-mindspore

triton-ascend-examples-mindspore is a skill for Claude Code, Codex from mindspore-ai/akg. It costs 75 tokens per session (1,184 once invoked), scanned A, original, Apache-2.0.

An integration example for using Triton Ascend kernels with MindSpore, a machine-learning framework. It shows how custom operators are registered and how tensors are passed into and out of them.

In plain words
What is it for?
Use it as a code-structure reference when implementing Triton operations inside MindSpore models, including a vector-add example.
Why use it?
It helps avoid copying PyTorch code patterns that do not match MindSpore's classes, forward method names, tensor creation, or device handling.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it as a code-structure reference when implementing Triton operations inside MindSpore models, including a vector-add example.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/mindspore-ai/akg/triton-ascend-examples-mindspore
Install

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.

Any agent
npx skills add mindspore-ai/akg --skill triton-ascend-examples-mindspore
Clone the repo
git clone --depth 1 https://github.com/mindspore-ai/akg

Made for: Claude Code, Codex.

Wrote 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.

agentmods badge for triton-ascend-examples-mindspore

README.md
[![agentmods](https://agentmods.dev/badge/skills/mindspore-ai/akg/triton-ascend-examples-mindspore/github.svg)](https://agentmods.dev/skills/mindspore-ai/akg/triton-ascend-examples-mindspore)
Your own site
<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.

agentmods 80×15 button for triton-ascend-examples-mindspore

Your own site · 80×15
<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>
Per session 75 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,184 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce invoked
Fable 5.1 $0.00075 $0.01184
Opus 5.5 $0.00030 $0.00474
Sonnet 5.5 $0.00015 $0.00237
Haiku 4.5 $0.00007 $0.00118

Measured 2mo ago against content hash 1a28d1fec28e, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

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 2mo 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.

akg_agents/python/akg_agents/op/resources/skills/triton-ascend/examples/triton-ascend-examples-mindspore/SKILL.md · 145 lines

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

Read the full file on GitHub · 145 lines

Changes

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.

  1. 2mo ago First seen · 145 lines · 75 tokens per session scan A 1a28d1fec28e

Subscribe to this mod's changes

triton-ascend-examples-mindspore is a skill published in the GitHub repository mindspore-ai/akg (266 stars, last pushed 2d ago), licensed Apache-2.0. It adds 75 tokens to every session and 1,184 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.

Related

triton-ascend-examples-mindspore compared with skills from other repositories

triton-ascend-examples-mindspore next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
triton-ascend-examples-mindsporemindspore-ai/akgSkill2662d agoApache-2.0A75Claude Code, Codex
triton-cuda-examples-torchwenyi-li/awesome-agent-kernel-skillsSkill105mo agononeA71Claude Code, Codex
triton-ascend-examples-mindsporewenyi-li/awesome-agent-kernel-skillsSkill105mo agononeA75Claude Code, Codex
pypto-case-norm-batchnormwenyi-li/awesome-agent-kernel-skillsSkill105mo agononeA41Claude Code, Codex
pypto-case-loss-crossentropywenyi-li/awesome-agent-kernel-skillsSkill105mo agononeA37Claude Code, Codex
pypto-case-elemwise-geluwenyi-li/awesome-agent-kernel-skillsSkill105mo agononeA40Claude Code, Codex
pypto-case-norm-layernormwenyi-li/awesome-agent-kernel-skillsSkill105mo agononeA42Claude Code, Codex