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 pypto-optimizationgit 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/pypto-optimization)<a href="https://agentmods.dev/skills/mindspore-ai/akg/pypto-optimization"><img src="https://agentmods.dev/badge/skills/mindspore-ai/akg/pypto-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.
<a href="https://agentmods.dev/skills/mindspore-ai/akg/pypto-optimization"><img src="https://agentmods.dev/badge/skills/mindspore-ai/akg/pypto-optimization.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.00063 | $0.04080 |
| Opus 5.5 | $0.00025 | $0.01632 |
| Sonnet 5.5 | $0.00013 | $0.00816 |
| Haiku 4.5 | $0.00006 | $0.00408 |
Grade A, and why
pypto-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 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 — 219 lines — stays where its author put it; the contents beside it link to each section on GitHub.
PyPTO 性能优化(持续补充)
规则 1:连续搬运先达阈值,再在归约轴找甜点
对包含归约的算子(softmax、logsoftmax、sum/amax/amin,以及 mean=sum/count 语义)按以下优先级:
- 对固定题型
shape=(16,256,256), dim=1,默认模板直接用set_vec_tile_shapes(1, 16, 256)。 - 先满足硬约束:
prod(tile_shape) <= 16384且auto_tiles <= 2048。 - 若
auto_tiles > 2048,优先引入loop + view/assemble分块,再做 tile 微调。 - 若编译/验证出现 UB 或 OoOSchedule 相关报错,优先降
prod(tile_shape)(常见从16384 -> 8192 -> 4096)。 - 先让连续搬运达经验阈值:
contiguous_bytes(tile) >= 1KB(经验值,第一性能门槛)。 - 在同等可编译约束下,未达 1KB 的候选默认淘汰,不能仅因“规约轴不分段”直接入选。
- 只有当可编译候选都达不到 1KB 时,才在
<1KB候选中比较规约轴分段与实测。 - 达到阈值后,不要默认“规约轴越大越快”;对规约轴 tile 做候选实测(默认顺序
16 -> 32 -> 64),按实测选甜点。 - tile 不浪费:优先让每一维
tile[i] <= shape[i]。tile[i]远大于对应维度通常不会增加有效并行,反而会浪费 tile 预算并抬高 auto-tiling 开销。 - 禁止误读:不是“越连续越好”也不是“归约轴不切分”。连续搬运达标后,目标转为减少规约分段,而不是继续放大非规约轴 tile。
其中(关键,禁止误算):
contiguous_bytes(tile) = contiguous_tile_elems * dtype_bytescontiguous_tile_elems指一次连续搬运段里的 tile 元素数,不是原始shape元素数。- Vec 场景默认按最后一维估算:
contiguous_tile_elems = tile[last_axis](不做转置/置换时)。 - 连续搬运阈值判定前,优先满足
tile[last_axis] <= shape[last_axis];不要通过tile > shape做“折算达标”。 - FP32 常用阈值:
contiguous_tile_elems >= 256(约 1KB) - FP16/BF16 常用阈值:
contiguous_tile_elems >= 512(约 1KB) - 反例:
shape=(16,256,256), dim=1, tile=(1,256,64)时,连续搬运按tile[2]=64算,仅64*4=256B,未达到 1KB。
原因
- 连续搬运不足时,访存碎片和跨步开销会先成为瓶颈。
- 连续搬运达到高效区后,进一步放大通常边际收益很低。
- 归约轴 tile 过大时,单 task 可能过胖(局部归约树更重、寄存器/流水压力更高)。
- 归约轴 tile 过小时,分段与合并开销会上升。
- 因此常见是非单调关系(U 型),需要在达标候选中找甜点,而不是单调追大。
示例 A:Softmax (16, 16384), dim=1
set_vec_tile_shapes(1, 8192):每行 2 段(优先)set_vec_tile_shapes(2, 4096):每行 4 段set_vec_tile_shapes(4, 4096):每行 4 段,且更多预算给了非归约轴
经验上,(1, 8192) 通常优于 (2, 4096) 和 (4, 4096)。
示例 B:Reduction (16, 64, 256, 256), dim=1
set_vec_tile_shapes(1, 16, 1, 256)/(1, 32, 1, 256)/(1, 64, 1, 256):均满足连续搬运达标,需做甜点比较。set_vec_tile_shapes(1, 1, 16, 256):虽然连续搬运达标,但归约轴未被有效利用,通常是劣候选。
这个例子体现了层级规则:连续搬运先达标,达标后做归约轴甜点搜索。
示例 C:TripletMarginLoss Phase-1 (128, 4096), dim=1
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 · 219 lines · 63 tokens per session scan A f57f2afea546
pypto-optimization is a skill published in the GitHub repository mindspore-ai/akg (269 stars, last pushed yesterday), licensed Apache-2.0. It adds 63 tokens to every session and 4,080 once invoked, about $0.0003 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.
pypto-optimization compared with skills from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| pypto-optimizationmindspore-ai/akg | Skill | 269 | yesterday | Apache-2.0 | A | 63 | Claude Code, Codex |
| agent-platform-model-registrygoogle/skills | Skill | 26k | yesterday | Apache-2.0 | A | 60 | Claude Code, Codex |
| llm-evaluationsickn33/agentic-awesome-skills | Skill | 51k | today | MIT | A | 25 | Claude Code |
| google-cloud-solution-agentic-analytics-spark-knowledge-cataloggoogle/skills | Skill | 26k | yesterday | Apache-2.0 | A | 132 | Claude Code, Codex |
| training-checkwanshuiyin/Auto-claude-code-research-in-sleep | Skill | 20k | 4d ago | MIT | A | 35 | Claude Code |
| tao-run-inference-serviceNVIDIA/skills | Skill | 4.4k | yesterday | Apache-2.0 | A | 92 | Claude Code |
| nemo-automodel-launcher-configNVIDIA/skills | Skill | 4.4k | yesterday | Apache-2.0 | A | 30 | Claude Code |