triton-ascend-example-attention

Implements serial Cube/Vector Flash Attention forward kernel in Triton-Ascend for Ascend A5 hardware.

6|1|Updated Apr 19, 2026
One-click install
npx skills add https://github.com/xchang1121/op-autoresearch --skill triton-ascend-example-attention-xchang1121
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: triton-ascend-example-attention
Source: https://github.com/xchang1121/op-autoresearch/tree/main/skills/triton-ascend/examples/triton-ascend-example-attention
Command: npx skills add https://github.com/xchang1121/op-autoresearch --skill triton-ascend-example-attention-xchang1121

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing Flash Attention kernels for Ascend A5 (Ascend950) hardware requires coordinating Cube and Vector cores with explicit synchronization, which is difficult to get right. This Skill provides a complete, working Triton-Ascend reference implementation showing the serial Cube/Vector cooperation pattern. ## Core Features & Use Cases - Serial Cube/Vector Cooperation: Cube cores run two matmuls (logits = Q·K^T and partial = P·V) with fixpipe, while Vector cores run online softmax and flash accumulation. - Explicit Synchronization Pattern: Demonstrates three sync_block events (ids 0/1/2) pairing PIPE_FIX/V/MTE to coordinate Cube and Vector execution. - Online Softmax with NZ Layout: Shows row-max rescaling, denominator accumulation, and writing probability tiles to L1 in NZ 16x16 fractal format. - Use Case: When generating an A5 serial attention-style operator, reference this kernel structure to implement the Cube/Vector split, event pairing, and compile options (disable_auto_inject_block_sync, vf_merge_level=1). ## Quick Start Ask the agent to generate an A5 serial Flash Attention kernel following the Cube/Vector cooperation structure in this Triton-Ascend example.

Frequently Asked Questions about triton-ascend-example-attention

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement Flash Attention on Ascend A5 with Triton-Ascend?▼

Split the kernel into Cube and Vector scopes: Cube computes logits = Q·K^T and partial = P·V via tl.dot with fixpipe, while Vector runs online softmax and accumulates output. Coordinate the two with three sync_block set/wait events per KV block.

How do Cube and Vector cores synchronize in Triton-Ascend kernels?▼

Use al.sync_block_set and al.sync_block_wait with event ids and pipe pairs. This example uses event 0 (FIX to V) for logits ready, event 1 (MTE3 to MTE1) for P written to L1, and event 2 (FIX to V) for partial output ready.

What compile options does a Triton-Ascend attention kernel need?▼

Compile with debug=True, disable_auto_inject_block_sync=True, and vf_merge_level=1. Disabling auto block sync injection is required because the kernel manages Cube/Vector synchronization manually through explicit sync_block events.

Why is the probability matrix stored in NZ format on Ascend?▼

The Cube unit consumes matmul operands in NZ 16x16 fractal layout on L1. The Vector side reshapes and permutes the softmax probabilities into (BN/16, BM/16, 16, 16) and copies them to L1 so the second matmul P·V can read them directly.

Does this Triton-Ascend attention example support other Ascend chips?▼

The example targets Atlas A5 (Ascend950) and relies on A5-specific features like fixpipe dual-destination row split and sub-vector partitioning. Porting to other Ascend generations requires adjusting buffer layouts and synchronization pipes.