| Files | Last commit | Last update |
|---|---|---|
fix(machine): Revert pull request 4342 Co-authored-by: junjieHuang<huangjunjie38@h-partners.com> # message auto-generated for no-merge-commit merge: !4364 merge fix into master fix(machine): Revert pull request 4342 Created-by: junjieHuang Commit-by: junjieHuang Merged-by: cann-robot Description: 1、PR 4342 caused CI timeout, revert it 2、Fix some static warnings See merge request: cann/pypto!4364 | 5 months ago | |
fix(dfx): Modify error code h path Co-authored-by: meiqing2<meiqing2@hisilicon.com> # message auto-generated for no-merge-commit merge: !2697 merge errcode into master fix(dfx): Modify error code h path Created-by: meiqing2 Commit-by: meiqing2 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 规范](https://gitcode.com/cann/pypto/blob/master/docs/contribute/pull-request.md#commit-message) See merge request: cann/pypto!2697 | 7 months ago | |
feat(codegen): Add op magic comment after TileOp Co-authored-by: Bee.Hujun<Bee.hujun@huawei.com> # message auto-generated for no-merge-commit merge: !2250 merge codegen/add_op_magic into master feat(codegen): Add op magic comment after TileOp Created-by: cam_bxh Commit-by: Bee.Hujun Merged-by: cann-robot Description: Related Issue: https://gitcode.com/cann/pypto/issues/1060 Add op magic comment after TileOp See merge request: cann/pypto!2250 | 7 months ago | |
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 months ago | |
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 months ago | |
refactor(frontend): Adding errCode for frontend. Co-authored-by: junjieHuang<huangjunjie38@h-partners.com> # message auto-generated for no-merge-commit merge: !2563 merge log into master refactor(frontend): Adding errCode for frontend. Created-by: junjieHuang Commit-by: junjieHuang Merged-by: cann-robot Description: 1. FUNCTION_LOGE错误码补充 2. ASSERT错误码补充 3. python前端封装FrontendError 补充错误码打印 4. FUNCTION日志宏前缀统一为"FE", 即Frontend See merge request: cann/pypto!2563 | 6 months ago | |
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 months ago | |
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 months ago | |
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 months ago | |
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 months ago | |
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 months ago | |
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 months ago | |
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 months ago | |
feat(distributed): Reduce signal memory usage Co-authored-by: codehjp423<hanjunpei@huawei.com> # message auto-generated for no-merge-commit merge: !2227 merge maxtile into master feat(distributed): Reduce signal memory usage Created-by: codehjp423 Commit-by: codehjp423 Merged-by: cann-robot Description: feat(distributed): Reduce signal memory usage 此PR是为了解决如下问题:由于pypto存在切分,因此每一个在tensor graph中的signal,经过expandfunction后会变成多份;但是在创建signal tensor时并不清楚实际需要创建多大的shape,为了解决这个问题,原来解决方案是创建一个“足够大”的shape,但是这会造成内存使用的浪费。 Changes: ShmemTensor结构增加了signalOp,用于在tensor graph中记录创建signal的bindtensor op tensor graph中,在处理ShmemSignal时,获取切分信息,根据signal shape和tileshape计算出maxtilenum,如果maxtilenum超过signal tensor当前maxtilenum,则更新 在分配shmem signal时,按照最终的maxtilenum分配内存 See merge request: cann/pypto!2227 | 7 months ago | |
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 months ago | |
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 months ago | |
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 months ago | |
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 months ago | |
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 months ago | |
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 months ago | |
feat(machine): Memory-driven workspace budget Co-authored-by: LordOfMysteries<duhongxiang@huawei.com> # message auto-generated for no-merge-commit merge: !4395 merge feat/expr-memory-dual-pool-integration into master feat(machine): Memory-driven workspace budget Created-by: LordOfMysteries Commit-by: LordOfMysteries Merged-by: cann-robot Description: https://gitcode.com/cann/pypto/issues/1740 # Workspace 预算计算器架构设计 --- ## 核心语义(当前实现) **Encode / tensor 预算与 unroll 解耦**: k_eff 表示最多 stitch 多少个 **root function**(与 unrolllist 改造前一致)。workspace 按整段 root 的 raw 需求 × k 线性缩放,**不**再除以 unrollTimes,也**不**使用 maxPerUnit* 聚合快捷路径。 **Runtime submit 仍按 unroll 单元计量**(非 MD):StitchUnits() = Σ unrollTimes;达到 stitchMaxFunctionNum 后 submit。这与 encode 侧 root 粒度预算分层设计,避免 workspace 被 stitchNum × MAX_UNROLL 粗暴放大。 | 维度 | Encode / workspace | Runtime submit | |------|-------------------|----------------| | 深度 k | root function 个数 | 非 MD:StitchUnits(unroll 累加);MD:主要靠 stitchMaxFunctionNum + allocator | | stitchMaxFunctionNum | 非 MD = stitchNumMax;MD = kEff | 写入 devProg,作为非 MD 的 unroll 单元阈值 | | root 硬顶 | pool depth min(k, 1024) | Size() >= MAX_STITCH_FUNC_NUM(1024) | --- ## 背景:两项关联调整 ### 问题陈述(摘自 old.md) 1. **Unroll 与 Stitch 语义不一致**:旧逻辑 workspace 用 stitchNum × MAX_UNROLL_TIMES 放大,与 runtime 计量方式不匹配。 2. **Workspace 不可配置**:仅能通过 stitch_function_max_num 间接控内存。 3. **Outcast 缓存深度与 stitch 深度耦合**:boundary / pool / ctrlflow 未按 root 粒度 k 分层。 ### 两项调整的关系 mermaid flowchart TB subgraph part1 [调整一:语义分层] A1["Runtime 非 MD: StitchUnits 按 unrollTimes 累加"] A2["Encode: AlignUp(raw) × k,k = root 个数"] A3["stitchMaxFunctionNum = stitchNumMax 或 kEff"] A4["outcastCacheDepth / poolDepth = f(k_eff),无 unroll 归一化"] end subgraph part2 [调整二:Memory-Driven] B1["max_workspace_kb → DeriveEffectiveStitchNum 反推 k"] B2["MD: 跳过 StitchUnits 阈值 submit"] B3["k_eff = min(derived, stitchNumMax)"] end part1 --> part2 | 维度 | 调整一 | 调整二(memory-driven) | |------|--------|-------------------------| | Encode | BuildTensorWorkspaceFromDescriptor(desc, k) | 二分 DeriveEffectiveStitchNum,cap 后 cap 至 stitchNumMax | | Runtime | 非 MD:StitchUnits + unroll > stitchMaxFunctionNum | memoryDrivenWorkspace≠0 时跳过 unroll 单元阈值 | | 配置 | stitch_function_max_num | 额外 max_workspace_kb | --- ## 调整一:Encode 预算 + Runtime submit ### Runtime 行为 | 项 | 行为 | |----|------| | Stitch 计量 | StitchUnits() = Σ unrollTimes(device_stitch_context) | | 非 MD submit | StitchUnits() + unroll > stitchMaxFunctionNum(stitchMaxFunctionNum = 配置的 stitchNumMax) | | MD submit | 跳过 stitchUnitsExceeded;依赖 stitchMaxFunctionNum(= kEff)与 workspace allocator | | root 硬顶 | stitchContext.Size() >= MAX_STITCH_FUNC_NUM(1024,MD / 非 MD 相同) | | callop 硬顶 | stitchedCallOpSize + opSize > stitchFunctionsize | 实现:[device_execute_context.cpp](../../framework/src/machine/device/dynamic/context/device_execute_context.cpp) CallRootFunctionAlloc。 ### Encode 采集与预算 **Per-root 采集**([CollectWorkspaceDesc](../../framework/src/machine/utils/dynamic/dev_encode_workspace.cpp) → rootFuncDescList): rootInnerSpilledRawMem ← devFunc->rootInnerTensorWsMemoryRequirement rootTotalExclusiveOutcastRawMem ← devFunc->exclusiveOutcastWsMemoryRequirement unroll ← devFunc->unrollTimes(仅 runtime / dump,不参与 tensor × k) **Tensor 深度 k**(k_eff 或非 MD 时为 stitchNumMax): maxRootInnerSpilledMem = max_root( AlignUp(rootInnerSpilledRawMem) × k ) maxRootTotalExclusiveOutcastMem = max_root( AlignUp(rootTotalExclusiveOutcastRawMem) × k ) devTaskBoundaryOutcastNum = E × 2 + A × 2 # 固定 devTaskInnerTemporalOutcastNum = A × k tensor.Total = inner + exclusive + maxStaticOutcastMem × (boundary + innerTemporal) encoded = AlignUp(tensor.Total, 32KB) × parallelism + aicoreSpilled + debug 实现:[workspace_budget_calculator.cpp](../../framework/src/machine/utils/dynamic/workspace_budget_calculator.cpp) BuildTensorWorkspaceFromDescriptor / WorkspaceTotalFromDesc。 **Outcast / ctrlflow 深度**(root 个数语义,API 已精简): cpp DeriveOutcastCacheDepth(k) // k==0 → 1,否则 k DeriveRuntimeOutcastPoolDepth(k) // min(k, MAX_STITCH_FUNC_NUM),k==0 → 1 runtimeOutcastPoolSize = totalSlot × (runtimeOutcastPoolDepth + 1) × parallelism outcastCacheDepth 与 runtimeOutcastPoolDepth 在 MD / 非 MD 路径公式相同;MD 与非 MD 差异体现在 kEff 取值与 runtime submit 策略。 ### 大 unroll 与性能 - **Workspace**:不再因 unroll 额外放大;同一 stitchNumMax 下大 unroll 图 tensor 预算通常更低或持平。 - **Runtime 非 MD**:StitchUnits 按 unroll 累加,相同 stitchNumMax=64 时,unroll=512 的 root 一次 append 即贡献 512 单元,**更容易触发 submit**,单次 stitch 含 fewer root 但 more unroll 单元——与旧「按 root 个数 submit」行为不同,需单独回归。 - **stitchMaxFunctionNum 不再** max(stitchNumMax, maxUnrollTimes);encode 与配置保持一致(64 即 64)。 --- ## 调整二:Memory-Driven ### 架构 mermaid flowchart LR subgraph encode [Encode 胶水层 dev_encode.cpp] A[EncodeDevAscendProgramFull] end subgraph encodeWs [Encode 域 dev_encode_workspace] L[LoadRuntimeWorkspaceConfig] C[CollectWorkspaceDesc] V[ValidateMaxWorkspaceOrThrow] W[ApplyStitchDepthConfig / LogWorkspaceEncodeSummary] end subgraph calc [计算层 workspace_budget_calculator] B[ResolveStitchDepthConfig] D[DeriveEffectiveStitchNum] end A --> L A --> C L --> V C --> B L --> B B --> D B --> W W --> A ### Encode 数据流 cpp RuntimeWorkspaceConfig cfg = LoadRuntimeWorkspaceConfig(); WorkspaceDesc wsDesc = CollectWorkspaceDesc(func, *devProg, ...); cfg.workspaceStitchMin = TensorWorkspaceBytesAtMinimumStitchDepth(wsDesc, ...); ValidateMaxWorkspaceOrThrow(cfg.maxWorkspaceBytes, cfg.workspaceStitchMin); StitchDepthConfig depth = ResolveStitchDepthConfig(wsDesc, cfg); ApplyStitchDepthConfig(devProg, wsDesc, depth, totalSlot); LogWorkspaceEncodeSummary(...); ### MD 与 encode 的衔接 | 机制 | 作用 | |------|------| | kEff = min(DeriveEffectiveStitchNum(cap), stitchNumMax) | cap 内反推 root 深度,且不超过配置 | | stitchMaxFunctionNum = kEff | MD 下 runtime stitch 窗口与 tensor 深度一致 | | memoryDrivenWorkspace = 1 | runtime 跳过 StitchUnits 阈值 | | encodedWorkspaceSize = maxWorkspaceBytes | tensor 预算 cap(不含 metadata / debug 等) | **注意**:max_workspace_kb 仅 cap **tensor 预算**;workspaceSize = memBudget.Total() 仍含 metadata / aicoreSpilled / debug。 ### 二分逻辑(DeriveEffectiveStitchNum) 前提:max_workspace_kb > workspaceStitchMin(k=1 可运行预算);由 ValidateMaxWorkspaceOrThrow 保证。 1. **指数扩张**:k=1 起 hi 翻倍,直到 tensorBytesAt(hi) > cap、预算平台期、或 uint32 溢出。 2. **确定二分上界**:最后一个 fit 的 hi,或扩至 UINT32_MAX(若预算仍随 k 增长)。 3. **二分**:在 [lo, searchHi] 取满足 cap 的最大 k。 4. **平台期收缩**:BytesAt(k) == BytesAt(k-1) 时取更小 k(32KB 对齐或 raw 主导时常见)。 单次 encode 约 O(log k_eff) 次 tensorBytesAt;每次复制 WorkspaceDesc 并调用 BuildTensorWorkspaceFromDescriptor。 --- ## 分层深度对照表 | 字段 | 非 memory-driven | memory-driven | |------|------------------|---------------| | kEff | stitchNumMax | min(DeriveEffectiveStitchNum(cap), stitchNumMax) | | outcastCacheDepth | DeriveOutcastCacheDepth(kEff) | 同左 | | runtimeOutcastPoolDepth | DeriveRuntimeOutcastPoolDepth(kEff) → min(kEff, 1024) | 同左 | | stitchMaxFunctionNum | stitchNumMax | kEff | | rootFuncCountExceeded | Size() >= MAX_STITCH_FUNC_NUM | 同左 | | encodedWorkspaceSize | 按 kEff 计算的 tensor 总量 | maxWorkspaceBytes | | maxWorkspaceBytesLimit | 0 | cap bytes | | 非 MD runtime submit | StitchUnits + unroll > stitchMaxFunctionNum | — | | MD runtime submit | — | 跳过 StitchUnits 阈值;allocator / root 硬顶 | --- ## WorkspaceDesc schema(精简后) cpp struct WorkspaceConfig { uint64_t parallelism{0}; // 仅 parallelism;已移除 innerSpilledRecyclePeriod / unrollStitchCount / actualStitchCount }; struct WorkspacePerRootFunctionDesc { // raw 采集值 + unroll(dump);预算结果在 desc.maxRoot* 聚合字段 uint64_t rootInnerSpilledRawMem; uint64_t rootTotalExclusiveOutcastRawMem; uint64_t unroll; // ... }; rootFuncDescList 为空时 inner / exclusive 预算为 0(无 maxPerUnit* fallback)。 --- ## 对算子开发者一句话总结 使能了unrolllist的算子,需要按照打屏/日志提示配置上workspace内存大小(max_workspace_kb)来使能内存驱动模式以达到修改前的表现。 See merge request: cann/pypto!4395 | 4 months ago |
| Files | Last commit | Last update |
|---|---|---|
| 5 months ago | ||
| 7 months ago | ||
| 7 months ago | ||
| 4 months ago | ||
| 4 months ago | ||
| 6 months ago | ||
| 4 months ago | ||
| 4 months ago | ||
| 4 months ago | ||
| 4 months ago | ||
| 7 months ago | ||
| 4 months ago | ||
| 4 months ago | ||
| 7 months ago | ||
| 4 months ago | ||
| 4 months ago | ||
| 4 months ago | ||
| 7 months ago | ||
| 4 months ago | ||
| 4 months ago | ||
| 4 months ago |