triton-ascend-optimization

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

A general performance guide for Triton kernels on Ascend processors. It covers block sizes, grid layouts, core selection, memory alignment, automatic tuning, precision, and reduction patterns.

In plain words
What is it for?
Use it when tuning element-wise operations, matrix multiplication, reductions, convolutions, and fused kernels for Ascend hardware.
Why use it?
It provides practical choices for balancing parallel work, memory bandwidth, device limits, and kernel launch overhead.

Skill for Claude CodeCodex

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

Good fit Use it when tuning element-wise operations, matrix multiplication, reductions, convolutions, and fused kernels for Ascend hardware.

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

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

Your own site · 80×15
<a href="https://agentmods.dev/skills/mindspore-ai/akg/triton-ascend-optimization"><img src="https://agentmods.dev/badge/skills/mindspore-ai/akg/triton-ascend-optimization.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 146 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 991 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.00146 $0.00991
Opus 5 $0.00073 $0.00495
Sonnet 5 $0.00029 $0.00198
Haiku 4.5 $0.00015 $0.00099

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

Security

Grade A, and why

triton-ascend-optimization 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 6d 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/fundamentals/triton-ascend-optimization/SKILL.md · 68 lines

What it actually says

Triton Ascend 性能优化指南

优化策略 Checklist

  • Grid 1D 化: grid=(CORE_NUM,) + 核内交错循环 for block_id in range(pid, total, CORE_NUM)
  • Grid 维度选择:
    • 对于计算密集型算子(矩阵乘、卷积、大块 reduce等),考虑 2D/3D grid,利用硬件调度优势
    • 对于大量小规模计算(element-wise、pointwise等),考虑 1D grid + 核内循环,减少启动开销
  • 核内循环: 无需 for 的场景添加额外循环,编译器自动多级流水
  • 尝试不同 BLOCK_SIZE: 从较大 tile 开始,ub overflow 则缩小;在核内循环中平衡并行度和资源占用:
    • 尝试小切分策略,使读写能够并行进行
    • 尝试大切分策略,提升 UB 使用率
    • 列多组参数配置,添加 @triton.autotune
  • 算子拆分: 复杂融合算子可拆为多 kernel 顺序执行,有时性能更优
  • Autotune: 列多组 tile 参数配置(不含 num_warps/num_stages)
  • Reduction 用标量累加: 每个核心标量累加 + 单次 atomic 写入
  • 内存对齐: matmul 的 K 维度按 512B 对齐提升带宽
  • 避免 host 端 permute: 非最后维 reduce 在 kernel 内用多维索引处理
  • 隐式广播: 用 a[:, None] * b 替代 tl.broadcast_to,减少临时 tensor
  • load 时直接 mask: tl.load(ptr, mask=m, other=0.0) 优于先加载再 tl.where
  • 减少冗余精度转换: 避免反复在 fp16/fp32 转换 即.to(float16).to(float32),一次转换多次复用
  • 核心数配置: grid 数设为核心数(VEC/CUBE),过大时启动开销反增
  • 256B 对齐: 数据搬运以 256B 为单位,对齐可提升带宽

Reduction 优化

每个核心先局部标量累加,最后一次原子写入:

core_sum = 0.0
for block_start in range(pid, total_blocks, CORE_NUM):
    data = tl.load(...)
    core_sum += tl.sum(data, axis=0)
tl.atomic_add(output_ptr, core_sum)

数值稳定性

防溢出

max_val = tl.max(scores, axis=0)
scores = scores - max_val
p = tl.math.exp2(scores)

防负值开方

  • 任何 sqrt 前确保非负: max(input, 0.)max(input, eps)

精度提升

  • matmul 使用 fp32 累加器:acc = tl.zeros([M, N], dtype=tl.float32)
  • 最后再转回目标精度:result = acc.to(tl.float16)
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. 6d ago First seen · 68 lines · 146 tokens per session scan A 021f73e20037

Subscribe to this mod's changes

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

Related

Other skills, from other repositories

ruview-quickstart

Onboarding and first-run for RuView (WiFi-DensePose) — Docker demo with simulated data, repo build, and the fastest path to a live sensing dashboard. Use when someone is new to RuView or wants the shortest path to "it works on my machine".

ruvnet/RuView · 62 tokens

onboard

Zero-to-sensing path picker for RuView (WiFi-DensePose) — pick docker-demo, repo-build, or live-esp32 and run the next concrete step.

ruvnet/RuView · 39 tokens

lesson-quiz

Test a learner on a single Claude Code tutorial lesson (01-10) with 10 questions, scoring answers and flagging weak spots. Use before, during, or after a lesson. Don't use for whole-tutorial assessment or explaining a topic instead of testing it.

luongnv89/claude-howto · 58 tokens

doca-programming-guide

Use this skill when the user is writing their first DOCA app or asking a library-agnostic programming question — picking a shipped sample to copy and modify, wiring the canonical pkg-config doca-{library} + meson build (or FFI from Rust / Go / Python against the public C ABI), walking the cfg-create → init → start →…

NVIDIA/skills · 246 tokens

devin-akin-perspective

A vendor-neutral perspective for making enterprise Wi-Fi decisions, with emphasis on radio physics, training, technical standards, and checking vendor claims against real deployments.

swaylq/master-skill · 220 tokens

design-logic-circuit

Design combinational logic circuits from a functional specification through gate-level implementation. Covers AND, OR, NOT, XOR, NAND, NOR gates; NAND/NOR universality conversions; and standard building blocks including multiplexers, decoders, half/full adders, and ripple-carry adders. Use when translating a Boolean…

pjt222/agent-almanac · 87 tokens