一键导入
triton-npu-kernel-opt
>-
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
>-
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | triton-npu-kernel-opt |
| description | >- |
Backend: ttx in mojo_opset
This skill is for end-to-end delivery of a new or updated Triton kernel on Ascend NPU. It is not only an optimization note. It defines the required workflow for:
coretorch or torch_npu implementation already existsFollow this order. Do not skip steps.
coreInspect the relevant API first:
mojo_opset/core/operators/mojo_opset/core/functions/You need a stable semantic contract before writing a backend kernel.
If there is no corresponding core operator/function, or there is no usable
torch reference implementation for semantics and correctness comparison, stop
and tell the user exactly what is missing. Ask the user to provide or approve
the missing core/torch implementation first.
Practical rule:
core contract + existing torch reference: proceedcore contract but no torch reference: proceed only if there is a
torch_npu implementation or a trusted mathematical reference you can test
against; otherwise ask the user to provide onecore contract: do not invent API semantics silentlyBefore writing any new NPU kernel, read all relevant existing optimized NPU kernels in this repository. Start with:
At minimum, inspect:
Do not treat the new kernel as greenfield work if the repo already solved a similar scheduling, layout, or validation problem elsewhere.
Use the curated guides as the primary documentation layer. Prefer English only.
Start with:
Load only the sections needed for the current task:
Use only the distilled local references that have a clear role:
Inspect the full dispatch path before coding:
mojo_opset/backends/ttx/operators/mojo_opset/backends/ttx/kernels/npu/mojo_opset/backends/torch_npu/operators/mojo_opset/backends/ttx/kernels/npu/__init__.pyThe questions to answer are:
ttx operator class for this core op?torch_npu backend path to use as a baseline?torch.ops.ttx.*, a Mojo* operator, or both?Default assumptions for Ascend NPU:
num_stages > 1 do not automatically transferStart from proven patterns in existing NPU kernels before inventing a new schedule.
For GEMM-like kernels, read only:
For non-GEMM kernels, start from:
A kernel is not done when the Triton body compiles.
Finish all needed integration work:
backends/ttx/kernels/nputtx operator/function backend if requiredtorch implementation as the correctness referencetorch_npu implementation as a native-performance baseline when it
existsUse:
Do not present a new NPU kernel as complete unless all applicable checks pass.
You must validate against a trusted reference:
torch backend first when availabletorch_npu native operator or mathematically equivalent referenceMinimum expectations:
Use existing accuracy tests where possible. Extend them when the current shape
set does not cover the new behavior.
If the kernel surfaces through torch.ops.ttx.*, add or update opcheck tests in
mojo_opset/tests/test_ttx_graph/.
You must run performance validation, not only correctness.
Compare against the strongest available baseline:
ttx kernel, if replacing onetorch_npu native implementation, if it existstorch reference only as a correctness baseline, not as the final
performance targetRecord or summarize:
Treat the kernel as accepted only when all of the following are true:
coretorch.ops.ttx.* is involvedIf performance is worse but the kernel is still needed for coverage, state that explicitly and keep the gap quantified.
When new NPU-specific findings appear:
SKILL.md