dsl-baseline-generation

Generate initial AscendDSL kernel code from functional PyTorch for NPU vector operators.

Updated Sep 15, 2026
One-click install
npx skills add https://github.com/WangWindow/CANN-BatchMatMulMaxsum --skill dsl-baseline-generation-wangwindow
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dsl-baseline-generation
Source: https://github.com/WangWindow/CANN-BatchMatMulMaxsum/tree/main/.agents/skills/dsl-baseline-generation
Command: npx skills add https://github.com/WangWindow/CANN-BatchMatMulMaxsum --skill dsl-baseline-generation-wangwindow

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires torch, and includes references (resource) components.

What problem does it solve? Writing a first working AscendDSL kernel for an NPU operator from scratch is error-prone: developers must get core partitioning, UB tiling, copyin/compute/copyout structure, and hardware constraints right before any optimization can begin. This Skill converts a functional PyTorch operator definition into a complete, verified AscendDSL baseline implementation. ## Core Features & Use Cases - Category-based example selection: Picks a proven reference implementation (element-wise, reduction, normalization, scan, matmul, gather, pooling, loss, top-k, transpose) matching the operator's compute pattern. - Hardware-aware tiling: Reads env.json for ub_size and vector_core_cnt, uses tl.num_vec_cores() with pivot distribution instead of hardcoded core counts. - Transpose/conversion guardrails: Enforces DataCopyPad 32B slot layout, blockCount ≤ 4095, correct perm/stride semantics, and contiguous-row fast paths to avoid known runtime failures. - Use Case: After a project scaffold is created for a new NPU operator like layer_norm or cumsum, invoke this Skill to produce output/{op_name}/{op_name}_dsl.py with a full, placeholder-free implementation that passes a verification checklist. ## Quick Start Generate the AscendDSL baseline for the operator defined in my functional PyTorch file and save it to the output directory.

Frequently Asked Questions about dsl-baseline-generation

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

FAQPage Schema
How do I generate an AscendDSL kernel from a PyTorch operator?

Provide the functional PyTorch file containing module_fn, a Model class, and configurations. The Skill selects a matching reference example by operator category, applies the Ascend DSL host/kernel structure, and saves the result to output/{op_name}/{op_name}_dsl.py.

What operator categories does AscendDSL baseline generation support?

It supports pure Vector operators: element-wise, reduction, normalization, scan/prefix, matmul-like (Vector path only), gather, pooling, loss, sort/top-k, and conversion operators like transpose and permute. Cube+Vector fused operators use separate -cv skills.

How does the DSL handle NPU core partitioning and tiling?

The host function queries tl.num_vec_cores() dynamically and uses pivot distribution so the first pivot cores get one extra work unit. Tiling parameters are derived from env.json fields like ub_size and vector_core_cnt rather than hardcoded constants.

Why do transpose DSL kernels fail with DataCopyPad on Ascend NPU?

Strided gathers lower to multi-block DataCopyPad where each element lands in a 32B-aligned UB slot, and blockCount is a 12-bit field capped at 4095. The Skill enforces the proven transpose template, correct perm stride tables, and chunked row copies to avoid these failures.

Can the generated DSL contain simplified or placeholder logic?

No. The Skill explicitly forbids placeholders, fixed constants, skipped loops, or approximations. Every operation from module_fn must be implemented with proper Ascend DSL APIs, all inputs must be used, and reductions must accumulate across all tiles.