triton-ascend-example-matmul-vector

Implements MatMul plus vector post-processing fusion kernels 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-matmul-vector-xchang1121
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: triton-ascend-example-matmul-vector
Source: https://github.com/xchang1121/op-autoresearch/tree/main/skills/triton-ascend/examples/triton-ascend-example-matmul-vector
Command: npx skills add https://github.com/xchang1121/op-autoresearch --skill triton-ascend-example-matmul-vector-xchang1121

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing Cube/Vector affinity kernels on Ascend A5 (Ascend950) hardware is difficult because developers must coordinate cube-core GEMM computation, fixpipe data movement to UB, and vector-core post-processing with explicit synchronization. This Skill provides complete, runnable Triton-Ascend reference implementations that show exactly how to structure these fused kernels. ## Core Features & Use Cases - MatMul + ReLU fused kernel: A single-kernel CV fusion example using UB buffers, ROW_SPLIT fixpipe mode, sub_vec_id for dual sub-vector utilization, and explicit cube/vector sync_block primitives. - Vision MLP + GELU backward mixed-form example: Demonstrates how to split 7 backward operations across one fused-cv kernel, three plain Triton matmul kernels, and two pure-vector reduce kernels, eliminating an intermediate (S, I) tensor's GM write/read round trip. - Fusion selection guidance: Explains when affinity (Cube/Vector fusion) pays off versus when native Triton GEMM is the correct choice, including host-side requirements like disable_auto_inject_block_sync=True. - Use Case: When porting a transformer MLP backward pass to Ascend A5, follow the K1/K2/K3 kernel decomposition pattern to fuse only the GEMM-plus-epilogue boundary that benefits, keeping other GEMMs as plain Triton. ## Quick Start Ask the agent to implement a MatMul with ReLU epilogue as a fused Cube/Vector Triton-Ascend kernel for Ascend A5 following this example's structure.

Frequently Asked Questions about triton-ascend-example-matmul-vector

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

FAQPage Schema
How do I fuse MatMul with a ReLU epilogue on Ascend NPU using Triton?▼

Use Cube/Vector affinity scopes: compute the GEMM in an al.scope(core_mode="cube") block, move the accumulator to UB with al.fixpipe, then apply ReLU in an al.scope(core_mode="vector") block and store to GM. Synchronize the two cores with al.sync_block_set and al.sync_block_wait.

How to write Cube Vector affinity kernels in Triton-Ascend?▼

Allocate a UB buffer with bl.alloc, split work with al.scope(core_mode="cube") and al.scope(core_mode="vector"), and hand off tiles via al.fixpipe plus sync_block_set/wait pairs on PIPE_FIX and PIPE_V. The host launch must pass disable_auto_inject_block_sync=True.

When should I use fused Cube/Vector kernels versus plain Triton GEMM on Ascend?▼

Use affinity fusion only when a GEMM is immediately followed by an elementwise epilogue, so the intermediate tile stays in UB and avoids a GM write/read round trip. GEMMs without post-processing gain nothing from fusion and should remain native Triton matmul kernels.

Does Triton-Ascend support mixing fused and plain kernels in one model?▼

Yes. The Vision MLP GELU backward example combines one fused-cv kernel, three plain Triton matmul kernels, and two pure-vector reduce kernels in a single nn.Module. Only kernels using al.scope or bl.alloc need the affinity launch flags.

Why must disable_auto_inject_block_sync be set for Ascend affinity kernels?▼

Kernels that manage cube/vector synchronization manually with sync_block_set and sync_block_wait require the host call to pass disable_auto_inject_block_sync=True, otherwise automatically injected synchronization conflicts with the explicit pipeline control.