catlass-matmul-optimization

Tune CATLASS GEMM kernels via DispatchPolicy, tile shapes, and swizzle configuration.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Optimizing CATLASS matmul kernels on Ascend NPUs requires choosing the right kernel family, DispatchPolicy, tile shapes, and swizzle parameters, and wrong choices lead to idle AIC cores, L1 overflow, or no measurable speedup. ## Core Features & Use Cases - Kernel Family Selection: Decision table mapping M/N/K shape, alignment, and epilogue needs to BasicMatmul, MatmulEpilogue, padding, Split-K, or Preload kernel families. - Tile and Load-Balance Tuning: Guidance for adjusting L1TileShape and L0TileShape so block counts match AIC core counts without exceeding L1/L0 capacity. - Swizzle and DispatchPolicy Configuration: Rules for GemmIdentityBlockSwizzle direction and offset, plus when MmadAtlasA2Preload beats Pingpong. - Use Case: When an AR task shows profile time dominated by Transdata instead of MMAD, the guide directs edits to catlass_torch.cpp to remove redundant npu_format_cast calls rather than wasting cycles on tile changes. ## Quick Start Ask the agent to tune the CATLASS matmul kernel in catlass_kernel.asc for your reference shape by adjusting DispatchPolicy, tile shapes, and swizzle, then verify compilation and profile results.

Frequently Asked Questions about catlass-matmul-optimization

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

FAQPage Schema
How do I optimize a CATLASS matmul kernel on Ascend NPU?▼

Edit the DispatchPolicy, L1TileShape, L0TileShape, and BlockScheduler swizzle in catlass_kernel.asc. Choose the kernel family based on M/N/K shape and alignment, then tune tile sizes so block counts approach a multiple of the AIC core count.

How to choose between Pingpong and Preload DispatchPolicy in CATLASS?▼

Use MmadAtlasA2Pingpong as the baseline for regular aligned GEMM. Try MmadAtlasA2Preload for large matrices to reduce data-movement bubbles, but note Preload adds pipeline overhead and can slow down small matrices, so confirm with profiling.

When should I use Split-K kernels in CATLASS?▼

Use Split-K only when K is very large, a single core cannot saturate the K dimension, and multi-stage K reduction is actually enabled. If the configuration yields a split factor of 1, Split-K is equivalent to plain GEMM and gives no benefit.

Why does tile tuning not improve my CATLASS kernel latency?▼

Latency is often measured end-to-end including dtype conversion and npu_format_cast, so if profiling shows time in Transdata rather than MMAD, tile changes have little effect. Instead edit catlass_torch.cpp to remove redundant format casts or copies.

What happens if CATLASS tile shapes exceed L1 memory?▼

Exceeding L1 capacity causes compilation failure or silently selects a wrong configuration. Always compute L1/L0 usage against hardware constraints before submitting a configuration for evaluation.