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.
npx skills add mindspore-ai/akg --skill triton-ascend-case-matmul-large-kgit clone --depth 1 https://github.com/mindspore-ai/akgWrote 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.
[](https://agentmods.dev/skills/mindspore-ai/akg/triton-ascend-case-matmul-large-k)<a href="https://agentmods.dev/skills/mindspore-ai/akg/triton-ascend-case-matmul-large-k"><img src="https://agentmods.dev/badge/skills/mindspore-ai/akg/triton-ascend-case-matmul-large-k/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.
<a href="https://agentmods.dev/skills/mindspore-ai/akg/triton-ascend-case-matmul-large-k"><img src="https://agentmods.dev/badge/skills/mindspore-ai/akg/triton-ascend-case-matmul-large-k.svg" alt="Reviewed on agentmods" width="80" height="20"></a>- NVIDIA SkillSpector pass
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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00101 | $0.01358 |
| Opus 5.5 | $0.00040 | $0.00543 |
| Sonnet 5.5 | $0.00020 | $0.00272 |
| Haiku 4.5 | $0.00010 | $0.00136 |
Grade A, and why
triton-ascend-case-matmul-large-k 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 3mo 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.
How it starts
The opening of the file, as written. The whole thing — 100 lines — stays where its author put it; the contents beside it link to each section on GitHub.
大 K 维度矩阵乘法优化案例
任务特征
- 操作类型:矩阵乘法 A[M, K] @ B[K, N] = C[M, N]
- 典型数据尺寸:A[256, 131072] @ B[131072, 256] = C[256, 256]
- 特点:K 远大于 M 和 N(K/M = 512 倍),输出块数远少于核心数,常规 matmul 核心利用率低
核心问题
M=256, N=256, K=131072, BLOCK_M=64, BLOCK_N=64:
输出块数 = ceil(256/64) × ceil(256/64) = 4 × 4 = 16
可用核数 = 32
→ 16 块 < 32 核, 一半核空闲!
→ 每个核的 K-loop = 131072/256 = 512 次, 单核计算量极大
优化 1:Split-K + Atomic Add 并行化
原理
当输出块数 < 核心数时,将 K 维度切分成 SPLIT_K 段,让多个核并行计算同一输出块的不同 K 区间,用 tl.atomic_add 将划分后的partial结果累加到 C。另外,如果把SPLIT_K参数放在 grid 中,调整核数,可以使得无核空转。
# grid = (NUM_MN_BLOCKS, SPLIT_K)
# 例如:AI_Cude=32,M=N=256, BLOCK=128: NUM_MN_BLOCKS = 2*2 = 4
# grid = (4, 16) → 64 , 32核每核处理2块数据
@triton.jit
def matmul_splitk_kernel(A_ptr, B_ptr, C_ptr, M, N, K, ...,
BLOCK_M: tl.constexpr, BLOCK_N: tl.constexpr,
BLOCK_K: tl.constexpr):
pid = tl.program_id(0) # 输出块 ID
split_id = tl.program_id(1) # K 分段 ID
acc = tl.zeros((BLOCK_M, BLOCK_N), dtype=tl.float32)
for k_idx in range(k_block_start, k_block_end):
a = tl.load(A_ptr + ...)
b = tl.load(B_ptr + ...)
acc += tl.dot(a, b)
# 原子加: 多个 split 的 partial 直接累加到 C
tl.atomic_add(C_ptr + ..., acc, mask=...)
核心要点
- grid数的配置应接近或超过核心数,确保核满载
SPLIT_K越大并行度越高,但 atomic_add 竞争也越多
优化 2:Workspace + Reduce
原理
全局同步(如 tl.debug_barrier)会让所有核在同一点等待,等同于将 CUBE 计算和 VEC 归约完全串行化,性能极差。这里不像 AscendC 有 AIC/AIV 硬件并行操作实现,核内直接将 CUBE 结果写到 workspace,然后外部调用Reduce进行归约。另外,workspace的大小应该尽可能的装满,不要申请的过大。
@triton.jit
def matmul_splitk_to_ws_kernel(A_ptr, B_ptr, WS_ptr, M, N, K, ...,
BLOCK_M: tl.constexpr, BLOCK_N: tl.constexpr,
BLOCK_K: tl.constexpr):
pid = tl.program_id(0)
split_id = tl.program_id(1)
# ... K 分段计算 ...
acc = tl.zeros((BLOCK_M, BLOCK_N), dtype=tl.float32)
for k_idx in range(k_block_start, k_block_end):
acc += tl.dot(tl.load(A_ptr + ...), tl.load(B_ptr + ...))
# 直接 store 到 workspace, 不做任何归约
tl.store(WS_ptr + split_id * stride_ws_s + ..., acc, mask=...)
# host 端
...
# 归约
C = torch.sum(workspace, dim=0)
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.
- 3mo ago First seen · 100 lines · 101 tokens per session scan A 065127534ff5
triton-ascend-case-matmul-large-k is a skill published in the GitHub repository mindspore-ai/akg (269 stars, last pushed today), licensed Apache-2.0. It adds 101 tokens to every session and 1,358 once invoked, about $0.0004 per session on Opus 5.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.
triton-ascend-case-matmul-large-k compared with skills from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| triton-ascend-case-matmul-large-kmindspore-ai/akg | Skill | 269 | today | Apache-2.0 | A | 101 | Claude Code, Codex |
| triton-ascend-case-reduction-prod-smallwenyi-li/awesome-agent-kernel-skills | Skill | 11 | 6mo ago | none | A | 95 | Claude Code, Codex |
| pypto-case-matvecwenyi-li/awesome-agent-kernel-skills | Skill | 11 | 6mo ago | none | A | 32 | Claude Code, Codex |
| triton-ascend-case-reduction-mean-mediumwenyi-li/awesome-agent-kernel-skills | Skill | 11 | 6mo ago | none | A | 82 | Claude Code, Codex |
| triton-ascend-case-reduction-sum-largewenyi-li/awesome-agent-kernel-skills | Skill | 11 | 6mo ago | none | A | 92 | Claude Code, Codex |
| instrument-data-to-allotropeanthropics/knowledge-work-plugins | Skill | 38k | today | Apache-2.0 | A | 123 | Claude Code |
| exploratory-data-analysisK-Dense-AI/scientific-agent-skills | Skill | 59k | 3d ago | MIT | A | 83 | Claude Code |