pypto-op-construct

Decomposes PyPTO kernels into semantic modules and constructs them incrementally with golden validation.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Building complex PyPTO kernels for Ascend NPU operators in one shot leads to hard-to-debug failures and precision errors. This Skill enforces a disciplined decomposition-and-construction workflow so each kernel is split into verifiable semantic modules before integration. ## Core Features & Use Cases - Decomposition Gate: Reads module_count from DESIGN.md §0.3 to choose the L0 single-module path or the L1 multi-module path, consuming architect-defined breakpoints without inventing new ones. - Module Boundary Rules (R1-R6): Enforces that every module contains at least one heavy op (matmul, cross-tile reduce, scan), merges light ops into neighboring heavy modules, and keeps pypto.view/pypto.assemble as entry/exit fixtures rather than standalone modules. - Module-at-a-time Construction: Builds staged files (_module1.py_module12.py → …) where each iteration adds at most one real module, cross-checks the golden function inventory before running, and freezes verified modules. - Use Case: When implementing a fused BatchMatmulMaxSum operator in PyPTO, use this Skill to split the matmul, max-reduce, and sum-reduce stages into contract-defined modules, validate each boundary tensor against golden output, and freeze them before integration. ## Quick Start Ask the AI to decompose the current operator into PyPTO modules according to DESIGN.md and construct them one at a time with golden boundary validation.

Frequently Asked Questions about pypto-op-construct

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

FAQPage Schema
How do I decompose a PyPTO kernel into modules?

Read module_count from DESIGN.md §0.3 first. If it equals 1, follow the L0 path and produce a single implementation file; if it is 2 or more, follow the L1 path using the pre-determined data-flow breakpoints from DESIGN.md §0.5 without inventing new boundaries.

What counts as a heavy op in PyPTO module decomposition?

Heavy ops include pypto.matmul, cross-tile reductions, scan or recurrence steps with loop-carried state, and outer products crossing tiles. Every module must contain at least one heavy op; modules with only elementwise or cast operations must be merged into a neighboring heavy module.

Can pypto.view and pypto.assemble be standalone modules?

No. They are kernel entry and exit fixtures present in every PyPTO kernel, not heavy ops. The entry view merges into the first module and the exit assemble merges into the last module; rare intermediate ones merge into adjacent heavy modules.

What should I do when a PyPTO module fails validation?

First run diagnose_error with the full error log and module source to match known error patterns, then apply the fix and re-run. If no pattern matches, inspect shapes, dtypes, and intermediate checkpoints with binary-search debugging, and never edit already frozen modules.

Can I implement two PyPTO modules in one iteration?

No. The L1 path enforces a hard rule of extending the kernel by at most one semantic module per iteration, with downstream modules stubbed or fed from golden boundary tensors. Progress follows the staged file chain module1, module12, module123, and so on.

When is it allowed to run a module's boundary test?

Only after cross-checking the golden function inventory in MEMORY.md and mapping every operation in the module's scope to a PyPTO call and line number. If any operation is marked unimplemented, running the test is forbidden until it is implemented.