CANN/cannbot-skills 先澄清工作流

张开发
2026/5/9 18:08:00 15 分钟阅读

分享文章

CANN/cannbot-skills 先澄清工作流
Clarify-First Playbook【免费下载链接】cannbot-skillsCANNBot 是面向 CANN 开发的用于提升开发效率的系列智能体本仓库为其提供可复用的 Skills 模块。项目地址: https://gitcode.com/cann/cannbot-skillsUse this file before you touch any new kernel or major kernel redesign. Its job is to settle the exact contract before any DSL code is written.When this applieswriting a new kernelreplacing a kernel body in a major wayredesigning a stage or pipeline during debuggingSkip this file only for trivial fixes that do not change the contract.Hard ruleYou must fill in the Contract Template below before writing kernel code. If any field has more than one plausible interpretation that the formula alone does not fix, STOP and ask the user. Do not substitute reasonable assumptions for fields marked ASK.If the request points to a PyTorch file, an existing kernel, or another indirect reference, read:agent/references/contract-intake.mdThat page owns the intake rules, device-default rules, and anti-patterns.Contract TemplateTarget formula: pytorch expression Input tensors: name, dtype, shape, logical layout (row/col-major, KM/MK, etc.) Output tensor: name, dtype, shape Scalar/aux tensors: name, dtype, shape (include broadcast intent when ambiguous) Reduction axes: which axes are reduced Cast boundaries: input - matmul_accum - post - output Device: a2 | a5 Topology: cube-only | cube-vec | vec-cube | cube-vec-cube | ... Tail behavior: which axes may be non-aligned, at what alignment Accumulation: replace | atomic_addPer-field rule: ASK vs MAY ASSUMEFieldDefault handlinginput tensor shape when only a dtype is givenASKbroadcast intent for any aux tensor (bias, mask, scale vector)ASKaux tensor staging (kernel-side broadcast vs caller-side pre-expand)ASKoutput dtype when different from the inputsASKinterior post-matmul cast boundary (for examplep.half()before a later cube stage)ASKtail behavior (non-aligned axes)ASKtopology for 2 matmuls, softmax, or online reductionASK unless the user already named the loop / reduction orderaccumulation semantics across repeated launchesASKdevice when a referenced kernel path already fixes it (agent/example/kernels/a2/oragent/example/kernels/a5/)MAY ASSUME that devicematmulaccumulation dtypeMAY ASSUMEfloattile family, split thresholds ( 32), andL0Crow offsetMAY ASSUME repo defaults; document the choiceStandardized question blockKeep all clarifying questions in one upfront block:Before I write the kernel, I need to confirm N things that the formula alone does not fix: 1. field: possibilities are (a)..., (b)..., (c).... Which matches your intent? 2. field: ... I will wait for your answer before starting.Why this format:one handoff is cheaper than scattered follow-up questionslisting(a) / (b) / (c)proves you enumerated the real interpretationsI will wait makes the stop explicit instead of silently defaultingWhen no user answer is availableIn automated runs where the user cannot reply in real time:still write the question blockthen pick the best-guess default for each unresolved fieldrecord each guess next to the questionecho the same assumptions in the kernel file header commentAfter clarificationsOnce every field is settled, continue with:agent/playbooks/kernel-authoring.md【免费下载链接】cannbot-skillsCANNBot 是面向 CANN 开发的用于提升开发效率的系列智能体本仓库为其提供可复用的 Skills 模块。项目地址: https://gitcode.com/cann/cannbot-skills创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

更多文章