triton-ascend-fused-operator-optimization

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

A practical guide to optimizing fused Triton operations on Ascend AI processors, where several calculations are combined into one kernel.

In plain words
What is it for?
Use it to plan optimizations for fused elementwise operations, normalization, softmax with top-k selection, or matrix multiplication with activation functions.
Why use it?
It helps identify whether time is spent moving data, scanning it repeatedly, using inefficient access patterns, or doing unavoidable matrix multiplication work.

Skill for Claude CodeCodex

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

Good fit Use it to plan optimizations for fused elementwise operations, normalization, softmax with top-k selection, or matrix multiplication with activation functions.

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

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

Your own site · 80×15
<a href="https://agentmods.dev/skills/mindspore-ai/akg/triton-ascend-fused-operator-optimization"><img src="https://agentmods.dev/badge/skills/mindspore-ai/akg/triton-ascend-fused-operator-optimization.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 96 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,045 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.00096 $0.02045
Opus 5 $0.00048 $0.01022
Sonnet 5 $0.00019 $0.00409
Haiku 4.5 $0.00010 $0.00204

Measured 9d ago against content hash 17f5247b671a, 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-fused-operator-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 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-fused-operator-optimization/SKILL.md · 186 lines

How it starts

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

融合算子深度优化方法论

优化前:性能天花板分析框架

优化前先分析算子的瓶颈类型,选择正确的优化方向,避免在物理极限附近浪费时间:

瓶颈类型 判断方法 优化方向 典型天花板
内存带宽受限 计算量少、数据搬运多 减少 HBM 读写次数 ~1.5-2x
多次遍历 同一数据被读取 3+ 次 多 pass 合并为单 pass ~3-4x
数据访问模式 非连续/strided 访问 重构为连续访问 ~5-20x
计算主导 matmul weight 矩阵大 融合几乎无效 ~1.0x

天花板计算方法

理论加速比 = baseline 总 HBM 访问量 / 优化后总 HBM 访问量

示例:对于 y = f(x) * z 类融合:

  • Baseline(2 个 PyTorch op):读 x → 写 f(x) → 读 f(x) + z → 写 y = 4 次
  • Triton 融合:读 x + z → 写 y = 2 次
  • 理论上限 = 4/2 = 2x

实际天花板更低的原因:baseline 中间 tensor 常命中 L2 cache,等效减少了 HBM 访问次数。

Matmul 主导型融合的判断

优化方法 1:多 Pass 合并

适用条件

算子对同一数据进行多次独立遍历(如 softmax 的 max→exp_sum→normalize,或 topk 的多次扫描)。

方法

将所有 pass 合并为单次遍历,在寄存器内完成全部计算:

# 次优:多次遍历
max_val = pass_find_max(data)          # 遍历 1
exp_sum = pass_compute_exp(data)       # 遍历 2
topk = pass_find_topk(data)            # 遍历 3+

# 推荐:单次遍历
data = tl.load(...)
max_val = tl.max(data, axis=0)
exp_vals = tl.math.exp(data - max_val)
exp_sum = tl.sum(exp_vals, axis=0)
probs = exp_vals / exp_sum
# topk 直接在同一 block 内完成
first_val = tl.max(probs, axis=0)

关键约束

当归约维度能放入单个 BLOCK 时效果最佳;维度过大则需分块归约,收益递减。

优化方法 2:数据访问模式重构

适用条件

算子涉及 strided / 非连续访问模式(如需要访问相邻元素的配对计算)。

方法

从按元素展平处理,改为按语义分组处理,使相关元素落在同一 block 内:

# 次优:展平后按 flat_idx 处理,需跨 stride 访问配对元素
for block_id in range(pid, total_elements // BLOCK_SIZE, CORE_NUM):
    flat_idx = block_id * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)
    d = flat_idx % D
    d_pair = d ^ 1  # 跨 stride 随机访问

# 推荐:按语义维度分组,内层连续加载
for group_idx in range(pid, total_groups, CORE_NUM):
    # 计算分组坐标
    for d_start in range(0, D, BLOCK_D):
        d_offsets = d_start + tl.arange(0, BLOCK_D)
        # 配对元素天然在同一 block 内
        vals = tl.load(ptr + base + d_offsets)

为什么有效

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

优化方法 3:Normalization 两阶段决策

适用条件

LayerNorm / RMSNorm / GroupNorm 等需要先统计再归一化的算子。

结论:两阶段(2-pass)优于单 Pass

Read the full file on GitHub · 186 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 · 186 lines · 96 tokens per session scan A 17f5247b671a

Subscribe to this mod's changes

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