| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
fix(machine): Add metadata memory usage print Co-authored-by: duanhaotian<duanhaotian@huawei.com> # message auto-generated for no-merge-commit merge: !7289 merge duanhaotian into master fix(machine): Add metadata memory usage print Created-by: duanhaotian Commit-by: duanhaotian Merged-by: cann-robot Description: 新增元数据运行时使用率打印,每一轮devicetask下发时,打印每一类元数据的当前使用量,总评估量,地址分布 See merge request: cann/pypto!7289 | 24 天前 | |
refactor(all): Remove trailing whitespace Co-authored-by: tsungl4<lidongsheng4@huawei.com> # message auto-generated for no-merge-commit merge: !2188 merge pre-commit into master refactor(all): Remove trailing whitespace Created-by: tsungl4 Commit-by: tsungl4 Merged-by: cann-robot Description: Introduce pre-commit tools, and remove trailing white space with default plugin Related Issue: #1017 See merge request: cann/pypto!2188 | 7 个月前 | |
fix(machine): fix log quality issues in machine module. Co-authored-by: chai-hw<chaizhengtong@huawei.com> # message auto-generated for no-merge-commit merge: !5679 merge pyptolog_fix into master fix(machine): fix log quality issues in machine module. Created-by: chai-hw Commit-by: chai-hw Merged-by: cann-robot Description: PyPTO machine 模块日志整改 See merge request: cann/pypto!5679 | 3 个月前 | |
style(all): Apply additional clang-format corrections across codebase Co-authored-by: junjieHuang<huangjunjie38@h-partners.com> # message auto-generated for no-merge-commit merge: !4883 merge style-cpp into master style(all): Apply additional clang-format corrections across codebase Created-by: junjieHuang Commit-by: junjieHuang Merged-by: cann-robot Description: Apply additional clang-format corrections across codebase See merge request: cann/pypto!4883 | 4 个月前 | |
style(all): Apply additional clang-format corrections across codebase Co-authored-by: junjieHuang<huangjunjie38@h-partners.com> # message auto-generated for no-merge-commit merge: !4883 merge style-cpp into master style(all): Apply additional clang-format corrections across codebase Created-by: junjieHuang Commit-by: junjieHuang Merged-by: cann-robot Description: Apply additional clang-format corrections across codebase See merge request: cann/pypto!4883 | 4 个月前 | |
perf(machine): Device CF hot path, tagSeq, and partial-stitch flags Co-authored-by: LordOfMysteries<duhongxiang@huawei.com> # message auto-generated for no-merge-commit merge: !5008 merge perf/device-cf-hotpath-bundle into master perf(machine): Device CF hot path, tagSeq, and partial-stitch flags Created-by: LordOfMysteries Commit-by: LordOfMysteries Merged-by: cann-robot Description: https://gitcode.com/cann/pypto/issues/2597 perf(machine): Device CF hot path, tagSeq, and partial-stitch flags Bundle device-side control-flow hot-path optimizations that share stitch/slot/ctrl surfaces. Commits: - perf(machine): Use cellMatchTagSeq and AICORE_TASK_INIT pool reset - perf(machine): Tighten device stitch, task build, and ctrl hot path Changes: - Monotonic cellMatchTagSeq instead of embedding taskId in tags - Word-wise AICORE_TASK_INIT pool reset / overflow clear - Device stitch / task / ctrl hot-path tightening See merge request: cann/pypto!5008 | 4 个月前 | |
perf(machine): Balance static wrap remainder against dynamic fetch Co-authored-by: LordOfMysteries<duhongxiang@huawei.com> # message auto-generated for no-merge-commit merge: !7318 merge master into master perf(machine): Balance static wrap remainder against dynamic fetch Created-by: lululu40888 Commit-by: LordOfMysteries Merged-by: cann-robot Description: PR 应该避免没有描述信息,描述信息的最重要的作用是描述修改意图,应该清晰明了。例如:标题中包含了 fix 标签,如果没有描述信息,就需要Review人员猜测PR具体修复了哪些内容,或者怀疑修改的必要性。如果PR和特定的Issue相关,可以单独包含一行 Related Issue: 放到描述信息最后。 下面是一个典型的PR描述信息: The origin issue template brings too many noise, it's not suitable for git message. eg: comments are not removed, labels are redundant as the PR tile already contains the tag. The guide gives a clear suggestion on how to write the PR body. Related Issue: #1234,#5678 更多描述信息见:[Commit Message 规范](../docs/zh/contribute/pull-request.md#commit-message) See merge request: cann/pypto!7318 | 27 天前 | |
feat(machine): Cut ctrlflow cache IO Reloc overhead via host arena Co-authored-by: LordOfMysteries<duhongxiang@huawei.com> # message auto-generated for no-merge-commit merge: !7025 merge fix-ring-event-epoch into master feat(machine): Cut ctrlflow cache IO Reloc overhead via host arena Created-by: LordOfMysteries Commit-by: LordOfMysteries Merged-by: cann-robot Description: # 需求设计:消减控制流 cache 路径上的 ctrl RelocIO 开销 > PR: https://gitcode.com/cann/pypto/pull/7025 > Commit: feat(machine): Cut ctrlflow cache IO Reloc overhead via host arena (1fd1e2ee2) ## 1. 背景与问题 控制流 cache 命中后,每次 launch 仍要把本轮 **incast/outcast 绝对地址**交给叶子任务。原先主要开销在 **AICPU ctrl 热路径**:GELaunchRunCached 对每个 cached DevTask 调用 RelocIncastOutcastTask,按 rawTensorAddrBackup 描述符解析并**写回共享内嵌 IO 表**。 问题: - RelocIO 落在 ctrl 热路径,与 stitch/restore 争用同一条 AICPU-CTRL。 - 写共享内嵌表时,若与 early-launch / 上一轮 AICore 读侧重叠,存在改表竞态风险。 - 每轮 O(全部 I/O 槽) 的解析无法被 Host 侧提前完成。 ## 2. 目标与约束 | 类型 | 内容 | |------|------| | **主目标** | cache replay 跳过 per-task RelocIncastOutcastTask;RelocIO 挪到 Host Materialize(随路 arena,与 AICore launch-args 同寿命) | | **隐含约束** | **不增加 AICore 热路径损失**:无多核 BindIo、无 /8;叶子入口解析一次表起点;GetTensorAddr 仍是 base[i] | | **正确性** | aclgraph 每次捕获各自随路表;partial-cache 后 stitch 的 func 不进 layout(kIoAddressArenaOffsetInvalid),继续内嵌表 | | **兼容** | emulation / aicore-model / dump / shmem 等仍可读内嵌表时,走原 Reloc 回退 | | **工程化** | KernelBinary 与 offline kernel-bundle 共用同一套 AICore launch/arena 帮助函数,避免双份布局逻辑漂移 | ## 3. 改造前:IO 地址刷新与使用 text 每次 Launch Host 下发 tensor / workspace │ ▼ AICPU ctrl: RelocIncastOutcastTask │ 写回共享 DynFuncData 内嵌 rawTensorAddr[] ▼ AICore Leaf GetTensorAddr └── 读 funcData->rawTensorAddr[i] (共享 CF 元数据) | 阶段 | 行为 | |------|------| | Ctrl RelocIO | 热路径写共享内嵌 rawTensorAddr[] | | Leaf | 读 funcData->rawTensorAddr[i] | ## 4. 改造后:流程与元数据路径 ### 4.1 总览 **可变绝对地址**只进本轮随路 arena;共享 CF 只留静态 ioAddressArenaOffset;ctrl 在纯 arena 场景不再 RelocIO;叶子把表起点放进 CoreFuncParam.rawTensorAddr。 text 建 Cache(一次性) AssignIoAddressArenaLayout │ ▼ 静态 ioAddressArenaOffset + ioAddressArenaBytes 每次 Launch Host 准备 AICore 7-slot args(可预留 arena 尾部容量) AICPU GELaunchRunCached └── 有 arena 且无需内嵌刷新时:仅挂 startArgs,跳过 RelocIncastOutcastTask Host MaterializeIncastOutcastAddrs ──► AICore host-args 尾部 arena(AICPU 之后) AICore launch(无 BindIo) KernelEntry: ctx.ioAddressArena = inputs Leaf 入口: param.rawTensorAddr = arena + offset(或内嵌表) GetTensorAddr → param.rawTensorAddr[i] > **时序约束**:Materialize 必须在 AICPU 之后、AICore 之前(与 DeviceLauncher::LaunchKernel / LaunchBundleKernelOnce 一致),避免把绝对 host 指针提前泄漏进仍需设备侧使用的缓冲语义;H2D CF 在 rebase 之前完成。 ### 4.2 元数据访问路径 text 共享 CF(静态) 本轮随路(可变) 叶子私有 ┌─────────────────────┐ ┌──────────────────┐ ┌─────────────────────────┐ │ ioAddressArenaOffset│──(+base)─►│ ioAddressArena[] │───────►│ CoreFuncParam.rawTensorAddr │ │ 内嵌 rawTensorAddr │ │ 绝对地址 │ └───────────┬─────────────┘ │ (stitch / fallback) │──Invalid─►│ │ │ └─────────────────────┘ └──────────────────┘ ▼ GetTensorAddr: base[i] | 阶段 | 写 / 读 | |------|---------| | Assign | 写静态 ioAddressArenaOffset(元素下标,**不是字节 /8**) | | Host Materialize | **写本轮 arena**(承接原 ctrl RelocIO) | | Ctrl replay | 条件满足时只挂 startArgs,**不 RelocIO** | | Leaf 入口 | offset != Invalid → param.rawTensorAddr = arena + offset;否则用内嵌表 | | GetTensorAddr | 读 param.rawTensorAddr[i] | ### 4.3 共享 Host 实现(本批补充) 抽出 framework/src/machine/runtime/runner/aicore_launch_args.{h,cpp},供 **在线 KernelBinary** 与 **离线 kernel_bundle_launch** 共用: | API | 作用 | |-----|------| | PrepareAicoreLaunchArgsBuffer | 按 7-slot + 可选 arena 容量扩缓冲,填 launch slots,先关掉 host-input | | EnsureHostCtrlFlowCacheRebased | 对本轮 host CF mirror 做一次 rebase,供 Materialize 解引用 | | FillAicoreIoAddressArenaBuffer | 调用 MaterializeIncastOutcastAddrs 写入 arena,再打开 RtHostInputInfo(inputs) | LaunchBundleKernelOnce 同步拆成:准备 AICPU / 准备 AICore slots → 推 AICPU → Materialize arena → 推 AICore,避免超长一次性函数、并与 DeviceLauncher 时序对齐。 **RingEvent / slot 复用**:arena 只解决「本轮 IO 绝对地址落点」;host CF cache 槽位复用与 epoch 同步仍依赖既有 RingEvent 机制,**不能**因引入 arena 而删掉。 ### 4.4 关键代码锚点 **Host 物化**(KernelBinary::MaterializeIoAddressArenaForAicore / BundleMaterializeAicoreIoArena):走共享 helper → rebase → Materialize → 挂到 AICore args 尾部。 **Ctrl 跳过条件**(GELaunchRunCached): cpp const bool arenaLive = (devProg->ctrlFlowCacheAnchor->ioAddressArenaBytes != 0); const bool needEmbeddedIo = (devProg->devArgs.hostPid != 0) || (startArgs->commGroupNum != 0); if (arenaLive && !needEmbeddedIo) { dynTask->dynFuncDataList->startArgs = startArgs; // 跳过 Reloc } else { RelocIncastOutcastTask(...); // dump/shmem/无 arena 回退 } **叶子解析**(aicore_entry.h): cpp __gm__ uint64_t* rawTensorAddr = funcData->rawTensorAddr; if (funcData->ioAddressArenaOffset != kIoAddressArenaOffsetInvalid) { rawTensorAddr = ctx->ioAddressArena + funcData->ioAddressArenaOffset; } CoreFuncParam param = { ..., rawTensorAddr }; **热路径**(aicore_runtime.h):GetTensorAddr 改为读 ctx->rawTensorAddr[i],指令形态仍是基址+下标。 ## 5. 与原 Reloc / Workspace 的关系 | 地址类型 | Arena 是否覆盖 | 说明 | |----------|----------------|------| | 用户 Input/Output 槽 | ✅ | Materialize 时按 index 取本轮绝对地址 | | Backup 中 Workspace kind 槽 | ✅ | Materialize 时 +wsShift 写成绝对地址进 arena | | DynFuncData.workspaceAddr / stack / runtime WS **基址** | ❌ | 仍走 TaskAddr*Workspace / TaskAddrRelocWorkspace | | LOCAL tensor | ❌ | AICore:workspaceAddr + offset,不经 rawTensorAddr | 原 RelocIncastOutcastTask:在 device ctrl **原地**把 backup 解到内嵌表;现与 Materialize 共用 ResolveLeafIncastOutcastAddrs,区别是目标缓冲(内嵌 vs arena)与执行位置(ctrl vs host)。 ## 6. 兼容矩阵 | 场景 | 行为 | |------|------| | Full / partial cache(已 Assign layout) | Host 物化;ctrl 可跳过 RelocIO;叶子用 arena;无 BindIo | | 同 launch 后续 device stitch | ioAddressArenaOffset = Invalid,走内嵌表 | | ioAddressArenaBytes == 0 / emulation / aicore-model | 清 arena 标记;ctrl Reloc 刷新内嵌表并置 Invalid | | dump(hostPid != 0)或通信(commGroupNum != 0) | 仍 Reloc 内嵌表(AICPU 侧仍读嵌入地址) | | aclgraph 多次捕获 | 各自随路 arena,互不影响 | ## 7. 主要改动清单 1. **Host arena**:AssignIoAddressArenaLayout / MaterializeIncastOutcastAddrs;launch 挂 AICore 随路 arena 2. **共享 helper**:新增 aicore_launch_args.{h,cpp};KernelBinary + kernel_bundle_launch 共用 Prepare / Rebase / Fill 3. **Bundle 拆分**:LaunchBundleKernelOnce 拆步骤,Materialize 固定在 AICPU 之后 4. **Ctrl**:arena 存活且无需内嵌刷新时跳过 RelocIncastOutcastTask 5. **Device AICore**:ExecuteContext.ioAddressArena;叶子解析 param.rawTensorAddr;stitch 置 kIoAddressArenaOffsetInvalid 6. **统一解析**:ResolveLeafIncastOutcastAddrs 供 Materialize 与 Reloc 共用 7. **测试**:test_aicore_launch_args.cpp(布局 / Prepare / null-safe Fill);既有 ctrlflow cache / kernel_binary UT 同步适配 ## 8. 验收要点 - [ ] cache replay 路径 ctrl 泳道上 RelocIO 段消失或显著缩短(纯计算算子) - [ ] GetTensorAddr 热路径无额外除法 / 多核写共享指针 - [ ] dump / shmem / 通信场景精度与功能不回退 - [ ] aclgraph capture/replay 与 eager 数值一致 - [ ] stitch / non-cache 仍走内嵌表且地址正确 - [ ] KernelBinary 与 bundle 路径 arena 布局一致;AicoreLaunchArgsTest.* 本地通过 See merge request: cann/pypto!7025 | 1 个月前 | |
perf(machine): Prefilter stitch slot lists and isolate device-side checks Co-authored-by: gaoxingwang<camuel.gao@huawei.com> # message auto-generated for no-merge-commit merge: !5584 merge perf/prefilter-stitch-slot-lists into master perf(machine): Prefilter stitch slot lists and isolate device-side checks Created-by: gaoxingwang Commit-by: gaoxingwang Merged-by: cann-robot Description: perf(machine): Prefilter stitch slot lists and isolate device-side checks ## 优化概述 将 stitch slot 预过滤逻辑从编译期前置到 encode 阶段,消除 device 侧热路径的冗余遍历与分支判断。 ## 优化点 ### 1. Stitch Slot 预过滤 - 新增 SlotMaskEntry + stitchUpdateSlotMaskMap,在 RunEncodeStage 中一次性计算所有 slot 的 stitch mask - device 侧 UpdateSlotsImpl / FastStitchConsumer / FastStitchProducer 直接遍历预计算列表,不再逐 slot 判断 ### 2. 统一 Update 数据结构 - DevAscendProgramPartialUpdate → DevAscendProgramUpdate + isPartial 标志 - InitPartialUpdateSlot → InitUpdateSlot,合并 partial/fullcover 遍历为单次循环 - DumpPartialUpdate → DumpUpdate,输出 isPartial + stitchCtrlBitMask ### 3. Mask 计算提取与复用 - 新增静态函数 CalculateStitchCtrlBitMaskForSlot,从 InitSinglePartialUpdateSlot 中抽离 mask 计算 - InitSingleFullCoverSlot / InitSinglePartialUpdateSlot 共用 stitchUpdateSlotMaskMap,避免重复计算 ### 4. Device 侧 Slot 预过滤列表 - 新增 4 个 DevLocalVector slot 列表(stitchIncastSlotList / updateIncastSlotList / stitchOutCastSlotList / updateOutCastSlotList) - InitStitchUpdateSlotPrefilterLists 在 encode 阶段填充,RefilterStitchUpdateSlotLists 二次过滤 ### 5. CellMatch 隔离与防护 - CellMatchHandle 中 DEV_IF_NONDEVICE 隔离 dim-zero 检查 - PrepareRuntimeDynamicPartialUpdateTable 增加 null data 守卫 Related Issues: #5382 See merge request: cann/pypto!5584 | 3 个月前 | |
fix(machine): Align outcast ioIndex with per-entry runtime address table Co-authored-by: gaoxingwang<camuel.gao@huawei.com> # message auto-generated for no-merge-commit merge: !6502 merge fix-outcast-ioindex into master fix(machine): Align outcast ioIndex with per-entry runtime address table Created-by: gaoxingwang Commit-by: gaoxingwang Merged-by: cann-robot Description: fix(machine): Align outcast ioIndex with per-entry runtime address table Since pr !6322 keeps every assemble version of one slot as an outcast, several outcast entries share one RawTensor, so outcastRawList (deduped by raw) no longer lines up with the runtime outcast address table, which holds one entry per outcast. ioIndex taken from the deduped raw list therefore resolves later outcasts onto a wrong address entry: in cell_match_dep case 50 the second output's raw resolves to the shared buf outcast buffer and the host output is never written, while all graph/pass level data stays correct (silent precision failure). Changes: - Resolve outcast ioIndex through the owning outcast entry (first occurrence of the raw in devRoot's outcast list) in InitRawTensorAndMemoryRequirement and HandleActualRaw - Use the incast entry count (devRoot->GetIncast().size()) as the outcast offsetOrIndex base so the COA location encode matches the per-entry address table layout - Fix the sym dump double indexing in DumpIncast/DumpOutcast: offsetAttrIdx is already a global sym offset, read it via GetSymoffset directly Verified: cell_match_dep case 50 restores PASS with metrics identical to the pre-!6322 baseline; 39-case sample regression 79/79 PASS. Related Issues: #3384 See merge request: cann/pypto!6502 | 2 个月前 | |
feat(machine): Support static succ node parallel resolve for large fan-out Co-authored-by: gaoxingwang<camuel.gao@huawei.com> # message auto-generated for no-merge-commit merge: !6829 merge drco-static-succ-unify into master feat(machine): Support static succ node parallel resolve for large fan-out Created-by: gaoxingwang Commit-by: gaoxingwang Merged-by: cann-robot Description: feat(machine): Support static succ node parallel resolve for large fan-out Large fan-out DRCO ops resolve every successor edge from one ordered flat table: the decrement serializes and the scatter skews across cores. This PR chunks large fan-out ops into type-homogeneous 64B static succ nodes and resolves them in parallel across core-type-balanced bands. On top of the original #6737 content it unifies ALL DRCO successors into the succNode storage (flat table removed) and shrinks the stitch matrix slot back to u32. Supersedes #6737 (contains its full changes plus the three refactor commits). Changes (from #6737): - Encode-time HUB expansion: single-pred HUB successors move one hop into the predecessor entry set (edge move, depth 1, parity marking on HUB chains); the expanded HUB keeps a no-op entry so edge conservation holds (drcoSuccCnt == staticEdges asserted at encode time) - Chunking: ops whose DRCO entry count exceeds DRCO_STATIC_SUCC_THRESHOLD (16) with a unique pred and non-HUB_MIX core type are chunked into 64B DevAscendFunctionStaticSuccNode entries (coreType-homogeneous, capacity min(DRCO_SUCC_NODE_TASK_CAP=6, N/2), at least 2 nodes) in a devprog-resident flat array - Balanced parallel scatter: typed row domains per core type (AIC/AIV bands in the shared stitch matrix), per-type push cursors seeded to the domain-next core at node pop; HUB-type nodes ordered last and resolved locally on the producer via its hubStack; typed ready-matrix cursors refreshed from the scatter cursor so producer-side pushes land after the scattered bands Refactor on top: - Unify flat succ table into drcoStaticSuccNodeList_: non-chunked ops append capacity-15 mixed nodes resolved in place by the producer core (no scatter, no cursor seeding, behavior-neutral pairing within node bounds); SuccInfo low 32 bits unify to succNodeIndex/succNodeSize and bit63 narrows to the parallel-resolve flag DRCO_SUCC_PARALLEL_BIT; ResolveHubMixTask iterates nodes per entry with identical semantics - Fold the node region offset into funcInfoAndStaticDataOffset bits 59-30, dropping the standalone staticSuccNodeListOffset field and restoring the upstream two-field DrcoRootFuncData shape - Shrink stitch matrix slots to u32: 21-bit per-func node index + 10-bit producer funcId + 1-bit static flag; consumers restore nodes via funcId -> rootFuncData -> node region base + index; the u64-only atomic primitives are removed Validation (mla_prolog_v3_l0_id0002, C310, from #6737): - capture e2e_mean 239.4 -> 202.1us vs upstream base, eager 513.5/524.3 -> 475.7/476.8us; quant variant capture -19.5% - balance verified Rope 64/64 and qb/qNope 32/32 lanes Commit list: - feat(machine): Emit both flat and static succ node encodings for drco - refactor(drco): Unify flat succ table into static succ node storage - refactor(drco): Shrink stitch matrix slot back to u32 node index - refactor(drco): Rename succ node storage and parallel mode bit Related requirement: #3486 See merge request: cann/pypto!6829 | 1 个月前 | |
fix(machine): Split runtime headers and use secure bundle functions Co-authored-by: W4termy<wangmingyang21@huawei.com> # message auto-generated for no-merge-commit merge: !6428 merge fix/master_cleancode into master fix(machine): Split runtime headers and use secure bundle functions Created-by: W4termy Commit-by: W4termy Merged-by: cann-robot Description: cleancode 超大头文件、不安全函数修改 See merge request: cann/pypto!6428 | 2 个月前 | |
perf(machine): Encode DRCO coreType into taskId and prebuild encoded succStaticList at encode time Co-authored-by: gaoxingwang<camuel.gao@huawei.com> # message auto-generated for no-merge-commit merge: !6253 merge perf-6137-v2 into master perf(machine): Encode DRCO coreType into taskId and prebuild encoded succStaticList at encode time Created-by: gaoxingwang Commit-by: gaoxingwang Merged-by: cann-robot Description: The DRCO runtime resolved each successor task's coreType by dereferencing cceBinary GM memory (cceBinaryIndexList -> cceBinary[i].coreType) on every dependency resolution, which costs extra GM loads on the hot scheduling path. This change moves coreType resolution to encode time: the CoreType enum is encoded directly into the DRCO taskId bits, and succStaticList entries are prebuilt as coreType-encoded values, so the device decodes coreType from the taskId locally without touching cceBinary GM memory. Changes: - Encode CoreType enum into DRCO taskId at encode time and decode it via DrcoTaskCoreTypeOf - Prebuild the DRCO encoded succStaticList once at encode time - Resolve succ coreType from the encoded taskId in DrcoResolveDependOnce/ResolveHubMixTask - Assert DRCO-inconsumable succ coreType at encode time Related Issues: #3312 See merge request: cann/pypto!6253 | 2 个月前 | |
feat(Machine): Pointer Quant optimization Co-authored-by: Jie Yin<yinjie27@huawei.com> # message auto-generated for no-merge-commit merge: !6689 merge aicore-quant-pointer into master feat(Machine): Pointer Quant optimization Created-by: yinjie27_ Commit-by: Jie Yin Merged-by: cann-robot Description: feat(Machine): Pointer Quant optimization See merge request: cann/pypto!6689 | 2 个月前 | |
perf(machine): Prefilter stitch slot lists and isolate device-side checks Co-authored-by: gaoxingwang<camuel.gao@huawei.com> # message auto-generated for no-merge-commit merge: !5584 merge perf/prefilter-stitch-slot-lists into master perf(machine): Prefilter stitch slot lists and isolate device-side checks Created-by: gaoxingwang Commit-by: gaoxingwang Merged-by: cann-robot Description: perf(machine): Prefilter stitch slot lists and isolate device-side checks ## 优化概述 将 stitch slot 预过滤逻辑从编译期前置到 encode 阶段,消除 device 侧热路径的冗余遍历与分支判断。 ## 优化点 ### 1. Stitch Slot 预过滤 - 新增 SlotMaskEntry + stitchUpdateSlotMaskMap,在 RunEncodeStage 中一次性计算所有 slot 的 stitch mask - device 侧 UpdateSlotsImpl / FastStitchConsumer / FastStitchProducer 直接遍历预计算列表,不再逐 slot 判断 ### 2. 统一 Update 数据结构 - DevAscendProgramPartialUpdate → DevAscendProgramUpdate + isPartial 标志 - InitPartialUpdateSlot → InitUpdateSlot,合并 partial/fullcover 遍历为单次循环 - DumpPartialUpdate → DumpUpdate,输出 isPartial + stitchCtrlBitMask ### 3. Mask 计算提取与复用 - 新增静态函数 CalculateStitchCtrlBitMaskForSlot,从 InitSinglePartialUpdateSlot 中抽离 mask 计算 - InitSingleFullCoverSlot / InitSinglePartialUpdateSlot 共用 stitchUpdateSlotMaskMap,避免重复计算 ### 4. Device 侧 Slot 预过滤列表 - 新增 4 个 DevLocalVector slot 列表(stitchIncastSlotList / updateIncastSlotList / stitchOutCastSlotList / updateOutCastSlotList) - InitStitchUpdateSlotPrefilterLists 在 encode 阶段填充,RefilterStitchUpdateSlotLists 二次过滤 ### 5. CellMatch 隔离与防护 - CellMatchHandle 中 DEV_IF_NONDEVICE 隔离 dim-zero 检查 - PrepareRuntimeDynamicPartialUpdateTable 增加 null data 守卫 Related Issues: #5382 See merge request: cann/pypto!5584 | 3 个月前 | |
fix(machine): Fix the tool for memory overlap check Co-authored-by: duanhaotian<duanhaotian@huawei.com> # message auto-generated for no-merge-commit merge: !7049 merge duanhaotian6 into master fix(machine): Fix the tool for memory overlap check Created-by: duanhaotian Commit-by: duanhaotian Merged-by: cann-robot Description: PR 应该避免没有描述信息,描述信息的最重要的作用是描述修改意图,应该清晰明了。例如:标题中包含了 fix 标签,如果没有描述信息,就需要Review人员猜测PR具体修复了哪些内容,或者怀疑修改的必要性。如果PR和特定的Issue相关,可以单独包含一行 Related Issue: 放到描述信息最后。 下面是一个典型的PR描述信息: The origin issue template brings too many noise, it's not suitable for git message. eg: comments are not removed, labels are redundant as the PR tile already contains the tag. The guide gives a clear suggestion on how to write the PR body. Related Issue: #1234,#5678 更多描述信息见:[Commit Message 规范](../docs/zh/contribute/pull-request.md#commit-message) See merge request: cann/pypto!7049 | 1 个月前 | |
feat(Machine): Local Matrix for scheduling Co-authored-by: Jie Yin<yinjie27@huawei.com> # message auto-generated for no-merge-commit merge: !6222 merge aicore-resolve-in-one into master feat(Machine): Local Matrix for scheduling Created-by: yinjie27_ Commit-by: Jie Yin Merged-by: cann-robot Description: feat(Machine): Local Matrix for scheduling See merge request: cann/pypto!6222 | 2 个月前 | |
feat(docs): Add describe of stitch function num per pool Co-authored-by: duanhaotian<duanhaotian@huawei.com> # message auto-generated for no-merge-commit merge: !5830 merge duanhaotian_doc into master feat(docs): Add describe of stitch function num per pool Created-by: duanhaotian Commit-by: duanhaotian Merged-by: cann-robot Description: 内存精细化控制配置项文档介绍 See merge request: cann/pypto!5830 | 2 个月前 | |
fix(machine): Add metadata memory usage print Co-authored-by: duanhaotian<duanhaotian@huawei.com> # message auto-generated for no-merge-commit merge: !7289 merge duanhaotian into master fix(machine): Add metadata memory usage print Created-by: duanhaotian Commit-by: duanhaotian Merged-by: cann-robot Description: 新增元数据运行时使用率打印,每一轮devicetask下发时,打印每一类元数据的当前使用量,总评估量,地址分布 See merge request: cann/pypto!7289 | 24 天前 | |
feat(machine): Cut ctrlflow cache IO Reloc overhead via host arena Co-authored-by: LordOfMysteries<duhongxiang@huawei.com> # message auto-generated for no-merge-commit merge: !7025 merge fix-ring-event-epoch into master feat(machine): Cut ctrlflow cache IO Reloc overhead via host arena Created-by: LordOfMysteries Commit-by: LordOfMysteries Merged-by: cann-robot Description: # 需求设计:消减控制流 cache 路径上的 ctrl RelocIO 开销 > PR: https://gitcode.com/cann/pypto/pull/7025 > Commit: feat(machine): Cut ctrlflow cache IO Reloc overhead via host arena (1fd1e2ee2) ## 1. 背景与问题 控制流 cache 命中后,每次 launch 仍要把本轮 **incast/outcast 绝对地址**交给叶子任务。原先主要开销在 **AICPU ctrl 热路径**:GELaunchRunCached 对每个 cached DevTask 调用 RelocIncastOutcastTask,按 rawTensorAddrBackup 描述符解析并**写回共享内嵌 IO 表**。 问题: - RelocIO 落在 ctrl 热路径,与 stitch/restore 争用同一条 AICPU-CTRL。 - 写共享内嵌表时,若与 early-launch / 上一轮 AICore 读侧重叠,存在改表竞态风险。 - 每轮 O(全部 I/O 槽) 的解析无法被 Host 侧提前完成。 ## 2. 目标与约束 | 类型 | 内容 | |------|------| | **主目标** | cache replay 跳过 per-task RelocIncastOutcastTask;RelocIO 挪到 Host Materialize(随路 arena,与 AICore launch-args 同寿命) | | **隐含约束** | **不增加 AICore 热路径损失**:无多核 BindIo、无 /8;叶子入口解析一次表起点;GetTensorAddr 仍是 base[i] | | **正确性** | aclgraph 每次捕获各自随路表;partial-cache 后 stitch 的 func 不进 layout(kIoAddressArenaOffsetInvalid),继续内嵌表 | | **兼容** | emulation / aicore-model / dump / shmem 等仍可读内嵌表时,走原 Reloc 回退 | | **工程化** | KernelBinary 与 offline kernel-bundle 共用同一套 AICore launch/arena 帮助函数,避免双份布局逻辑漂移 | ## 3. 改造前:IO 地址刷新与使用 text 每次 Launch Host 下发 tensor / workspace │ ▼ AICPU ctrl: RelocIncastOutcastTask │ 写回共享 DynFuncData 内嵌 rawTensorAddr[] ▼ AICore Leaf GetTensorAddr └── 读 funcData->rawTensorAddr[i] (共享 CF 元数据) | 阶段 | 行为 | |------|------| | Ctrl RelocIO | 热路径写共享内嵌 rawTensorAddr[] | | Leaf | 读 funcData->rawTensorAddr[i] | ## 4. 改造后:流程与元数据路径 ### 4.1 总览 **可变绝对地址**只进本轮随路 arena;共享 CF 只留静态 ioAddressArenaOffset;ctrl 在纯 arena 场景不再 RelocIO;叶子把表起点放进 CoreFuncParam.rawTensorAddr。 text 建 Cache(一次性) AssignIoAddressArenaLayout │ ▼ 静态 ioAddressArenaOffset + ioAddressArenaBytes 每次 Launch Host 准备 AICore 7-slot args(可预留 arena 尾部容量) AICPU GELaunchRunCached └── 有 arena 且无需内嵌刷新时:仅挂 startArgs,跳过 RelocIncastOutcastTask Host MaterializeIncastOutcastAddrs ──► AICore host-args 尾部 arena(AICPU 之后) AICore launch(无 BindIo) KernelEntry: ctx.ioAddressArena = inputs Leaf 入口: param.rawTensorAddr = arena + offset(或内嵌表) GetTensorAddr → param.rawTensorAddr[i] > **时序约束**:Materialize 必须在 AICPU 之后、AICore 之前(与 DeviceLauncher::LaunchKernel / LaunchBundleKernelOnce 一致),避免把绝对 host 指针提前泄漏进仍需设备侧使用的缓冲语义;H2D CF 在 rebase 之前完成。 ### 4.2 元数据访问路径 text 共享 CF(静态) 本轮随路(可变) 叶子私有 ┌─────────────────────┐ ┌──────────────────┐ ┌─────────────────────────┐ │ ioAddressArenaOffset│──(+base)─►│ ioAddressArena[] │───────►│ CoreFuncParam.rawTensorAddr │ │ 内嵌 rawTensorAddr │ │ 绝对地址 │ └───────────┬─────────────┘ │ (stitch / fallback) │──Invalid─►│ │ │ └─────────────────────┘ └──────────────────┘ ▼ GetTensorAddr: base[i] | 阶段 | 写 / 读 | |------|---------| | Assign | 写静态 ioAddressArenaOffset(元素下标,**不是字节 /8**) | | Host Materialize | **写本轮 arena**(承接原 ctrl RelocIO) | | Ctrl replay | 条件满足时只挂 startArgs,**不 RelocIO** | | Leaf 入口 | offset != Invalid → param.rawTensorAddr = arena + offset;否则用内嵌表 | | GetTensorAddr | 读 param.rawTensorAddr[i] | ### 4.3 共享 Host 实现(本批补充) 抽出 framework/src/machine/runtime/runner/aicore_launch_args.{h,cpp},供 **在线 KernelBinary** 与 **离线 kernel_bundle_launch** 共用: | API | 作用 | |-----|------| | PrepareAicoreLaunchArgsBuffer | 按 7-slot + 可选 arena 容量扩缓冲,填 launch slots,先关掉 host-input | | EnsureHostCtrlFlowCacheRebased | 对本轮 host CF mirror 做一次 rebase,供 Materialize 解引用 | | FillAicoreIoAddressArenaBuffer | 调用 MaterializeIncastOutcastAddrs 写入 arena,再打开 RtHostInputInfo(inputs) | LaunchBundleKernelOnce 同步拆成:准备 AICPU / 准备 AICore slots → 推 AICPU → Materialize arena → 推 AICore,避免超长一次性函数、并与 DeviceLauncher 时序对齐。 **RingEvent / slot 复用**:arena 只解决「本轮 IO 绝对地址落点」;host CF cache 槽位复用与 epoch 同步仍依赖既有 RingEvent 机制,**不能**因引入 arena 而删掉。 ### 4.4 关键代码锚点 **Host 物化**(KernelBinary::MaterializeIoAddressArenaForAicore / BundleMaterializeAicoreIoArena):走共享 helper → rebase → Materialize → 挂到 AICore args 尾部。 **Ctrl 跳过条件**(GELaunchRunCached): cpp const bool arenaLive = (devProg->ctrlFlowCacheAnchor->ioAddressArenaBytes != 0); const bool needEmbeddedIo = (devProg->devArgs.hostPid != 0) || (startArgs->commGroupNum != 0); if (arenaLive && !needEmbeddedIo) { dynTask->dynFuncDataList->startArgs = startArgs; // 跳过 Reloc } else { RelocIncastOutcastTask(...); // dump/shmem/无 arena 回退 } **叶子解析**(aicore_entry.h): cpp __gm__ uint64_t* rawTensorAddr = funcData->rawTensorAddr; if (funcData->ioAddressArenaOffset != kIoAddressArenaOffsetInvalid) { rawTensorAddr = ctx->ioAddressArena + funcData->ioAddressArenaOffset; } CoreFuncParam param = { ..., rawTensorAddr }; **热路径**(aicore_runtime.h):GetTensorAddr 改为读 ctx->rawTensorAddr[i],指令形态仍是基址+下标。 ## 5. 与原 Reloc / Workspace 的关系 | 地址类型 | Arena 是否覆盖 | 说明 | |----------|----------------|------| | 用户 Input/Output 槽 | ✅ | Materialize 时按 index 取本轮绝对地址 | | Backup 中 Workspace kind 槽 | ✅ | Materialize 时 +wsShift 写成绝对地址进 arena | | DynFuncData.workspaceAddr / stack / runtime WS **基址** | ❌ | 仍走 TaskAddr*Workspace / TaskAddrRelocWorkspace | | LOCAL tensor | ❌ | AICore:workspaceAddr + offset,不经 rawTensorAddr | 原 RelocIncastOutcastTask:在 device ctrl **原地**把 backup 解到内嵌表;现与 Materialize 共用 ResolveLeafIncastOutcastAddrs,区别是目标缓冲(内嵌 vs arena)与执行位置(ctrl vs host)。 ## 6. 兼容矩阵 | 场景 | 行为 | |------|------| | Full / partial cache(已 Assign layout) | Host 物化;ctrl 可跳过 RelocIO;叶子用 arena;无 BindIo | | 同 launch 后续 device stitch | ioAddressArenaOffset = Invalid,走内嵌表 | | ioAddressArenaBytes == 0 / emulation / aicore-model | 清 arena 标记;ctrl Reloc 刷新内嵌表并置 Invalid | | dump(hostPid != 0)或通信(commGroupNum != 0) | 仍 Reloc 内嵌表(AICPU 侧仍读嵌入地址) | | aclgraph 多次捕获 | 各自随路 arena,互不影响 | ## 7. 主要改动清单 1. **Host arena**:AssignIoAddressArenaLayout / MaterializeIncastOutcastAddrs;launch 挂 AICore 随路 arena 2. **共享 helper**:新增 aicore_launch_args.{h,cpp};KernelBinary + kernel_bundle_launch 共用 Prepare / Rebase / Fill 3. **Bundle 拆分**:LaunchBundleKernelOnce 拆步骤,Materialize 固定在 AICPU 之后 4. **Ctrl**:arena 存活且无需内嵌刷新时跳过 RelocIncastOutcastTask 5. **Device AICore**:ExecuteContext.ioAddressArena;叶子解析 param.rawTensorAddr;stitch 置 kIoAddressArenaOffsetInvalid 6. **统一解析**:ResolveLeafIncastOutcastAddrs 供 Materialize 与 Reloc 共用 7. **测试**:test_aicore_launch_args.cpp(布局 / Prepare / null-safe Fill);既有 ctrlflow cache / kernel_binary UT 同步适配 ## 8. 验收要点 - [ ] cache replay 路径 ctrl 泳道上 RelocIO 段消失或显著缩短(纯计算算子) - [ ] GetTensorAddr 热路径无额外除法 / 多核写共享指针 - [ ] dump / shmem / 通信场景精度与功能不回退 - [ ] aclgraph capture/replay 与 eager 数值一致 - [ ] stitch / non-cache 仍走内嵌表且地址正确 - [ ] KernelBinary 与 bundle 路径 arena 布局一致;AicoreLaunchArgsTest.* 本地通过 See merge request: cann/pypto!7025 | 1 个月前 | |
perf(machine): Speed up host ctrl-flow cache build Co-authored-by: LordOfMysteries<duhongxiang@huawei.com> # message auto-generated for no-merge-commit merge: !7190 merge optimize/ctrlflow-cache-skip-unused-memset into master perf(machine): Speed up host ctrl-flow cache build Created-by: LordOfMysteries Commit-by: LordOfMysteries Merged-by: cann-robot Description: https://gitcode.com/cann/pypto/issues/3681 ## Summary Host 侧构建 ctrl-flow cache 时,去掉默认路径上不必要的开销: 1. **跳过未使用 payload 的整块 memset** - CreateHostCtrlFlowCache 原先对约 100MB 容量上限做 AllocZero;录制实际只用约 1MB,usedCacheSize 拷 device 也不带走未用尾部。 - 改为只清 cacheData 之前的元数据前缀;payload 在 AllocateCache 按块(含 64B 对齐 padding)清零,保留 ready-queue / mix-task「洞必须为 null」语义。 - Engram ST 上 create_cache 约 5.7ms → 约 64µs。 2. **默认跳过 host stitch 校验 / topo dump** - 新增 HostTopoVerifyEnabled(),与 runtime_debug_mode == VERIFY 对齐。 - 默认关闭 CheckStitch、边校验以及 consumer/producer cell-access dump;VERIFY 时再开启。 - 不改 ENABLE_COMPILE_VERBOSE_LOG;无需为性能重编 verbose 开关。 ## UT - AllocateCache_ZerosPoisonedSlabAndPadding:poison 后分配,校验 slab + 64B padding 清零 - CreateHostCtrlFlowCache_AllocateCacheZerosPoisonedPayload:只清 header 后 poison payload,再经 AllocateCache 清零 - HostTopoVerifyEnabled_TrueWhenRuntimeDebugVerify:VERIFY 模式下门闩为 true - 原有 CreateHostCtrlFlowCache / BuildControlFlowCache 路径无需改断言 See merge request: cann/pypto!7190 | 28 天前 | |
feat(machine): Add basic data structure header for cord. Co-authored-by: Jie Yin<yinjie27@huawei.com> # message auto-generated for no-merge-commit merge: !5349 merge cord-data into master feat(machine): Add basic data structure header for cord. Created-by: yinjie27_ Commit-by: Jie Yin Merged-by: cann-robot Description: feat(machine): Add basic data structure header for cord. See merge request: cann/pypto!5349 | 3 个月前 | |
fix(machine): Improve ctrl cache replay performance Co-authored-by: qq_52905393<liuzhen180@huawei.com> # message auto-generated for no-merge-commit merge: !6316 merge dev-inoutreloc-performance into master fix(machine): Improve ctrl cache replay performance Created-by: qq_52905393 Commit-by: qq_52905393 Merged-by: cann-robot Description: 1、删除 funcdata backup 拷贝到 funcdata 的 memcpys,RelocIncastOutCast 流程中直接从 backup 读取信息 2、原 RelocIncastOutCast 流程为遍历所有 device task 和 dupFuncData,逐 input outpu 还原。新流程将 RelocIncastOutCast 放入 push task 之前,per-task reloc 并 push;并将在 host cache 之后记录并构建需要 Reloc 的信息,每个 Kind 记录下有哪些 input oout,在 reloc 时,不遍历所有 input out,而是按照 kind 类别做 reloc; See merge request: cann/pypto!6316 | 2 个月前 | |
fix(machine): Add metadata memory usage print Co-authored-by: duanhaotian<duanhaotian@huawei.com> # message auto-generated for no-merge-commit merge: !7289 merge duanhaotian into master fix(machine): Add metadata memory usage print Created-by: duanhaotian Commit-by: duanhaotian Merged-by: cann-robot Description: 新增元数据运行时使用率打印,每一轮devicetask下发时,打印每一类元数据的当前使用量,总评估量,地址分布 See merge request: cann/pypto!7289 | 24 天前 | |
feat(machine): Add new memory pool for dupped_stitch Co-authored-by: duanhaotian<duanhaotian@huawei.com> # message auto-generated for no-merge-commit merge: !6534 merge duanhaotian18 into master feat(machine): Add new memory pool for dupped_stitch Created-by: duanhaotian Commit-by: duanhaotian Merged-by: cann-robot Description: text Host 编码 CalcStitchWorkspace 共享 stitch 池,不再含 << 4 CalcDuppedStitchWorkspace 独立池 = 页大小 << 2 memBudget.metadata.duppedStitchPool / duppedStitchSlabSize | Launch FillDeviceRuntimeOffset 在 stitch 池之后铺 duppedStitchPoolOffset DevStartArgs 填 duppedStitchPoolAddr = runtime 基址 + offset | Device 初始化 InitMetadataAllocators InitAicpuDuppedStitchSlabAllocator 只注册 WsAicpuSlabMemType::DUPPED_STITCH | 运行中 AllocateStitch -> SlabAlloc(DUPPED_STITCH) -> duppedStitchSlab.Alloc Alloc 成功:allocatedObjCount++,unPopAllocatedObjCount++,挂上 stage 链表 | 切窗 活节点达到 80% SubmitToAicoreAndRecycleMemory SlabGetStageAllocMem -> PopStageAllocMem objCnt = 本窗 unPopAllocatedObjCount 记入 DynDeviceTask.taskStageAllocMem.duppedStitchStageMem | 回收 DeviceTaskMemTryRecycle FreeStageAllocMem:allocatedObjCount -= objCnt,节点回到 freeList 针对 slab metadata 共享内存池中的 type 间资源侵占问题,当前已有的问题中主要导致侵占的元数据是不可评估的DUPPED_STITCH,另外,当前因为DUPPED_STITCH不易评估因此预留了较大的内存池,针对这类不可评估的元数据问题考虑的方案是独立内存池并在即将使用完时直接submit | 算子 |pre ringbuffer | after ring buffer| 减少 | 降幅 | pre metadatasize | after metadatasize | metadata减少 | |---|---:|---:|---:|---:|---:|---:|---:| | glm_attention low_latency | 126,395,688 (120.54 MiB) | 76,168,744 (72.64 MiB) | 50,226,944 (47.90 MiB) | 39.7% | 31,598,904 | 19,042,168 | 12,556,736 | | glm_attention high_throughput | 138,460,904 (132.04 MiB) | 88,270,824 (84.18 MiB) | 50,190,080 (47.87 MiB) | 36.2% | 34,615,216 | 22,067,696 | 12,547,520 | | flash_attention_mha pre_training | 123,784,616 (118.05 MiB) | 73,551,528 (70.14 MiB) | 50,233,088 (47.91 MiB) | 40.6% | 30,946,136 | 18,387,864 | 12,558,272 | | interleave_rope low_latency | 103,559,208 (98.76 MiB) | 53,270,824 (50.80 MiB) | 50,288,384 (47.96 MiB) | 48.6% | 25,889,784 | 13,317,688 | 12,572,096 | See merge request: cann/pypto!6534 | 1 个月前 | |
feat(machine): Add new memory pool for dupped_stitch Co-authored-by: duanhaotian<duanhaotian@huawei.com> # message auto-generated for no-merge-commit merge: !6534 merge duanhaotian18 into master feat(machine): Add new memory pool for dupped_stitch Created-by: duanhaotian Commit-by: duanhaotian Merged-by: cann-robot Description: text Host 编码 CalcStitchWorkspace 共享 stitch 池,不再含 << 4 CalcDuppedStitchWorkspace 独立池 = 页大小 << 2 memBudget.metadata.duppedStitchPool / duppedStitchSlabSize | Launch FillDeviceRuntimeOffset 在 stitch 池之后铺 duppedStitchPoolOffset DevStartArgs 填 duppedStitchPoolAddr = runtime 基址 + offset | Device 初始化 InitMetadataAllocators InitAicpuDuppedStitchSlabAllocator 只注册 WsAicpuSlabMemType::DUPPED_STITCH | 运行中 AllocateStitch -> SlabAlloc(DUPPED_STITCH) -> duppedStitchSlab.Alloc Alloc 成功:allocatedObjCount++,unPopAllocatedObjCount++,挂上 stage 链表 | 切窗 活节点达到 80% SubmitToAicoreAndRecycleMemory SlabGetStageAllocMem -> PopStageAllocMem objCnt = 本窗 unPopAllocatedObjCount 记入 DynDeviceTask.taskStageAllocMem.duppedStitchStageMem | 回收 DeviceTaskMemTryRecycle FreeStageAllocMem:allocatedObjCount -= objCnt,节点回到 freeList 针对 slab metadata 共享内存池中的 type 间资源侵占问题,当前已有的问题中主要导致侵占的元数据是不可评估的DUPPED_STITCH,另外,当前因为DUPPED_STITCH不易评估因此预留了较大的内存池,针对这类不可评估的元数据问题考虑的方案是独立内存池并在即将使用完时直接submit | 算子 |pre ringbuffer | after ring buffer| 减少 | 降幅 | pre metadatasize | after metadatasize | metadata减少 | |---|---:|---:|---:|---:|---:|---:|---:| | glm_attention low_latency | 126,395,688 (120.54 MiB) | 76,168,744 (72.64 MiB) | 50,226,944 (47.90 MiB) | 39.7% | 31,598,904 | 19,042,168 | 12,556,736 | | glm_attention high_throughput | 138,460,904 (132.04 MiB) | 88,270,824 (84.18 MiB) | 50,190,080 (47.87 MiB) | 36.2% | 34,615,216 | 22,067,696 | 12,547,520 | | flash_attention_mha pre_training | 123,784,616 (118.05 MiB) | 73,551,528 (70.14 MiB) | 50,233,088 (47.91 MiB) | 40.6% | 30,946,136 | 18,387,864 | 12,558,272 | | interleave_rope low_latency | 103,559,208 (98.76 MiB) | 53,270,824 (50.80 MiB) | 50,288,384 (47.96 MiB) | 48.6% | 25,889,784 | 13,317,688 | 12,572,096 | See merge request: cann/pypto!6534 | 1 个月前 | |
fix(machine): Fix predcount offset over 2G Co-authored-by: qq_52905393<liuzhen180@huawei.com> # message auto-generated for no-merge-commit merge: !7218 merge dev-fix-offset into master fix(machine): Fix predcount offset over 2G Created-by: qq_52905393 Commit-by: qq_52905393 Merged-by: cann-robot Description: 限制 stitchCache 检测的最大 OpSize 为 3000,对应的 stitchCache 约为 70MB See merge request: cann/pypto!7218 | 30 天前 | |
style(all): Apply additional clang-format corrections across codebase Co-authored-by: junjieHuang<huangjunjie38@h-partners.com> # message auto-generated for no-merge-commit merge: !4883 merge style-cpp into master style(all): Apply additional clang-format corrections across codebase Created-by: junjieHuang Commit-by: junjieHuang Merged-by: cann-robot Description: Apply additional clang-format corrections across codebase See merge request: cann/pypto!4883 | 4 个月前 | |
fix(machine): Add metadata memory usage print Co-authored-by: duanhaotian<duanhaotian@huawei.com> # message auto-generated for no-merge-commit merge: !7289 merge duanhaotian into master fix(machine): Add metadata memory usage print Created-by: duanhaotian Commit-by: duanhaotian Merged-by: cann-robot Description: 新增元数据运行时使用率打印,每一轮devicetask下发时,打印每一类元数据的当前使用量,总评估量,地址分布 See merge request: cann/pypto!7289 | 24 天前 | |
fix(machine): Add metadata memory usage print Co-authored-by: duanhaotian<duanhaotian@huawei.com> # message auto-generated for no-merge-commit merge: !7289 merge duanhaotian into master fix(machine): Add metadata memory usage print Created-by: duanhaotian Commit-by: duanhaotian Merged-by: cann-robot Description: 新增元数据运行时使用率打印,每一轮devicetask下发时,打印每一类元数据的当前使用量,总评估量,地址分布 See merge request: cann/pypto!7289 | 24 天前 | |
feat(machine): Add new memory pool for dupped_stitch Co-authored-by: duanhaotian<duanhaotian@huawei.com> # message auto-generated for no-merge-commit merge: !6534 merge duanhaotian18 into master feat(machine): Add new memory pool for dupped_stitch Created-by: duanhaotian Commit-by: duanhaotian Merged-by: cann-robot Description: text Host 编码 CalcStitchWorkspace 共享 stitch 池,不再含 << 4 CalcDuppedStitchWorkspace 独立池 = 页大小 << 2 memBudget.metadata.duppedStitchPool / duppedStitchSlabSize | Launch FillDeviceRuntimeOffset 在 stitch 池之后铺 duppedStitchPoolOffset DevStartArgs 填 duppedStitchPoolAddr = runtime 基址 + offset | Device 初始化 InitMetadataAllocators InitAicpuDuppedStitchSlabAllocator 只注册 WsAicpuSlabMemType::DUPPED_STITCH | 运行中 AllocateStitch -> SlabAlloc(DUPPED_STITCH) -> duppedStitchSlab.Alloc Alloc 成功:allocatedObjCount++,unPopAllocatedObjCount++,挂上 stage 链表 | 切窗 活节点达到 80% SubmitToAicoreAndRecycleMemory SlabGetStageAllocMem -> PopStageAllocMem objCnt = 本窗 unPopAllocatedObjCount 记入 DynDeviceTask.taskStageAllocMem.duppedStitchStageMem | 回收 DeviceTaskMemTryRecycle FreeStageAllocMem:allocatedObjCount -= objCnt,节点回到 freeList 针对 slab metadata 共享内存池中的 type 间资源侵占问题,当前已有的问题中主要导致侵占的元数据是不可评估的DUPPED_STITCH,另外,当前因为DUPPED_STITCH不易评估因此预留了较大的内存池,针对这类不可评估的元数据问题考虑的方案是独立内存池并在即将使用完时直接submit | 算子 |pre ringbuffer | after ring buffer| 减少 | 降幅 | pre metadatasize | after metadatasize | metadata减少 | |---|---:|---:|---:|---:|---:|---:|---:| | glm_attention low_latency | 126,395,688 (120.54 MiB) | 76,168,744 (72.64 MiB) | 50,226,944 (47.90 MiB) | 39.7% | 31,598,904 | 19,042,168 | 12,556,736 | | glm_attention high_throughput | 138,460,904 (132.04 MiB) | 88,270,824 (84.18 MiB) | 50,190,080 (47.87 MiB) | 36.2% | 34,615,216 | 22,067,696 | 12,547,520 | | flash_attention_mha pre_training | 123,784,616 (118.05 MiB) | 73,551,528 (70.14 MiB) | 50,233,088 (47.91 MiB) | 40.6% | 30,946,136 | 18,387,864 | 12,558,272 | | interleave_rope low_latency | 103,559,208 (98.76 MiB) | 53,270,824 (50.80 MiB) | 50,288,384 (47.96 MiB) | 48.6% | 25,889,784 | 13,317,688 | 12,572,096 | See merge request: cann/pypto!6534 | 1 个月前 | |
feat(machine): Optimize perf Co-authored-by: dty_30041779<daitianyi1@h-partners.com> # message auto-generated for no-merge-commit merge: !5431 merge oom into master feat(machine): Optimize perf Created-by: LordOfMysteries Commit-by: dty_30041779 Merged-by: cann-robot Description: https://gitcode.com/cann/pypto/issues/2597 # AICPU Ctrl / Sche 代码优化摘要 面向动态图 EXEC_DYN 热路径的微优化(不改变语义;DEV_INFO 日志级别保持原样)。 ## 主要改动 1. **Fill I/O / ItemPool** - 新增 ItemPool::AllocateBump / MakeRuntimeOutcastTensorBump:在 RunInit 后首次填充 root I/O 时跳过 freelist 分支与逐元素 ItemAt 检查。 2. **Stitch 挂边** - DevAscendFunctionDuppedStitchList::PushBack 由 std::function 改为模板 AllocFn,避免类型擦除与间接调用。 - Partial-update 表基址由 &table[0] 改为 Data(),空表安全且去掉无意义的下标检查。 3. **Workspace / Dupped 尺寸** - DevFunctionDuppedSlabMemObjSize 对同一 DevAscendProgram 缓存最大 Dupped 尺寸,避免每轮 launch 重复全表扫描。 4. **Ctrl / Sche 其它热路径** - Slot / Stitch / Task / AICore 管理路径的小幅去冗余、指针/数据预取与分支收敛(见对应 device_*_context 与 aicore_manager 改动)。 See merge request: cann/pypto!5431 | 3 个月前 | |
feat(ir): Support dump function attribute Co-authored-by: tsungl4<lidongsheng4@huawei.com> # message auto-generated for no-merge-commit merge: !6675 merge attr into master feat(ir): Support dump function attribute Created-by: tsungl4 Commit-by: tsungl4 Merged-by: cann-robot Description: Related Issue: #2559 See merge request: cann/pypto!6675 | 2 个月前 | |
fix(machine): Fix dynamic partial-update cell match lifecycle Co-authored-by: Songyangyang18<songyangyang18@huawei.com> # message auto-generated for no-merge-commit merge: !2723 merge lp4 into master fix(machine): Fix dynamic partial-update cell match lifecycle Created-by: songyangyang18 Commit-by: Songyangyang18 Merged-by: cann-robot Description: # 一、需求背景 相关issue: https://gitcode.com/cann/pypto/issues/489,//有规避方法,未解决根本问题 https://gitcode.com/cann/pypto/issues/748,//方案说明 https://gitcode.com/cann/pypto/issues/608,//疑似相同问题,本地稳定可以复现 例如在以下用例中,z 的高维大小由 x 的 shape 确定。当 x 是动态 shape 时,z 的大小是动态的。导致 LOOP_1 和 LOOP_2 在 stitch 到一起时,LOOP_1 中对 z 的 assemble 操作无法正确建立指向 LOOP_2 中对 z view 的z_view 等 tensor 的依赖,进而导致在缺少这些依赖时,存在精度问题。 def matmul_kernel(x, y, bias, out): pypto.set_debug_options(runtime_debug_mode=1) bsz, h = x.shape d = y.shape[1] z = pypto.Tensor([bsz, d], dtype=pypto.DT_FP32) b = 128 b_loop = (bsz + b - 1) // b for b_idx in pypto.loop(b_loop, name="LOOP_1", idx_name="b_idx"): b_valid = (bsz-b_idx*b).min(b) x_view = pypto.view(x, [b, h], [b_idx*b, 0], valid_shape=[b_valid, h]) ## Matmul pypto.set_cube_tile_shapes([128, 128], [128, 128], [128, 128]) c = pypto.matmul(x_view, y, pypto.DT_FP32) pypto.assemble(c, [b_idx*b, 0], z) c = 128 c_loop = (bsz + c - 1) // c for c_idx in pypto.loop(c_loop, name="LOOP_2", idx_name="c_idx"): c_valid = (bsz-c_idx*c).min(c) z_view = pypto.view(z, [c, d], [c_idx*c, 0], valid_shape=[c_valid, d]) bias_view = pypto.view(bias, [c, d], [c_idx*c, 0], valid_shape=[c_valid, d]) pypto.set_vec_tile_shapes(128, 128) pypto.assemble(z_view + bias_view, [c_idx*c, 0], out) 由于当前采用 cell match 来动态计算依赖关系,但是 cell match 在匹配时,需要事先分配相应大小的 cell match table,并且由 prod 更新 cell match table,由 con 读取 cell match table 中的值来建立依赖关系。 # 原因分析 根本原因是目前对于局部动态tensor的处理存在不足。 1. cell match 的问题 目前对于patial update slot,局部tensor需要cell match table,这是用于构建dev_task内依赖关系的重要机制。  目前的cell match table需要在编译期确定完整的大小,以准备完整的DevAscendProgram数据,但是动态局部tensor在编译期只能得到符号表达式,而非实际的大小,所以目前的 cell match table 缺乏处理动态大小tensor的能力,目前的做法是忽视动态大小的-1轴,当作正常数值计算,导致计算得到的cell table大小恒为1,这在动态轴大小为更大的数值(如128)时明显计算错误,这个错误会带到运行时,从而导致依赖建立的丢失或错误。  # 方案设计 考虑单独构建局部动态tensor的cell match分配器,用于运行时分配cell match table,尽量将所有需要的数值在launch阶段得到,运行时直接取,减少计算; ## 编译期(Encode) 1. 支持动态 cell-match 延后决策:编译期允许部分 cell-match 描述先不完整(动态维度场景),不再强行一次性定死。 2. 新增动态元数据输出:产物里补充 dynamic cell-match 的预算上限、slot 数量、以及 launch 期补丁所需 meta(offset/cell shape/候选维度表达式)。 3. workspace 预算模型扩展:把 dynamic cell-match 内存纳入 memBudget.metadata,总预算从“两段式”扩为“三段式”(general + dynamicCellMatch + stitchPool)。 ## Launch 阶段 1. 启动前按真实输入 patch 描述符:基于本次输入 shape 计算 stride,并写回 cfgdata(host 或 H2D)。 2. 动态预算随 kArgs 下发并回填设备侧:新增 dynamic assemble / dynamic cell-match 两类预算字段,设备初始化时回填并重算 runtime offset。 3. 地址布局升级:runtime offset 新增 dynamicCellMatchOffset,形成独立内存区,避免与 general/stitchPool 混用。 ## 运行时(Workspace/Slot 生命周期) 1. partial-update slot 标记更准确:按真实 slotIndex + 描述状态 标记,不再依赖旧的隐式假设。 2. 动态 cell-match 表按需分配/初始化:在 slot 更新和 assemble 分配路径中补齐“分配-初始化-绑定”闭环。 3. 回收路径补全:boundary outcast 释放时联动释放 dynamic cell-match 分配,避免残留和泄漏。 ## Cost Model 模块 1. 与真实 launch 对齐:cost model 启动时同步接收 dynamic 预算参数。 2. 同样执行动态 patch 逻辑:仿真前也按输入求值并 patch cell-match desc,避免“仿真和实跑不一致”。 3. 测试链路同步:ST runner 加入同类 budget refill + desc patch,保证测试口径一致。 See merge request: cann/pypto!2723 | 6 个月前 | |
refactor(all): Remove trailing whitespace Co-authored-by: tsungl4<lidongsheng4@huawei.com> # message auto-generated for no-merge-commit merge: !2188 merge pre-commit into master refactor(all): Remove trailing whitespace Created-by: tsungl4 Commit-by: tsungl4 Merged-by: cann-robot Description: Introduce pre-commit tools, and remove trailing white space with default plugin Related Issue: #1017 See merge request: cann/pypto!2188 | 7 个月前 | |
style(all): Apply additional clang-format corrections across codebase Co-authored-by: junjieHuang<huangjunjie38@h-partners.com> # message auto-generated for no-merge-commit merge: !4883 merge style-cpp into master style(all): Apply additional clang-format corrections across codebase Created-by: junjieHuang Commit-by: junjieHuang Merged-by: cann-robot Description: Apply additional clang-format corrections across codebase See merge request: cann/pypto!4883 | 4 个月前 | |
style(all): Apply additional clang-format corrections across codebase Co-authored-by: junjieHuang<huangjunjie38@h-partners.com> # message auto-generated for no-merge-commit merge: !4883 merge style-cpp into master style(all): Apply additional clang-format corrections across codebase Created-by: junjieHuang Commit-by: junjieHuang Merged-by: cann-robot Description: Apply additional clang-format corrections across codebase See merge request: cann/pypto!4883 | 4 个月前 | |
style(all): Apply additional clang-format corrections across codebase Co-authored-by: junjieHuang<huangjunjie38@h-partners.com> # message auto-generated for no-merge-commit merge: !4883 merge style-cpp into master style(all): Apply additional clang-format corrections across codebase Created-by: junjieHuang Commit-by: junjieHuang Merged-by: cann-robot Description: Apply additional clang-format corrections across codebase See merge request: cann/pypto!4883 | 4 个月前 | |
style(all): Apply additional clang-format corrections across codebase Co-authored-by: junjieHuang<huangjunjie38@h-partners.com> # message auto-generated for no-merge-commit merge: !4883 merge style-cpp into master style(all): Apply additional clang-format corrections across codebase Created-by: junjieHuang Commit-by: junjieHuang Merged-by: cann-robot Description: Apply additional clang-format corrections across codebase See merge request: cann/pypto!4883 | 4 个月前 | |
fix(machine): Fix inner temporal memory check Co-authored-by: songyangyang18<songyangyang18@huawei.com> # message auto-generated for no-merge-commit merge: !6875 merge bound into master fix(machine): Fix inner temporal memory check Created-by: songyangyang18 Commit-by: songyangyang18 Merged-by: cann-robot Description: 修复检验逻辑没有适配Inner Temporal内存最大值修改的问题。 See merge request: cann/pypto!6875 | 1 个月前 | |
feat(machine): Add option to control memory reuse of workspace Co-authored-by: duanhaotian<duanhaotian@huawei.com> # message auto-generated for no-merge-commit merge: !5427 merge duanhaotian13 into master feat(machine): Add option to control memory reuse of workspace Created-by: duanhaotian Commit-by: duanhaotian Merged-by: cann-robot Description: ## 改造后:精细 Workspace 总体流程 改造后保留 max_workspace_kb 粗调模式,同时新增 actual_stitch_function_num=[d0,d1,d2] 精细模式。两个模式共用需求收集、memBudget、序列化、Host 申请和 Device allocator,只在容量决策方式上分流。 mermaid flowchart TD Config["配置<br/>max_workspace_kb<br/>actual_stitch_function_num=[d0,d1,d2]"]:::added Load["LoadRuntimeWorkspaceConfig<br/>长度/范围校验并映射三个 depth"]:::added Collect["复用原有需求收集<br/>WorkspaceDesc"]:::legacy Mode{"数组是否为 [0,0,0]"}:::decision Coarse["保留原有 max_workspace_kb / 统一 k_eff 路径"]:::legacy Validate{"每个非空池是否至少支持一个 RootFunction"}:::decision Precise["独立计算三个池容量<br/>CalculatePreciseWorkspaceLayout"]:::added Apply["ResolveStitchDepthConfig<br/>ApplyStitchDepthConfig"]:::added Budget["memBudget.tensor 最终容量<br/>+ workspaceControl 单位需求与深度"]:::added Encode["DevProg 两遍编码并序列化"]:::legacy Dynamic["动态 Shape 求值更新 MaxOutcastMem<br/>深度和池 Slot 数不重算"]:::added HostAlloc["Host 按 memBudget.Total() 申请 Workspace"]:::legacy Init["DeviceWorkspaceAllocator::InitTensorAllocators"]:::legacy Pools["注册原有四池<br/>容量来自精细预算结果"]:::legacy Preflight{"当前 Root 追加前精确预检"}:::decision Alloc["真实申请并绑定地址"]:::legacy Observe["采集三个精细池 current/peak"]:::added Submit["内存不足或原有边界触发 Submit"]:::added Tuning["窗口日志、Launch 汇总和推荐 depth"]:::added Recycle["回收当前窗口并重置窗口峰值"]:::added Config -.-> Load Collect --> Mode Load -.三个 depth.-> Mode Mode -->|是| Coarse Mode -->|否| Validate Validate -->|通过| Precise Validate -->|失败| Error["编码期报错"]:::decision Coarse --> Apply Precise -.-> Apply Collect --> Apply Apply -.-> Budget Budget --> Encode --> Dynamic --> HostAlloc --> Init --> Pools --> Preflight Preflight -->|通过| Alloc --> Observe --> Preflight Preflight -->|失败且窗口非空| Submit Preflight -->|失败且窗口为空| RuntimeError["单个 Root 无法容纳,运行时报错"]:::decision Alloc -->|控制流/硬阈值| Submit Submit --> Tuning --> Recycle --> Preflight classDef legacy fill:#f5f5f5,stroke:#666,stroke-width:1px,color:#222 classDef added fill:#e6f4ff,stroke:#1677ff,stroke-width:3px,color:#102a43 classDef decision fill:#fff7e6,stroke:#d46b08,stroke-width:2px,color:#5c2b00 ### 总体前后差异 | 维度 | 改造前 | 改造后 | |---|---|---| | 外部控制 | max_workspace_kb 总量粗调 | 保留粗调;新增三池 depth 数组 | | 模式启用 | 根据总预算和 Stitch 上限求统一深度 | [0,0,0] 走粗调;任一非零走精细模式 | | 三池容量 | 同一个 k_eff 同步放大 | 三个 depth 独立计算 | | max_workspace_kb | 作为粗调总量依据 | 精细模式下不再截断用户指定的三池容量 | | Boundary Outcast | 拓扑固定 | 仍拓扑固定,不对外精细控制 | | Runtime allocator | 原有四池 | 复用原有四池,无新池 | | 运行时观测 | 无三池闭环推荐 | Window/Launch 峰值、推荐 depth、depth 内存影响 | | 热路径成本 | 无新增采样 | 由 ENABLE_PROFILE_GUIDED 编译期开关隔离 | | 追加前预检 | 聚合 Slot 粗估,失败原因不明确 | 按 Exclusive、InnerTemporal 和 RuntimeItem 分项预检 | | 内存不足处理 | 已有失败后 Submit/重试框架 | 保留框架,增加原因、空窗口保护和更准确预测 | --- See merge request: cann/pypto!5427 | 2 个月前 |
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 24 天前 | ||
| 7 个月前 | ||
| 3 个月前 | ||
| 4 个月前 | ||
| 4 个月前 | ||
| 4 个月前 | ||
| 27 天前 | ||
| 1 个月前 | ||
| 3 个月前 | ||
| 2 个月前 | ||
| 1 个月前 | ||
| 2 个月前 | ||
| 2 个月前 | ||
| 2 个月前 | ||
| 3 个月前 | ||
| 1 个月前 | ||
| 2 个月前 | ||
| 2 个月前 | ||
| 24 天前 | ||
| 1 个月前 | ||
| 28 天前 | ||
| 3 个月前 | ||
| 2 个月前 | ||
| 24 天前 | ||
| 1 个月前 | ||
| 1 个月前 | ||
| 30 天前 | ||
| 4 个月前 | ||
| 24 天前 | ||
| 24 天前 | ||
| 1 个月前 | ||
| 3 个月前 | ||
| 2 个月前 | ||
| 6 个月前 | ||
| 7 个月前 | ||
| 4 个月前 | ||
| 4 个月前 | ||
| 4 个月前 | ||
| 4 个月前 | ||
| 1 个月前 | ||
| 2 个月前 |