Agent skill

Tilelang Perf Optimization

by tile-ai in tile-ai/tilelang-ascend

TileLang 算子性能调优与潜在性能劣化模式检查。提供性能数据采集、瓶颈诊断、优化实施、效果验证能力;也用于生成或评审算子时对照常见性能劣化模式示例检查当前 kernel 代码。触发:算子精度通过后需要优化性能、性能不及预期时。

MITAuto-check passed

Install Tilelang Perf Optimization

skills CLI
$ npx skills add tile-ai/tilelang-ascend --skill tilelang-perf-optimization -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install tile-ai/tilelang-ascend tilelang-perf-optimization --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/tile-ai/tilelang-ascend.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/tilelang-perf-optimization .claude/skills/tilelang-perf-optimization && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
tilelang-perf-optimization
GitHub stars
402
Token cost
~1.2k tokens
SKILL.md length
237 words
Files
9 (incl. references)
Skills in repo
20
Repo updated
First seen
Licence
MIT

At a glance

TileLang 算子性能调优与潜在性能劣化模式检查。提供性能数据采集、瓶颈诊断、优化实施、效果验证能力;也用于生成或评审算子时对照常见性能劣化模式示例检查当前 kernel 代码。触发:算子精度通过后需要优化性能、性能不及预期时。

  • Works in 5 steps: 基线采集 → 算子类型判断 → 识别优化点(强制,禁止与 Step 4 合并) → …
  • SKILL.md covers 工作流程, 核心约束, 参考文档 and 执行步骤, plus 1 more section
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Tilelang Perf Optimization is an agent skill from tile-ai/tilelang-ascend. TileLang 算子性能调优与潜在性能劣化模式检查。提供性能数据采集、瓶颈诊断、优化实施、效果验证能力;也用于生成或评审算子时对照常见性能劣化模式示例检查当前 kernel 代码。触发:算子精度通过后需要优化性能、性能不及预期时。

Its SKILL.md is about 1.2k tokens, which your agent loads only when the skill is triggered. The skill folder holds 11 other files, including reference files (for example `references/best-practices/cube_optimization_path.md`, `references/best-practices/flash_attn_optimize.md` and `references/best-practices/gemm_intrinsic_optimize.md`).

The repository describes itself as: Ascend TileLang adapter. The licence is MIT.

Example prompts

  • “/tilelang-perf-optimization”

Requirements

  • Python 3

Workflow steps

5 steps, taken from the step headings in SKILL.md.

  1. 基线采集
  2. 算子类型判断
  3. 识别优化点(强制,禁止与 Step 4 合并)
  4. 逐项实施
  5. 效果验证

What it can do on your machine

Read from SKILL.md and the folder at commit 83b0ece. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are bash and python).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Tilelang Perf Optimization loads about 1.2k tokens when it runs, and up to ~45k if it reads all its reference files. Until then it costs about 36 tokens; SKILL.md has 237 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~36
When it runs · the whole SKILL.md, loaded when a task matches
~1.2k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~45k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from tile-ai/tilelang-ascend at commit 83b0ece, republished under its MIT licence (© tile-ai). 237 words, ~1,204 tokens.

Download SKILL.mdSave it as .claude/skills/tilelang-perf-optimization/SKILL.md (or your agent's skills folder). This skill also uses 8 other files; get the full folder from GitHub.
name
tilelang-perf-optimization
description
TileLang 算子性能调优与潜在性能劣化模式检查。提供性能数据采集、瓶颈诊断、优化实施、效果验证能力;也用于生成或评审算子时对照常见性能劣化模式示例检查当前 kernel 代码。触发:算子精度通过后需要优化性能、性能不及预期时。

TileLang 性能优化

工作流程

Step 1: 基线采集(性能 + 精度)
  → Step 2: 算子类型判断
  → Step 3: 阅读参考文档并识别优化点(输出到 optimization_log.md)
  → Step 4: 逐项实施优化点
  → Step 5: 效果验证(性能 + 精度)

核心约束

  • 逐项实施:每次 Edit 只改一个优化点,改完立即验证
  • 精度优先:精度未通过禁止性能优化
  • 性能验证:必须使用 msprof op,禁止用 Python/Torch 计时
  • Host 轻量化:禁止 host 侧全量数据搬运(F.pad、.contiguous()、.to(dtype) 等),必须移入 kernel

参考文档


执行步骤

Step 1: 基线采集

在 examples/{op_name}/ 下查找含 @tilelang.jit 的脚本,运行:

bash
msprof op --kernel-name="main_kernel" --output=./msprof_output python ./examples/{op_name}/<script_name>.py

精度未通过 → 禁止后续步骤。

Step 2: 算子类型判断

生成翻译后的 Ascend C 代码:

在算子脚本中,JIT 编译返回的函数对象调用 get_kernel_source() 可获取翻译后的 Ascend C 代码:

python
func = jit_func(batch=B, seq_len=S, ...)
print(func.get_kernel_source())

运行脚本后,从输出中搜索关键字判断算子类型:

判断依据类型典型算子
IS_ASCEND_AIC 出现Cube 型GEMM、MatMul、Linear
IS_ASCEND_AIV 出现Vector 型RoPE、Softmax、Add
两者均出现混合型FlashAttention、SparseFlashAttention
Step 3: 识别优化点(强制,禁止与 Step 4 合并)

先读取 optimization-guide.md 的目录和各章节标题 + performance-antipatterns.md 的各条目标题,根据算子类型(Step 2 判定)和算子实现特征初步筛选出可能适用的优化点清单。再针对每个候选优化点,读取其"适用场景"、"约束"、"使用条件"等描述,确认是否真正适用。如果是 cube 核额外参考 best-practices/cube_optimization_path.md,如果是 vector 核额外参考 vector-practices/ 目录下的文档。

在 optimization_log.md 中输出:

Part A 优化点清单:逐条标注适用/不适用 + 原因 + 参考文件行号。pass_configs 不是独立优化点,是伴随修改。

[#1] [名称](参考: optimization-guide.md L445-L650 §2.13):[适用/不适用] — [原因]

若候选会扩大现有 kernel 的调用域(新增 shape、batch、dtype、尾块或多 stage), Part A 必须先写:

text
[KERNEL-REUSE-PRECHECK]
candidate: <优化点及 reference 章节>
expanded_domain: <新增调用域>
compatibility_dimensions: <从该章节读取,不自行猜测>
unknown_or_false: <none/列表>
plan: direct-reuse / repair-kernel-first / new-kernel-first

存在 unknown/false 时,ORDER-PLAN 不得写 direct reuse。

重点:每节都需读取其"适用场景"和"约束"描述确认是否适用。仅当章节标题明确标注了特定算子类型专属(如"Cube 核")且当前算子不属于该类型时,才可初步排除;其余所有章节必须读约束确认,不得仅凭标题或算子类型跳过。

Part B [ORDER-PLAN]:分析依赖关系,排出实施顺序链。依赖分析三条规则:

  1. 布局依赖:改变 layout 的优化排在依赖此 layout 的优化之前
  2. 数量依赖:涉及预算的优化排在改变 buffer 数量的优化之后
  3. 配置依赖:涉及 pass_configs 的优化在相关功能实施后才改动
[ORDER-PLAN] 实施顺序:
1. [#N] [名称] — 前置依赖: [无] — 理由: [...]
2. [#M] [名称] — 前置依赖: [#N] — 理由: [...]
Step 4: 逐项实施

固定优先级:先静态分析(对照 performance-antipatterns.md),再 P0 Host 侧优化(optimization-guide.md §2.12)。P0 完成后 Host 侧只允许零拷贝形状变换。

后续优化点按 [ORDER-PLAN] 逐个实施,每个走 6 子步骤:

0: ORDER-CHECK → A: Read 文档 → B: Edit 代码 → C: msprof op 验证 → D: 记录结果 → (失败) E: 重读文档修复

门禁:[ORDER-CHECK] 未写禁止 Read;[IMPL-#N] 未写禁止 Edit;[RESULT-#N] 未写禁止下一个。

Edit 调用方、dispatch 或 planner 前,再写 [KERNEL-REUSE-AUDIT] 复核候选章节规定的 兼容性维度。任一项仍为 unknown/false,先修复或新建 kernel,并单独验证后再扩大调用域。 不同优化点使用各自 reference 章节的维度,不套用其他优化的专属字段。

日志格式:

[ORDER-CHECK] 准备实施: [#N] [名称] | 前置依赖: [#1 ✅ / #2 ❌] | 结论: [✅/❌]
[IMPL-#N] 已阅读 <文件> L行号(§X.X),关键约束: ...
[KERNEL-REUSE-AUDIT] 依据: <章节> | 维度及结论: <...> | 结论: <reuse/repair/new>
[SELF-CHECK] 本次 Edit 只涉及 [#N]
[RESULT-#N] 优化点: [名称] | 精度: [pass/fail] | 性能: [X us] | 对比: [+/-X%]

Double Buffer 特殊要求:实施前必须完成 [DB-ANALYSIS](Q1: 循环内有 MTE3?Q2: 有跨迭代累加器?Q3: 选同步方式),未完成禁止写代码。

最佳实践参考:

算子类型文档核心优化技术
Vector 型RoPE 优化、归约遍数融合NPU 内动态生成 Mask、Tile API 向量化、参数简化
Cube 型GEMM Intrinsic多缓冲流水线、细粒度 Flag 同步、MMA intrinsic、L0 分块、负载均衡
CV 融合型Flash Attentionnum_stages 流水线、批量 Softmax、Cross-core Semaphore、数据布局优化;多 shape 适配(BSND 免转置、Sq==1 decode 窄块、加性 mask 屏蔽变长 Skv)
Step 5: 效果验证

每个优化点后执行:精度验证 → msprof op → 记录 → 对比基线。精度失败时保持优化调试,不撤销。

调试手段:T.printf、T.dump_tensor、get_kernel_source(),详见 Programming Guide。

迭代终止:达到目标或连续 3 次无提升则中断上报。


优化记录

保存在 examples/{op_name}/perf_tuning/:

  • baseline.json - 基线性能
  • optimization_log.md - 优化记录
  • final_report.md - 最终报告

© tile-ai, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 8 other files (references) in .agents/skills/tilelang-perf-optimization of tile-ai/tilelang-ascend.

  • SKILL.md
  • references/best-practices/cube_optimization_path.md
  • references/best-practices/flash_attn_optimize.md
  • references/best-practices/gemm_intrinsic_optimize.md
  • references/best-practices/rope-developer-mode.md
  • references/best-practices/vector_add_pipeline.md
  • references/optimization-guide.md
  • references/performance-antipatterns.md
  • references/vector-practices/vector_reduce_pass_fusion.md

Open the folder on GitHubat commit 83b0ece

Compare with similar skills

Tilelang Perf Optimization next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Tilelang Perf Optimization compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Tilelang Perf Optimization this skilltile-ai/tilelang-ascend402—~1.2kAutomated safety check: PassMIT
Liger Kernel Perflinkedin/Liger-Kernel6.7k—~1.5kAutomated safety check: PassBSD-2-Clause
Tilegym Improve Cutile Kernel PerfNVIDIA/skills3.5k—~2kAutomated safety check: PassApache-2.0
Kernel Organizationsgl-project/sglang37k—~1.3kAutomated safety check: PassApache-2.0
Metal Kernelpytorch/pytorch104k—~4.9kAutomated safety check: PassCustom licence
Perf ComparisonClickHouse/ClickHouse50k—~3.9kAutomated safety check: NotesApache-2.0

Similar skills

  • Liger Kernel Perf

    linkedin/Liger-Kernel

    Optimizes the performance of existing Liger Kernel Triton kernels.

    6.7k GitHub stars~1.5k tokensUpdated today
    AI & LLM EngineeringAuto-check passed
  • Official

    Iteratively optimize cuTile kernel performance through systematic profiling, bottleneck analysis, IR comparison, and targeted tuning.

    3.5k GitHub stars~2k tokensUpdated today
    DevelopmentAuto-check passed
  • Kernel Organization

    sgl-project/sglang

    Apply the SGLang kernels RFC when adding, moving, splitting, or reviewing kernel APIs, registry metadata, kernel tests, benchmarks, and model-specific implementations.

    37k GitHub stars~1.3k tokensUpdated today
    AI & LLM EngineeringAuto-check passed
  • Metal Kernel

    pytorch/pytorch

    Write Metal/MPS kernels for PyTorch operators. An agent skill from pytorch/pytorch.

    104k GitHub stars~4.9k tokensUpdated today
    AI & LLM EngineeringAuto-check passed
  • Perf Comparison

    ClickHouse/ClickHouse

    Evaluate ClickHouse performance test results from existing CI/dashboard data or local perf.py runs.

    50k GitHub stars~3.9k tokensUpdated today
    DatabasesAuto-check: notes
  • Semantic Kernel

    github/awesome-copilot

    Official

    Create, update, refactor, explain, or review Semantic Kernel solutions using shared guidance plus language-specific references for .NET and Python.

    40k GitHub starsUsed in 1 repo~756 tokens
    DevelopmentAuto-check passed

More from tile-ai/tilelang-ascend

All 20 skills in this repo
  • Tilelang Submodule Pull

    tile-ai/tilelang-ascend

    Automatically pull tilelang repository and its third-party code.

    402 GitHub stars~1.5k tokensUpdated today
    Auto-check passed
  • Tilelang Debug Helper

    tile-ai/tilelang-ascend

    How to add debugging capabilities to TileLang Ascend example operators.

    402 GitHub stars~1.7k tokensUpdated today
    Auto-check: notes
  • Tilelang A5 Sim Convert

    tile-ai/tilelang-ascend

    将 tilelang example 脚本转换为可在 A5 camodel 仿真器上直接运行的版本。输入脚本路径,输出一个新的 sim.py 文件,不覆盖原始文件。触发:仿真运行、camodel、A5 仿真、sim 模式、转换脚本为仿真、不需要 NPU 跑 kernel、simulate A5。

    402 GitHub stars~1.1k tokensUpdated today
    Auto-check passed
  • Tilelang Env Check

    tile-ai/tilelang-ascend

    TileLang-Ascend 环境检查与配置验证技能。检查代码仓库完整性、编译安装状态、环境变量配置,并运行简单测试验证环境。发现问题会自动调用相关 skill 进行修复,并按依赖顺序重新执行后续步骤。触发关键词:"环境检查"、"检查环境"、"验证环境"、"环境配置"、"环境搭建"、"env check"、"check environment"、"verify…

    402 GitHub stars~3.4k tokensUpdated today
    Auto-check passed
  • Tilelang Op Test Design

    tile-ai/tilelang-ascend

    TileLang-Ascend 算子测试设计技能。支持多种场景:(1) 从 design.md 设计测试配置 (2) 从 examples/{op}/.py 补充测试 (3) 手动提供算子信息生成测试 (4) 测试覆盖率分析。理解算子实现逻辑后智能判断测试策略。触发:设计算子测试、生成测试用例、补充测试、测试覆盖率不足。

    402 GitHub stars~5.6k tokensUpdated today
    Auto-check passed
  • Tilelang Review

    tile-ai/tilelang-ascend

    检查代码格式是否符合 CI 规则。自动检测并安装缺失工具(ruff、clang-format),先运行检查生成报告,使用醒目方式询问用户后,仅在用户同意时执行修复。工作流程:检测环境→自动安装缺失工具→运行检查→生成报告→醒目询问→用户确认→执行修复。使用此技能当:用户要求"格式检查"、"格式化代码"、"代码格式化"、"检查代码格式"、"代码…

    402 GitHub stars~2.8k tokensUpdated today
    Auto-check: notes

Questions about Tilelang Perf Optimization

What does Tilelang Perf Optimization do?

TileLang 算子性能调优与潜在性能劣化模式检查。提供性能数据采集、瓶颈诊断、优化实施、效果验证能力;也用于生成或评审算子时对照常见性能劣化模式示例检查当前 kernel 代码。触发:算子精度通过后需要优化性能、性能不及预期时。. Tilelang Perf Optimization is an agent skill from tile-ai/tilelang-ascend.

How do I install Tilelang Perf Optimization in Claude Code?

Run `npx skills add tile-ai/tilelang-ascend --skill tilelang-perf-optimization -a claude-code`. Or copy the skill folder (.agents/skills/tilelang-perf-optimization in tile-ai/tilelang-ascend) into .claude/skills/tilelang-perf-optimization in your project. Claude Code loads it when a task matches its description.

How do I install Tilelang Perf Optimization in Codex?

Run `npx skills add tile-ai/tilelang-ascend --skill tilelang-perf-optimization -a codex`. Or copy the skill folder (.agents/skills/tilelang-perf-optimization in tile-ai/tilelang-ascend) into .agents/skills/tilelang-perf-optimization in your project. Codex loads it when a task matches its description.

Can I use Tilelang Perf Optimization in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add tile-ai/tilelang-ascend --skill tilelang-perf-optimization -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/tilelang-perf-optimization, .gemini/skills/tilelang-perf-optimization, .github/skills/tilelang-perf-optimization and .opencode/skills/tilelang-perf-optimization in your project.

What does Tilelang Perf Optimization need to run?

SKILL.md names no scripts, command-line tools or credentials: Tilelang Perf Optimization is instructions for the agent only. Our summary lists: Python 3.

Does Tilelang Perf Optimization access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Tilelang Perf Optimization safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Tilelang Perf Optimization use?

Tilelang Perf Optimization is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Tilelang Perf Optimization use?

About 1.2k tokens (SKILL.md is roughly 4.8k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 44k tokens, read only when the agent opens those files.

What are the alternatives to Tilelang Perf Optimization?

Skills that share tags, products or a category with Tilelang Perf Optimization: Liger Kernel Perf (linkedin/Liger-Kernel, 6.7k stars), Tilegym Improve Cutile Kernel Perf (NVIDIA/skills, 3.5k stars), Kernel Organization (sgl-project/sglang, 37k stars) and Metal Kernel (pytorch/pytorch, 104k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Tilelang Perf Optimization?

tile-ai (a GitHub organization) maintains it in tile-ai/tilelang-ascend, which has 402 GitHub stars. The repository holds 20 skills in this directory. The repository was last updated on October 9, 2026.

Source: tile-ai/tilelang-ascend on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.