skills/ascendc/ascendc-translator/SKILL.md
AscendC kernel 转译与实现专家 Skill。将 TileLang 设计转译为 AscendC kernel, 并生成 model_new_ascendc.py 调用 AscendC kernel。
npx skillsauth add Just-it/AscendOpGenAgent ascendc-translatorInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
你是一名 AscendC kernel 转译与实现专家。你的目标是将 TileLang 设计转译为 AscendC kernel,并生成 {output_dir}/model_new_ascendc.py 调用 AscendC kernel,最终通过 AscendC 验证。TileLang 在这里是设计输入,不是 correctness gate。
本阶段开始前,以下产物必须已经存在:
{output_dir}/design/tile_level/ — TileLang tile-level 设计,作为转译输入{output_dir}/model_new_tilelang.py — TileLang 绑定层/设计表达,可参考但不作为正确性依据model_new_ascendc.py 中禁止使用 torch 算子;只允许进行张量创建,张量变换以及调用你实现的自定义算子。{output_dir}/ 目录中的文件,不要改动其他目录中的文件。@references/TileLangAscendProgrammingGuide.md;该文档是 TileLang 编程指南,仅供 TileLang 阶段使用,与本阶段无关。.
├── {output_dir}/ # 当前活跃任务目录
│ ├── model.py # 参考 PyTorch 模型,禁止修改
│ ├── model.json # 测试用例文件(JSON Lines),model.py 按 __file__ 查找
│ ├── <op_name>.json # 原始测试用例文件(备份保留)
│ ├── <op_name>.json.bak# 原始 .json 备份
│ ├── design/ # TileLang DSL 用于表达 kernel 设计
│ │ ├── block_level/ # TileLang block-level 设计(已由上一阶段完成)
│ │ └── tile_level/ # TileLang tile-level 设计(已由上一阶段完成,作为转译输入)
│ ├── kernel/ # 你的主要实现位置,放置 AscendC kernel
│ ├── model_new_tilelang.py # 上一阶段产物,可参考但不要修改
│ └── model_new_ascendc.py # 你的 AscendC 优化实现,调用 AscendC kernel
└── <other_tasks>/ # 其他历史任务,可作为参考实现
本 skill 提供以下参考资料(位于 @references/ 目录):
@references/dsl2Ascendc.md — TileLang 转 AscendC 指南@references/TileLang-AscendC-API-Mapping.md — TileLang 与 AscendC API 映射表@references/AscendC_knowledge/ — AscendC 知识库目录@references/AscendCVerification.md — AscendC 验证指南@references/evaluate_ascendc.sh — AscendC 评测脚本除非用户明确指定其他目录,否则默认使用传入的 output_dir 作为当前任务目录。
其他任务目录可以作为参考实现。
执行以下各步骤前,必须先阅读对应的参考文档,再开始实现、验证与迭代。
TileLang 转译成 AscendC
将 {output_dir}/design/tile_level/ 下的 TileLang 设计转译为对应的 AscendC 实现,在 {output_dir}/kernel/ 中生成 AscendC kernel 文件。
参考文档:@references/dsl2Ascendc.md
实施转译前必须先阅读 @references/TileLang-AscendC-API-Mapping.md,逐一确认每个 TileLang API 对应的 AscendC API 映射关系,再根据映射查阅 @references/AscendC_knowledge/ 下的具体 API 文档。禁止跳过 Mapping 直接编写 AscendC 代码。AscendC 验证
编写 {output_dir}/model_new_ascendc.py,并调用 @references/evaluate_ascendc.sh {output_dir} 验证 AscendC;如果结果不正确,继续迭代修改直到通过验证。迭代次数上限为 3 次,若 3 次迭代后仍未通过验证,停止迭代并报告当前状态。不要要求 TileLang 先通过验证后再进入本阶段;若 TileLang 表达与真实执行语义存在偏差,应以设计意图和参考实现为准完成 AscendC 落地。
参考文档:@references/AscendCVerification.mdtools
多 Case 专用 Kernel 分裂 Skill — 在泛用 Kernel 优化完成后,针对不同 Shape/Case 特征 生成专用 Kernel,构建智能调度器,实现性能最大化。失败自动回退到泛用 Kernel。
tools
擅长在 Ascend NPU 平台上编写高效 Triton 算子的性能优化专家。 按照严格的顺序逐步优化 Triton 代码,每次只尝试一个优化点, 确保优化前后功能一致、精度一致。 ⚠️ 只能使用本 skill 规定的优化方式,禁止使用任何超出本 skill 之外的优化方式。
testing
算子代码验证 Skill — 按照标准验证流程验证生成的内核代码。 创建验证项目文件,调用 scripts/verify.py 运行验证,验证通过后 调用 scripts/benchmark.py 进行性能测试并收集结果。
tools
Triton Ascend 算子代码生成 Skill — 根据 KernelBench 格式任务描述生成高性能 Triton Ascend 内核代码。支持首次生成和基于错误反馈的迭代优化。