triton-ascend-case-reduction-amax-large

triton-ascend-case-reduction-amax-large is a skill for Claude Code, Codex from mindspore-ai/akg. It costs 81 tokens per session (647 once invoked), scanned A, original, Apache-2.0.

An optimization guide for Triton kernels that find maximum values across a very large dimension of a 2D array on an Ascend processor. It targets cases where the other dimension is very small.

In plain words
What is it for?
Use it for extreme shapes such as 16×262144. It covers splitting the large dimension, combining results with atomic operations, and choosing block sizes.
Why use it?
Mapping work only to the small dimension leaves many cores unused, so the guide splits the large dimension across cores and combines their partial results.

Skill for Claude CodeCodex

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

Good fit Use it for extreme shapes such as 16×262144. It covers splitting the large dimension, combining results with atomic operations, and choosing block sizes.

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

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

Your own site · 80×15
<a href="https://agentmods.dev/skills/mindspore-ai/akg/triton-ascend-case-reduction-amax-large"><img src="https://agentmods.dev/badge/skills/mindspore-ai/akg/triton-ascend-case-reduction-amax-large.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 81 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 647 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.00081 $0.00647
Opus 5 $0.00041 $0.00324
Sonnet 5 $0.00016 $0.00129
Haiku 4.5 $0.00008 $0.00065

Measured 13d ago against content hash 139ee9621f06, 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-case-reduction-amax-large 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 13d 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/cases/triton-ascend-case-reduction-amax-large/SKILL.md · 66 lines

What it actually says

大规模 Amax 归约优化(reduce轴映射多核)

任务特征

  • 数据尺寸:(16, 262144),非reduce轴很小,reduce轴很大
  • 策略:将reduce轴映射到多核,使用原子操作

优化 1:切分策略调整

# 错误:简单方式:非reduce轴映射多核
grid = lambda meta: (triton.cdiv(M, meta['BLOCK_SIZE_M']),)

# 正确:优化方式:reduce轴映射多核
grid = lambda meta: (triton.cdiv(N, meta['BLOCK_SIZE_N']),)

# Kernel内对列进行二次切分
for n_start in range(0, BLOCK_SIZE_N, SUB_BLOCK_SIZE_N):
    n_offsets = pid * BLOCK_SIZE_N + n_start + tl.arange(0, SUB_BLOCK_SIZE_N)

优化 2:原子操作

方案一:循环内原子操作

for m_start in range(0, M, BLOCK_SIZE_M):
    row_min = tl.min(curr_min, 1)
    tl.atomic_min(output_ptrs, row_min, mask=mmask)

方案二:循环外原子操作

all_row_min = tl.full((M,), float('inf'), dtype=tl.float32)
for m_start in range(0, M, BLOCK_SIZE_M):
    row_min = tl.min(curr_min, 1)
    all_row_min = tl.insert_slice(all_row_min, row_min, ...)
tl.atomic_min(output_ptrs, all_row_min)

优化 3:配置

@triton.autotune(
    configs=[
        # grid=32<40, UB用满
        triton.Config({'BLOCK_SIZE_M': 8, 'BLOCK_SIZE_N': 8192, 'SUB_BLOCK_SIZE_N': 1024}),
        triton.Config({'BLOCK_SIZE_M': 16, 'BLOCK_SIZE_N': 8192, 'SUB_BLOCK_SIZE_N': 512}),
    ],
    key=[...],
    restore_value=['out_ptr0'],  # autotune 必须加 restore_value
)

总结

非reduce轴很小、reduce轴很大时,将reduce轴映射到多核并结合原子操作,通过二次切分避免超出UB。

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. 13d ago First seen · 66 lines · 81 tokens per session scan A 139ee9621f06

Subscribe to this mod's changes

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

triton-ascend-case-reduction-mean-medium

A guide to optimizing medium-sized mean operations that reduce values along the first axis of a tensor.

wenyi-li/awesome-agent-kernel-skills · 82 tokens

triton-ascend-case-reduction-prod-small

A guide to optimizing small product reductions, which multiply a group of tensor values into one result.

wenyi-li/awesome-agent-kernel-skills · 95 tokens

triton-ascend-case-reduction-sum-large

A guide to optimizing large two-dimensional sum reductions when the non-reduced axis is very large and the reduced axis is medium-sized.

wenyi-li/awesome-agent-kernel-skills · 92 tokens

pypto-case-matvec

A matrix–vector multiplication workaround for cases where K is greater than 65,535. It replaces matrix multiplication with element-by-element multiplication followed by summing.

wenyi-li/awesome-agent-kernel-skills · 32 tokens

instrument-data-to-allotrope

Convert laboratory instrument output files (PDF, CSV, Excel, TXT) to Allotrope Simple Model (ASM) JSON format or flattened 2D CSV. Use this skill when scientists need to standardize instrument data for LIMS systems, data lakes, or downstream analysis. Supports auto-detection of instrument types. Outputs include full…

anthropics/knowledge-work-plugins · 123 tokens

matlab

Build, review, migrate, and safely plan MATLAB or GNU Octave numerical workflows, including arrays, tabular/time data, tests, projects, graphics, MAT files, and explicit Python interoperability.

K-Dense-AI/scientific-agent-skills · 42 tokens