catlass-api-basics

Explains CATLASS five-layer API and Gemm template assembly for Ascend NPU kernel development.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing or modifying CATLASS-based matrix kernels on Ascend NPUs requires understanding a layered template architecture (Device/Kernel/Block/Tile/Basic) and the correct assembly of GemmType, GemmShape, and DispatchPolicy aliases. This Skill provides the reference knowledge needed to correctly edit type alias regions in catlass_op .asc/.h files during autoresearch kernel optimization tasks. ## Core Features & Use Cases - Five-Layer Architecture Reference: Documents the Device, Kernel, Block, Tile, and Basic layers with their typical entry points such as DeviceGemm, BasicMatmul, and BlockMmad. - Standard Gemm Assembly Pattern: Provides the canonical ordering of BlockMmad, epilogue, BlockSwizzle, Kernel, and Device type aliases, plus guidance on GemmShape tiling conventions and DispatchPolicy selection (Pingpong vs Preload). - AR Workflow Integration: Identifies exactly which files to edit (catlass_kernel.asc, catlass_kernel.h, catlass_torch.cpp) and how task.yaml editable_files, CATLASS_ROOT, and the cmake rebuild cycle work. - Use Case: When an autoresearch task targets a matmul operator on Atlas A2, use this Skill to correctly compose the BlockMmad and DeviceGemm template aliases in catlass_kernel.asc instead of guessing header includes or template parameters. ## Quick Start Ask the agent to assemble a CATLASS BasicMatmul kernel for an Atlas A2 target using the standard Gemm type alias pattern in catlass_kernel.asc.

Frequently Asked Questions about catlass-api-basics

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

FAQPage Schema
How do I assemble a CATLASS Gemm kernel for Ascend NPU?▼

Assemble the type aliases in order: BlockMmad with DispatchPolicy, L1/L0 GemmShape and GemmType parameters, then an optional epilogue, a BlockSwizzle scheduler, the Kernel (e.g. BasicMatmul), and finally DeviceGemm. Place these aliases in catlass_kernel.asc with matching declarations in catlass_kernel.h.

What is the CATLASS five-layer architecture?▼

CATLASS organizes matrix operators into Device (host entry and launch), Kernel (block partitioning and synchronization), Block (single-core K-dimension main loop like BlockMmad), Tile (L1/L0 data movement), and Basic (instruction-level wrappers such as AscendC::Mmad and DataCopy).

Which DispatchPolicy should I use for CATLASS matmul on Atlas A2?▼

MmadAtlasA2Pingpong with L1 double buffering is the general baseline, while MmadAtlasA2Preload with prefetch and shuffleK suits large shapes and bandwidth-sensitive cases. TLA-based Pingpong policies pair with TLA Block implementations.

Does CATLASS GemmShape require specific tile size alignment?▼

GemmShape M, N, and K dimensions typically must be multiples of 16. A common convention sets L0.M equal to L1.M, L0.N equal to L1.N, and L0.K to L1.K divided by 4, though this is a tuning heuristic rather than a hard rule.

Why does my CATLASS kernel show high Transdata overhead in profiling?▼

High Transdata proportion in op_statistic.csv usually means tensor preprocessing in catlass_torch.cpp needs changes, not just the .asc kernel file. The torch cpp file handles TORCH_LIBRARY registration, tensor layout preparation, and launch.

Can I rewrite CATLASS computation logic in the Python kernel.py file?▼

No. The ModelNew class in kernel.py only handles load_library and torch.ops.catlass calls. All template type and computation changes belong in the catlass_op .asc and .h files, which are rebuilt via cmake on each evaluation round.