triton-ascend-a5-attention

Guides serial Cube/Vector optimization of Flash Attention kernels on Ascend950 hardware.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing high-performance attention kernels for Ascend950 (A5) hardware requires coordinating Cube and Vector cores, managing on-chip memory buffers, and handling ND-to-NZ format conversion, which is error-prone without hardware-specific guidance. ## Core Features & Use Cases - Cube/Vector Serial Scheduling: Maps Flash Attention's four stages (QK matmul, softmax, PV matmul, flash update) onto Cube and Vector cores with explicit sync_block_set/wait event pairing. - On-Chip Data Flow Design: Covers al.fixpipe, bl.alloc, al.copy, and bl.to_tensor usage across L0C, UB, and L1 memory tiers with ROW_SPLIT sub-vector partitioning. - P Matrix ND-to-NZ Conversion: Details reshape and permute steps to convert softmax output into NZ fractal format on L1 for the PV matmul. - Use Case: When porting a Triton Flash Attention kernel to Ascend950, follow this guide to structure the kernel with correct buffer shapes, synchronization events, and the required disable_auto_inject_block_sync compile option. ## Quick Start Ask the agent to optimize a Triton attention kernel for Ascend950 using the A5 serial Cube/Vector guide, applying the fixpipe data flow and manual sync events described in this skill.

Frequently Asked Questions about triton-ascend-a5-attention

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

FAQPage Schema
How do I optimize a Flash Attention kernel for Ascend950 with Triton?▼

Map the four Flash Attention stages onto Cube cores (QK and PV matmuls) and Vector cores (softmax, flash update), then alternate them serially per N-loop iteration. Use al.fixpipe to move L0C results to UB and sync_block_set/wait events to coordinate the two core types.

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

Use al.sync_block_set and al.sync_block_wait with distinct event IDs (0-15) and explicit pipe pairs such as PIPE_FIX to PIPE_V. Each set must be strictly paired with a wait, and counts must balance to avoid deadlock.

Does this guide apply to plain matrix multiplication on Ascend950?▼

No. This guide targets Transformer-style attention operators only, covering the four-stage Flash Attention decomposition. It is not suitable for ordinary matmul or reduction kernels without attention structure.

Why must disable_auto_inject_block_sync be set for Flash Attention?▼

Flash Attention's synchronization order is manually controlled via sync_block_set/wait calls. Automatically injected block syncs would conflict with this manual schedule, causing deadlocks or data races, so the option must be set to True.

What buffer shape should UB allocations use in ROW_SPLIT mode?▼

UB buffers should use (BLOCK_M // 2, ...) because ROW_SPLIT splits rows across two sub-vector cores, so each sub-vector only processes half the rows. L1 buffers for the P matrix use NZ fractal format (BLOCK_N//16, BLOCK_M//16, 16, 16).