AGENT SKILL

tilelang-npu-cann-ext-api-patterns

Expert-mode optimization pattern references for TileLang Ascend NPU kernels that use explicit hardware memory, manual synchronization, and CV scope separation. This skill does not define the optimize workflow; it only provides pattern material for optimize to consume.

License 许可
Apache-2.0
所属仓库
Piagari/helix
最近更新
2026-07-16
Stars
★ 0
Forks
0

01 前言 Front Matter

name
tilelang-npu-cann-ext-api-patterns
description
Expert-mode optimization pattern references for TileLang Ascend NPU kernels that use explicit hardware memory, manual synchronization, and CV scope separation. This skill does not define the optimize workflow; it only provides pattern material for optimize to consume.

02 资源文件 11

03 SKILL.md 正文

TileLang Expert-Mode Optimization Patterns

Purpose

This skill provides pattern references for optimize runs that use the Expert programming model — explicit hardware memory allocation, manual synchronization, and Cube/Vector scope separation.

Scope

  • This skill does not define optimize workflow behavior.
  • The optimize workflow contract remains owned by tilelang-npu-optimize.
  • This skill provides TileLang-specific Expert-mode patterns for performance-critical kernel tuning.
  • Use these patterns when the Developer-mode auto-managed approach is insufficient and the kernel needs precise hardware-level control.

Expert API Reference

This skill uses the Expert programming model. Read the Expert API docs before writing any Expert-mode kernel:

The Developer docs (memory-developer, compute-developer, kernel-basics) cover the shared infrastructure — you should already be familiar with those from convert.

How To Use This Skill

  1. Use this skill only when optimize explicitly stages it.
  2. Read references/pattern_index.md first.
  3. Pick only the most relevant detailed pattern file for the current bottleneck.
  4. Avoid bulk-loading all detailed pattern references unless the kernel genuinely shows multiple independent Expert-mode opportunities.

Lint Verification

Expert-mode kernels with manual sync are error-prone. Always run the sync linter after applying any pattern, before attempting on-device compilation:

python3 scripts/tl_sync_lint.py --tier1 --tier2 --tier3 --tier4 <kernel>.py

The linter has four tiers; map findings to on-device symptoms:

Tier Flag Symptom on device
0 FLAG_IMBALANCE, CROSS_DEADLOCK, NO_INTRA_FENCE Deadlock — AICore timeout (507014), ~10 min hang
1 (--tier1) DATA_RACE Precision / correctness errors — output mismatches ref
2 (--tier2) LATE_RELEASE Throughput-collapse deadlock — buffer-reuse credit released too late
3 (--tier3) PRIME_UNDERFLOW First-iteration deadlock — unconditional wait_flag whose credit is only primed under a guard
4 (--tier4) SHARED_MAILBOX Illegal vec config crash — alloc_shared used as cross-lane mailbox (error 507015)

Tier 0 checks set/wait flag balance (liveness). Tier 1 checks happens-before between cross-pipe buffer accesses. Tier 2 catches deferred-credit late releases. Tier 3 catches first-iteration credit underflow. Tier 4 detects illegal cross-vid memory sharing.

Patterns

All Expert-mode patterns are documented in references/patterns/. Start with pattern_index.md then read the specific pattern file for your bottleneck. If patterns don't cover what you need, explore the full Expert API docs linked above — the memory-expert and compute-expert references cover the complete surface.

Reading Contract

  • Treat this skill as reference material only.
  • Follow optimize workflow, validation, and reporting rules from tilelang-npu-optimize.
  • Use the detailed pattern files only when round evidence supports the rewrite direction.

04 同仓库更多 Skills

Piagari
Piagari/helix

triton-npu-repair-guide

Heuristic fixes for Ascend Triton compile/JIT/kernel errors and numerical precision mismatches when editing or converting the operator. Does not replace ascend-npu-gen-test, ascend-npu-gen-bench, or harness specs.

★ 0
Piagari
Piagari/helix

triton-npu-optimize

Iteratively optimize a Triton Ascend NPU operator with correctness and performance gates. Use for operator optimization tasks that need repeated correctness validation, benchmark validation, multi-round experiment tracking, reusable optimization notes, and profiler-backed performance analysis when benchmark results need deeper explanation.

★ 0
Piagari
Piagari/helix

triton-npu-optimize-knowledge

Generic reference-only optimize knowledge for pattern triage and evidence-backed symptom routing. This skill does not define optimize workflow or own round artifacts.

★ 0
Piagari
Piagari/helix

triton-npu-optimize-knowledge-v3

Generic reference-only optimize knowledge (v3 working copy) for pattern triage and evidence-backed symptom routing. This skill does not define optimize workflow or own round artifacts; prefer this tree for ongoing knowledge updates.

★ 0
Piagari
Piagari/helix

triton-npu-optimize-knowledge

Generic reference-only optimize knowledge for pattern triage and evidence-backed symptom routing. This skill does not define optimize workflow or own round artifacts.

★ 0
Piagari
Piagari/helix

triton-npu-convert-pytorch-operator

Convert one PyTorch operator into a Triton NPU-backed PyTorch operator, preserve the trailing input-helper block, and validate the converted output through standalone or differential testing.

★ 0