Triton ascend optimization

From wenyi-li/awesome-agent-kernel-skills · View interactive version

Triton ascend optimization is an AI agent skill from the GitHub repository wenyi-li/awesome-agent-kernel-skills. Triton Ascend 性能优化通用策略: BLOCK_SIZE 选择 (1024-2048 for elementwise, must be <65536), grid configuration (use VEC_CORE_NUM / CUBE_CORE_NUM, 2D/3D grid for matmul / conv / reduce, 1D grid + inner loop for elementwise / pointwise), 256B alignment for memory transfers, autotune block-size patterns, fp16 /

How to use this skill

Skill file

Triton Ascend 性能优化指南

优化策略 Checklist

Reduction 优化

每个核心先局部标量累加,最后一次原子写入:

core_sum = 0.0
for block_start in range(pid, total_blocks, CORE_NUM):
    data = tl.load(...)
    core_sum += tl.sum(data, axis=0)
tl.atomic_add(output_ptr, core_sum)

数值稳定性

防溢出

max_val = tl.max(scores, axis=0)
scores = scores - max_val
p = tl.math.exp2(scores)

防负值开方

精度提升

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.