triton-ascend-affinity-fix

Diagnose and fix Cube/Vector affinity bugs in Triton-Ascend kernels on Ascend hardware.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Triton-Ascend kernels written with Cube/Vector affinity often fail verification due to subtle bugs: a single UB buffer overwritten across loop iterations (WAW), bl.alloc shapes that are runtime tensors instead of constexpr, and pure matmul kernels wrongly written in affinity form. This Skill documents the root causes and concrete fixes for these recurring precision and compilation failures. ## Core Features & Use Cases - WAW Buffer Overwrite Fix: Explains why a single c_ub buffer reused across outer-loop iterations yields only the last written tile, and provides the paired sync_block_set/wait pattern that lets cube and vector scopes safely reuse the buffer. - Constexpr Shape Enforcement: Diagnoses the get_buffer_ty TypeError from bl.alloc and shows two fixes—annotating parameters with tl.constexpr or decoupling runtime dimensions behind a BLOCK constant with masked loops. - Affinity Misuse Correction: Identifies when a no-postprocessing GEMM should not use al.scope/fixpipe at all, and provides the native Triton tl.dot + tl.make_block_ptr rewrite. - Use Case: A kernel engineer sees err_cnt mismatches on an Atlas A5 matmul kernel using fixpipe to UB; this Skill pinpoints the WAW root cause and supplies the corrected synchronization code. ## Quick Start Ask the agent to diagnose why my Triton-Ascend affinity kernel fails verification and apply the appropriate fix from this guide.

Frequently Asked Questions about triton-ascend-affinity-fix

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

FAQPage Schema
Why does my Triton-Ascend kernel output only the last tile's values?▼

This is a WAW overwrite: a single UB buffer is written repeatedly by the cube loop, so the vector loop only reads the final write. Fix it by adding paired sync_block_set/wait calls after each fixpipe so the vector side consumes each tile before the next write.

How do I fix the bl.alloc get_buffer_ty TypeError in Triton-Ascend?▼

The error means a shape dimension is a runtime tensor instead of a compile-time constant. Either annotate the parameter with tl.constexpr, or introduce a BLOCK constant for the buffer shape and loop over the runtime dimension with masks.

When should I avoid Cube/Vector affinity in Triton-Ascend matmul kernels?▼

Avoid affinity for pure GEMMs with no postprocessing, such as grad weight or grad input computations. The cube-to-UB-to-vector-to-GM path adds extra data movement and sync events; write these kernels in native Triton with tl.dot and tl.make_block_ptr instead.

Does sync_block_set/wait fix overwritten buffer values in Ascend kernels?▼

No. Synchronization solves RAW ordering (reads after writes) but cannot recover values already physically overwritten. You must pair set/wait per iteration so the consumer reads each tile before the producer writes the next one.

What hardware and DSL does this affinity fix guidance target?▼

It targets the Ascend backend on Atlas A5 hardware using the triton_ascend DSL, covering primitives like al.scope, al.fixpipe, bl.alloc, bl.subview, and bl.to_tensor.