triton-ascend-performance-improvement

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

A collection of Triton Ascend performance techniques for choosing tile sizes, loading data safely, broadcasting values, and performing reductions.

In plain words
What is it for?
Use it when adjusting vector or matrix tiles, masked loads, implicit broadcasting, reduction accumulators, or multiple passes over data.
Why use it?
It helps prevent memory-capacity errors and reduce unnecessary temporary data while tuning kernels for Ascend hardware.

Skill for Claude CodeCodex

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

Good fit Use it when adjusting vector or matrix tiles, masked loads, implicit broadcasting, reduction accumulators, or multiple passes over data.

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

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

Your own site · 80×15
<a href="https://agentmods.dev/skills/mindspore-ai/akg/triton-ascend-performance-improvement"><img src="https://agentmods.dev/badge/skills/mindspore-ai/akg/triton-ascend-performance-improvement.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 67 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,126 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.00067 $0.01126
Opus 5 $0.00034 $0.00563
Sonnet 5 $0.00013 $0.00225
Haiku 4.5 $0.00007 $0.00113

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

Security

Grade A, and why

triton-ascend-performance-improvement 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 9d 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/evolved-improvement/triton-ascend-performance-improvement/SKILL.md · 88 lines

How it starts

The opening of the file, as written. The whole thing — 88 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Tile 尺寸选择方法

tile 尺寸需满足硬件存储约束(具体容量参考传入的硬件信息文档):

CUBE 路径 (matmul / tl.dot):tile 必须能放入 L0A/L0B/L0C

  • 计算公式:BLOCK_M × BLOCK_K × sizeof(dtype) ≤ L0A 容量
  • fp32 占用是 fp16 的 2 倍,需相应缩小 tile
  • K 维度按 512B 对齐可提升带宽利用率

VEC 路径 (elementwise / reduce):所有活跃 tensor 需放入 UB

  • 计算公式:BLOCK_SIZE × sizeof(dtype) × 活跃tensor数 × multi_buffer系数 ≤ UB 容量
  • 编译器 auto-multi-buffer 会将占用增至 2~3 倍
  • kernel 中间变量(如 tl.where 产生的临时缓冲)也占用 UB

调优策略:从较大 tile 开始尝试,遇到 ub overflow / cbuf overflow 编译错误时逐级缩小。配合 @triton.autotune 自动选优。

内存加载优化

tl.load 时直接应用 mask 和填充值,而非先无条件加载再用 tl.where 筛选:

# 次优:先加载再 where(多一次中间操作,可能触发 vsel 编译错误)
tile = tl.zeros([BLOCK_SIZE], dtype=tl.float32)
tile = tl.where(mask, tl.load(ptr + offsets), 0.0)

# 推荐:直接在 load 时应用 mask
tile = tl.load(ptr + offsets, mask=mask, other=0.0)

隐式广播替代显式展开

需要将低维 tensor 广播到高维时,用维度扩展([:, None])利用 Triton 的隐式广播,避免 tl.broadcast_to 创建临时矩阵:

# 次优:显式展开为完整矩阵
a_broadcast = tl.broadcast_to(a_tile[:, None], (BLOCK_M, BLOCK_N))
c_tile = a_broadcast * b_tile

# 推荐:隐式广播
c_tile = a_tile[:, None] * b_tile

Reduction 最佳实践

  1. 标量累加器:每个核心用 core_sum = 0.0 局部累加,避免 tensor 索引问题
  2. 单次原子写入:循环结束后 tl.atomic_add(out_ptr, core_sum) 一次写入
  3. 避免 host 端 permute:非最后维度 reduce 直接在 kernel 内用多维索引

Host 端预计算 stride

在 host 端预先计算 tensor 的 stride 并作为参数传入 kernel,而非在 kernel 内部计算,可以减少传参错误并辅助编译器优化:

# host 端
stride_am, stride_ak = A.stride(0), A.stride(1)
kernel[grid](A_ptr, ..., stride_am, stride_ak, ...)

多 Pass 合并为单 Pass

当算子对同一数据进行多次独立遍历时(如 softmax 的 max→exp_sum→normalize,或 topk 的多次扫描),应合并为单次遍历。每减少一次 HBM 读取,理论上可获得等比例加速。多 pass 合并对归约维度较小(能放入单个 BLOCK)的场景效果最佳。

Strided 访问模式重构

当算子涉及非连续的 strided 访问(如需要访问相邻元素的配对计算),应重构数据加载策略:

  • 改为按语义分组处理,使相关元素落在同一 block 内
  • 避免 flat_idx % D + 跨 stride 的随机访问
  • 连续加载后在块内处理配对关系,利用数据局部性

Ascend 硬件对非连续访问有显著性能惩罚,重构后性能差距可达数倍至数十倍。

Normalization 两阶段优于单 Pass

对于 LayerNorm/RMSNorm 类算子,两阶段方案(第一遍统计 mean/var,第二遍归一化)通常优于单 pass(在线统计)。 原因:单 pass 循环体内活跃 tensor 增多,UB 压力增大,编译器流水线优化效率下降。实测中 2-pass 比单 pass 快约 20%。

Read the full file on GitHub · 88 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. 9d ago First seen · 88 lines · 67 tokens per session scan A afe73dc7f4eb

Subscribe to this mod's changes

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

automatic-stateful-prompt-improver

Automatically intercepts and optimizes prompts using the prompt-learning MCP server. Learns from performance over time via embedding-indexed history. Uses APE, OPRO, DSPy patterns. Activate on "optimize prompt", "improve this prompt", "prompt engineering", or ANY complex task request. Requires prompt-learning MCP…

curiositech/windags-skills · 102 tokens

agent-platform-rag-engine-management

Manage and query Agent Platform RAG Engine Corpora and retrieve grounded contexts using the Google GenAI SDK. Use when listing RAG corpora or files, inspecting a corpus, retrieving contexts, or generating content grounded in a RAG corpus. Do not use for standard database queries (use SQL/Spanner skills), Google…

google/skills · 85 tokens

agent-platform-model-registry

Agent Platform Model Registry Management. Use when you need to upload, list, describe, update, or delete machine learning models (and their versions) in the Agent Platform Model Registry. Don't use for model training, model deployment to endpoints, or managing non-Agent Platform models.

google/skills · 60 tokens

foundry-config-setup

Resolve missing setup caused by a hardcoded Foundry project endpoint or model in a sample. Use when a sample fails because it uses a placeholder/hardcoded projectendpoint (for example "https://your-project.services.ai.azure.com") or a hardcoded model instead of reading them from the environment.

microsoft/agent-framework · 65 tokens

google-cloud-solution-agentic-analytics-spark-knowledge-catalog

Discovers requirements and generates guidance to design and deploy a governed, secure agentic-analytics solution for data that's distributed across Google Cloud, other cloud providers, or on-premises. Data that's outside Google Cloud (such as data from Databricks, Snowflake, Salesforce, SAP, or Oracle systems) is…

google/skills · 138 tokens

training-check

Interactively monitor training metrics from the current Codex session, periodically checking WandB or fallback logs for NaN, divergence, plateaus, and broken runs.

wanshuiyin/Auto-claude-code-research-in-sleep · 35 tokens