news 2026/5/9 19:24:42

CANN/cannbot-skills A5设备约束指南

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
CANN/cannbot-skills A5设备约束指南

a5 Device Constraints

【免费下载链接】cannbot-skillsCANNBot 是面向 CANN 开发的用于提升开发效率的系列智能体,本仓库为其提供可复用的 Skills 模块。项目地址: https://gitcode.com/cann/cannbot-skills

Read this file when writing a kernel targeting a5 (easyasc.a5, device950) and the kernel has any vec-side stage. Do not use it as a substitute for the general kernel-authoring playbook.

Goal

Capture the stable a5 vec-side authoring surface so that:

  • a2-style direct vec-body patterns are not copied into a5 kernels
  • vec-side work starts on the supported authoring surfaces
  • easyasc.a5import breadth is not mistaken for the stable kernel-writing contract

1. Stable a5 vec-side authoring rule

For a5, vec-side work should be authored through:

  • @vf()helpers for ordinary vec preprocess / postprocess
  • microops inside@vf()when register-level control is required
  • sort-family ops such assort32,mergesort4, andmergesort_2seqwhen the kernel genuinely needs sort behavior
  • ub_to_ubfor UB-local copies or layout-preserving handoff steps

Donotwrite generic a2-style vec UB ops directly in the a5 kernel body. If the step is elementwise, row-wise, reduction, normalization, or cast-oriented on a5, move it into@vf()first and only drop tomicrowhen@vf()alone is not enough.

Important note:

  • the raweasyasc.a5export surface is wider than this stable authoring rule
  • treat the authoring rule above as the repository contract for new a5 kernels

2. Contrast with a2

  • a2 doesnotsupport@vf()
  • a2 doesnotsupportmicro
  • a2 vec work is written directly in the kernel body on UB tensors
  • do not mirror an a2 pure-vec kernel body into a5, or an a5@vf()flow into a2

3. Implications for common topologies

Stable a5 forms:

  • cube -> vec:GM -> L1 -> L0 -> L0C -> UB -> @vf() -> GM
  • vec -> cube:GM -> UB -> @vf() -> UB -> L1 -> L0 -> L0C -> GM
  • vec-only transform:GM -> UB -> @vf()orGM -> UB -> @vf() + micro -> GM
  • UB-local republish / copy:ub_to_ubmay stay in the kernel body if it is truly just the copy step

Practical rule:

  • if you are about to call ordinary vec math on an a5 UB tensor from the kernel body, stop and move that logic into@vf()

3a. Cube-side matmul dependency reuse rule

When a later cube matmul depends on the result of an earlier cube matmul, check first whether the dependency can stay on the cube-side path:

  • producer:mmad -> L0C
  • republish:l0c_to_l1
  • consumer: laterl1_to_l0 -> mmad

Prefer that directL0C -> L1route when:

  • the intermediate value is only needed by a later cube-side matmul
  • no vec-side transform is required on the intermediate value before reuse

Avoid the detour:

  • L0C -> UB -> L1

unless the UB hop is semantically required for a real vec-side stage such as:

  • cast / normalization / elementwise transform in@vf()
  • a cube -> vec handoff that genuinely changes ownership to the vec lane

Reason:

  • l0c_to_l1already gives you the FIX-side republish path for this dependency
  • the UB detour adds traffic, adds synchronization surface, and makes the kernel easier to overcomplicate without adding capability

Practical debugging hint:

  • if you find yourself moving a pure matmul dependency through UB only so a later matmul can read it back, stop and re-check whetherl0c_to_l1already expresses the intended dependence

4. When to usemicro

Usemicroon a5 when the vec stage needs register-level behavior such as:

  • explicit fp8 cast control
  • pack4()/ sparse-lane squeeze patterns
  • explicit mask or cast-config handling
  • custom register reductions or packing not expressible cleanly as plainTensor <<= Reg/RegList

Prefer plain@vf()first when it already matches the contract. For example, aReg/RegListloaded in@vf()and written back withdst[...] <<= regsis usually simpler than dropping to explicitmicro cast + pack4.

Another stable case that should stay in@vf():

  • row-recursive vec kernels where each output row depends on the previous output row
  • example shape: load one GM chunk as[chunk_size, H], then compute
    • y[0, :] = x[0, :]
    • y[i, :] = x[i, :] + y[i - 1, :]
  • on a5, keep that recurrence in@vf()withReg/RegListslices over the row width
  • donotreach forcpaddor custommicrojust because the math is cumulative;cpaddis pair-wise add, not row-prefix recurrence
  • only drop tomicroif the recurrence itself needs per-lane scan behavior inside one row rather than previous-row carry

Files to study

  • agent/example/kernels/a5/basic_cube_vec_mix.py
  • agent/example/kernels/a5/chunk_row_cumsum.py
  • agent/example/kernels/a5/matmul_half_splitn_bias10p2_vf.py
  • agent/example/kernels/a5/matmul_kmkn_blockwise_quant128.py
  • agent/example/kernels/a5/micro_cast_fp8_pack4_dual.py
  • agent/example/kernels/a5/vec_cube_abs_sqrt_matmul.py

【免费下载链接】cannbot-skillsCANNBot 是面向 CANN 开发的用于提升开发效率的系列智能体,本仓库为其提供可复用的 Skills 模块。项目地址: https://gitcode.com/cann/cannbot-skills

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/5/9 19:18:45

5分钟掌握Switch游戏文件管理:NSC_BUILDER终极指南

5分钟掌握Switch游戏文件管理&#xff1a;NSC_BUILDER终极指南 【免费下载链接】NSC_BUILDER Nintendo Switch Cleaner and Builder. A batchfile, python and html script based in hacbuild and Nuts python libraries. Designed initially to erase titlerights encryption …

作者头像 李华
网站建设 2026/5/9 19:09:34

大视觉模型在医学影像领域的部署、应用与挑战

1. 项目概述&#xff1a;当大视觉模型遇见医学影像最近几年&#xff0c;大视觉模型&#xff08;Large Vision Models, LVMs&#xff09;在通用图像理解领域掀起的浪潮&#xff0c;不可避免地拍打到了医学影像这片专业且严谨的“海岸”。作为一名在医疗AI领域摸爬滚打多年的从业…

作者头像 李华
网站建设 2026/5/9 19:08:39

CANN/pto-isa库开发者规则与限制

This file lists some rules and limitations on the implementation of this library for pto-isa developers. 【免费下载链接】pto-isa Parallel Tile Operation (PTO) is a virtual instruction set architecture designed by Ascend CANN, focusing on tile-level operati…

作者头像 李华
网站建设 2026/5/9 19:00:35

CANN/ops-nn erfinv算子API文档

aclnnErfinv&aclnnInplaceErfinv 【免费下载链接】ops-nn 本项目是CANN提供的神经网络类计算算子库&#xff0c;实现网络在NPU上加速计算。 项目地址: https://gitcode.com/cann/ops-nn &#x1f4c4; 查看源码 产品支持情况 产品是否支持Ascend 950PR/Ascend 950…

作者头像 李华
网站建设 2026/5/9 18:59:33

CANN/ATVOSS设备适配层接口

DeviceAdapter 【免费下载链接】atvoss ATVOSS&#xff08;Ascend C Templates for Vector Operator Subroutines&#xff09;是一套基于Ascend C开发的Vector算子库&#xff0c;致力于为昇腾硬件上的Vector类融合算子提供极简、高效、高性能、高拓展的编程方式。 项目地址: …

作者头像 李华