triton-ascend

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

A guide to writing Triton kernels for Ascend NPUs. Triton is a Python-based language for describing parallel operations that run in blocks across the device.

In plain words
What is it for?
Use it when implementing vector operations, reductions, or tiled matrix multiplication on an Ascend NPU.
Why use it?
It explains how to divide work into blocks, handle array edges safely, and choose patterns for elementwise operations, reductions, and matrix multiplication.

Skill for Claude CodeCodex

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

Good fit Use it when implementing vector operations, reductions, or tiled matrix multiplication on an Ascend NPU.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/mindspore-ai/akg/triton-ascend
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
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

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

Your own site · 80×15
<a href="https://agentmods.dev/skills/mindspore-ai/akg/triton-ascend"><img src="https://agentmods.dev/badge/skills/mindspore-ai/akg/triton-ascend.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 28 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 715 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.00028 $0.00715
Opus 5 $0.00014 $0.00358
Sonnet 5 $0.00006 $0.00143
Haiku 4.5 $0.00003 $0.00072

Measured 11d ago against content hash ed5cecb4b9c6, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

triton-ascend 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 11d 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/examples/run_skill/skills/triton-ascend/SKILL.md · 100 lines

What it actually says

Triton Ascend NPU编程指南

基于 AKG Agents resources/docs/triton_ascend_docs

核心概念

内核 (Kernel)

  • 定义: 使用 @triton.jit 装饰的Python函数
  • 特点: 并行执行,通过程序ID区分

网格与块

  • 网格: 并行维度配置
  • : 数据块大小
  • 关系: grid_size = ceil(total_elements / block_size)

内存层次

  • 全局内存: 所有程序可访问,延迟高
  • 共享内存: 块内共享,延迟低
  • 寄存器: 线程私有,最快

标准内核结构

@triton.jit
def standard_kernel(output_ptr, input_ptr, n_elements, BLOCK_SIZE: tl.constexpr):
    # 1. 获取程序ID和计算偏移
    pid = tl.program_id(0)
    offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)
    
    # 2. 创建边界掩码
    mask = offsets < n_elements
    
    # 3. 加载数据
    data = tl.load(input_ptr + offsets, mask=mask)
    
    # 4. 执行计算
    result = compute_function(data)
    
    # 5. 存储结果
    tl.store(output_ptr + offsets, result, mask=mask)

三大编程模式

1. 向量操作模式

适用于元素级运算。

2. 归约模式

适用于聚合操作。

3. 矩阵乘法模式

使用分块策略。

Ascend NPU特性

NPU架构特点

  • AI Core执行计算
  • 高带宽内存(HBM)
  • 统一虚拟内存

优化建议

  1. 利用NPU的矩阵计算单元
  2. 优化数据布局
  3. 使用合适的block size
  4. 考虑内存对齐

完整示例

参考: python/akg_agents/op/resources/docs/triton_ascend_docs/examples/

  • torch_matmul.py
  • torch_layer_norm.py
  • torch_softmax.py
  • torch_vector_add.py

最佳实践

  1. 始终使用mask处理边界
  2. Block size选择2的幂
  3. 测试不同配置找到最优
  4. 注意NPU特定的内存访问模式

相关资源

  • API文档: triton_ascend_docs/api/api.md
  • 建议文档: triton_ascend_docs/suggestion_docs.md
  • 示例代码: triton_ascend_docs/examples/
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. 11d ago First seen · 100 lines · 28 tokens per session scan A ed5cecb4b9c6

Subscribe to this mod's changes

triton-ascend is a skill published in the GitHub repository mindspore-ai/akg (259 stars, last pushed 1mo ago), licensed Apache-2.0. It adds 28 tokens to every session and 715 once invoked, about $0.0001 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.

Related

Other skills, from other repositories

cardputer-buddy

Iterate on the Cardputer-Adv MicroPython app bundle (Claude Buddy, Snake, Hello) after the device is already provisioned via m5-onboard. Use when the user wants to add a new app, push a single changed .py without re-flashing, watch device serial logs, or run a one-shot REPL command. Trigger on "add an app", "push to…

anthropics/claude-plugins-official · 109 tokens

holoscan-install-wheel

Install Holoscan SDK Python wheel via pip into a venv. Use for Python installs; not for native C++/apt or Conda installs.

NVIDIA/skills · 37 tokens

HA Integration Dev

Home Assistant custom integration development in Python. Covers customcomponents, DataUpdateCoordinator, configflow, OAuth2, conversation agent, HACS publishing, device registry, entity platforms, services, repair issues, diagnostics, Bluetooth integrations, and multi-coordinator patterns.

tonylofgren/aurora-smart-home · 55 tokens

xpu-port

Execute a single-target CUDA-to-XPU port of a PyTorch repo with libcst-based scan, mechanical rewrite, and CPU FP64 vs target-dtype correctness verify on one forward pass. Use when the request says "port" — "port my repo to XPU", "port my repo at to XPU", "rewrite the CUDA calls to XPU", "apply the mechanical…

intel/gpu-ai-skills · 193 tokens

triton-lang

Triton language skill for Python GPU kernel authoring. Use when writing Triton kernels with @triton.jit, tl.load/store, masking, atomics, benchmarking with triton.testing, or integrating kernels into PyTorch. Activates on queries about Triton, tl.constexpr, block pointers, Triton benchmarking, or PyTorch custom ops.

mohitmishra786/low-level-dev-skills · 76 tokens

pywayne-cv-camera-model

Camera model wrapper for cameramodels C++ library via pybind11. Use when working with pywayne.cv.cameramodel module to load camera models from YAML configuration files, access camera properties (model type, image size, parameters), perform projection operations (liftprojective, spacetoplane), and export camera…

wangyendt/wayne-skills · 71 tokens