Triton ascend api rules

From mindspore-ai/akg · View interactive version

Triton ascend api rules is an AI agent skill from the GitHub repository mindspore-ai/akg. Triton Ascend hard API restrictions and forbidden syntax. MUST-follow rules that apply to every kernel: forbidden control flow (return/break/continue/lambda/while), tensor slice/index restrictions, scalar conversion rules, BLOCK_SIZE upper bound. Violating any of these produces a compile or runtime

How to use this skill

Skill file

Triton Ascend API Hard Rules (MUST follow)

This file lists rules whose violation causes a compile or runtime error

on Ascend. They apply to every kernel in this DSL — no exceptions.

禁止使用的语法

While 循环替代(Ascend)

静态上限(编译时常量): 直接 for i in range(N_ITERS)

动态上限(运行时参数):

@triton.jit
def kernel(ptr, n_iters, TILE: tl.constexpr, MAX_ITERS: tl.constexpr):
    for i in range(MAX_ITERS):
        if i < n_iters:
            offset = i * TILE + tl.arange(0, TILE)
            data = tl.load(ptr + offset)
            tl.store(ptr + offset, data * 2)

切片操作

其他限制

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.