| Files | Last commit | Last update |
|---|---|---|
fix(machine): Fix missing unit issue. Co-authored-by: chai-hw<chaizhengtong@huawei.com> # message auto-generated for no-merge-commit merge: !5489 merge machine_format into master fix(machine): Fix missing unit issue. Created-by: chai-hw Commit-by: chai-hw Merged-by: cann-robot Description: 修复日志中单位的缺失,使日志信息更便于阅读 See merge request: cann/pypto!5489 | 3 months ago | |
feat(machine): Migrate aicore print to host-side management for capture Co-authored-by: wan_jianfen<wanjianfen@hisilicon.com> # message auto-generated for no-merge-commit merge: !5216 merge feat/aicore-print-host-mgr into master feat(machine): Migrate aicore print to host-side management for capture Created-by: wan_jianfen Commit-by: wan_jianfen Merged-by: cann-robot Description: feat(machine): Migrate aicore print to host-side management for capture The aicore print log mechanism was managed on the device side (AICPU) via AicoreLogManager, which reads logs synchronously inside AiCoreManager::RunTask. This breaks Stream recording semantics in capture (aclgraph) mode and couples print buffer management with scheduling logic. This PR moves aicore print buffer management to the host side. Changes: - Add AicorePrintHostManager: host allocates per-core HBM ring buffers, injects addresses into shakeBuffer[5] via H2D, and D2H-copies + decodes TLV records to host log after task sync - Integrate AicorePrintHostManager into DeviceRunner; skip sync and dump in capture mode to preserve recording - Skip debug sync and data-dump sync in DeviceLauncher when in capture mode - Remove device-side AicoreLogManager, InitLogger/DumpAicoreLog/logger_ from AiCoreManager, and shakeBuffer write from AiCoreHal - Add Newline record type and EncodeNewline for per-log separation; support BindHostBuffer/GetConsumedTail for host-side decoding in AicoreLogger Related Issues: #2846 See merge request: cann/pypto!5216 | 3 months ago | |
feat(machine): Add log level control and timestamp to aicore print Co-authored-by: wan_jianfen<wanjianfen@hisilicon.com> # message auto-generated for no-merge-commit merge: !5352 merge feat/aicore-log-level-control into master feat(machine): Add log level control and timestamp to aicore print Created-by: wan_jianfen Commit-by: wan_jianfen Merged-by: cann-robot Description: ## 关联 Issue Closes #2915 ## 改动说明 为 AICore Print 系统添加日志级别控制、时间戳记录和专用 host 输出宏。 ### 改动内容 1. **日志级别控制** - 新增 AicoreLogLevel 枚举(DEBUG/INFO/WARN/ERROR/NONE) - LogContext 新增 logLevel 字段,由 DevDfxArgs.logLevel(host 侧 dlog_getlevel)传递到 device - AicoreLogger::Init() 接收 level 参数并写入 ctx_.logLevel - 新增 AICORE_LOGD/LOGI/LOGW/LOGE 宏,参照 DEV_INFO/DEV_DEBUG 模式按级别过滤 2. **时间戳记录** - 新增 TimestampMarker TLV 记录类型 - AiCoreLogFWithLevel 中通过 get_sys_cnt() 编码 device 侧周期计数器值 - Host 侧 Read() 解码时间戳并通过 outTimestamp 参数返回 3. **Host 侧专用日志宏** - LogModule 枚举新增 AICORE - 新增 AICORE_HOST_LOGD/LOGI/LOGW/LOGE 宏,不带 host file:line 前缀,使用 device cycle 作为时间戳 - DumpAicoreLog 按级别 switch 调用对应宏 4. **MAX_DIMS 重定义修复** - core_func_data.h 的 MAX_DIMS=8 重命名为 MAX_TENSOR_INFO_DIMS,避免与 layout.h 的 MAX_DIMS=5 冲突 ### 输出格式示例 [core-0][cycle=1234567890][INFO] === After TLoad === [core-0][cycle=1234567895][DEBUG] gmTensor_1 addr=0x... [core-0][cycle=1234567900][INFO] === After TAdd === ### 文件变更 | 文件 | 改动 | |------|------| | aicore_print_base.h | AicoreLogLevel 枚举、LogContext.logLevel、LogLevelMarker/TimestampMarker DataType | | aicore_print_logger.h | Init() 接收 level、EncodeLogLevel/EncodeTimestamp、Read() 返回 level+timestamp | | aicore_print.h | AiCoreLogFWithLevel、AICORE_LOGD/LOGI/LOGW/LOGE 宏 | | aicore_print_host_decode.h | DecodeLogLevelMarker | | aicore_entry.h | KernelEntry 读取 DevDfxArgs.logLevel 传入 InitCtx | | tilefwk_log.h | LogModule 新增 AICORE | | pypto_fwk_log.h | AICORE_HOST_LOGD/LOGI/LOGW/LOGE 宏 | | aicore_print_host_manager.cpp | DumpAicoreLog 按级别+时间戳输出 | | core_func_data.h | MAX_DIMS → MAX_TENSOR_INFO_DIMS | ## 验证方式 1. 设置 ASCEND_GLOBAL_LOG_LEVEL=1(INFO),运行用例,grep "AICORE" ./wk 验证仅 INFO 及以上级别输出 2. 设置 ASCEND_GLOBAL_LOG_LEVEL=0(DEBUG),验证 DEBUG 日志出现 3. 验证每条日志带 [cycle=N] 时间戳 See merge request: cann/pypto!5352 | 3 months ago | |
feat(machine): Migrate aicore print to host-side management for capture Co-authored-by: wan_jianfen<wanjianfen@hisilicon.com> # message auto-generated for no-merge-commit merge: !5216 merge feat/aicore-print-host-mgr into master feat(machine): Migrate aicore print to host-side management for capture Created-by: wan_jianfen Commit-by: wan_jianfen Merged-by: cann-robot Description: feat(machine): Migrate aicore print to host-side management for capture The aicore print log mechanism was managed on the device side (AICPU) via AicoreLogManager, which reads logs synchronously inside AiCoreManager::RunTask. This breaks Stream recording semantics in capture (aclgraph) mode and couples print buffer management with scheduling logic. This PR moves aicore print buffer management to the host side. Changes: - Add AicorePrintHostManager: host allocates per-core HBM ring buffers, injects addresses into shakeBuffer[5] via H2D, and D2H-copies + decodes TLV records to host log after task sync - Integrate AicorePrintHostManager into DeviceRunner; skip sync and dump in capture mode to preserve recording - Skip debug sync and data-dump sync in DeviceLauncher when in capture mode - Remove device-side AicoreLogManager, InitLogger/DumpAicoreLog/logger_ from AiCoreManager, and shakeBuffer write from AiCoreHal - Add Newline record type and EncodeNewline for per-log separation; support BindHostBuffer/GetConsumedTail for host-side decoding in AicoreLogger Related Issues: #2846 See merge request: cann/pypto!5216 | 3 months ago | |
fix(docs): Standardize aicore-exception FAQ format and translate Chinese comments to English Co-authored-by: chai-hw<chaizhengtong@huawei.com> # message auto-generated for no-merge-commit merge: !5757 merge delete_printf into master fix(docs): Standardize aicore-exception FAQ format and translate Chinese comments to English Created-by: chai-hw Commit-by: chai-hw Merged-by: cann-robot Description: 部分日志含有中文日志输出,现修改为英文,为了保持统一性,将注释也修改为英文 删除不被允许的printf内容,并且将文档中aicore error报错时的信息与实际修改为一致 See merge request: cann/pypto!5757 | 3 months ago | |
feat(dfx): Refine exception callback Co-authored-by: meiqing2<meiqing2@hisilicon.com> # message auto-generated for no-merge-commit merge: !3727 merge exception into master feat(dfx): Refine exception callback Created-by: meiqing2 Commit-by: meiqing2 Merged-by: cann-robot Description: 背景:device的返回值需要在rt_error_codes.h中定义的错误码范围内,exceptioncallback里才能区别出不同报错场景 1. 避免对cann的依赖,新增device_error_code.h(error_code.h头文件超大),重新集中定义 PYPTO_DEVICE_xx 错误码宏,和rt_error_codes.h保持一致,覆盖 107/207/507 三段。 2. device_utils.h 中 DEVICE_MACHINE_xx 改为引用 PYPTO_DEVICE_xx,消除硬编码值。 3. device_error_tracking 重构:报错打屏格式和PTA/cann error保持一致,GetRetcodeMessage 查表输出错误描述;PyPTOExceptionInfoCallBack 按 expandInfo.type 判断 union 分支,仅 AICore 异常时安全读取 kernelName,其余类型输出 (Null),避免越界脏数据。 4. 超时检测手动trap 5. 后续device新增代码请直接使用 errco_code.h 中的 PYPTO_DEVICE_xx 返回值 6. 进一步优化依赖后续device machine void整改 See merge request: cann/pypto!3727 | 5 months ago | |
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 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 | |
feator(machine): Add prof for draicore Co-authored-by: wan_jianfen<wanjianfen@hisilicon.com> # message auto-generated for no-merge-commit merge: !5627 merge br_prof into master feator(machine): Add prof for draicore Created-by: wan_jianfen Commit-by: wan_jianfen 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!5627 | 3 months ago | |
feator(machine): Add prof for draicore Co-authored-by: wan_jianfen<wanjianfen@hisilicon.com> # message auto-generated for no-merge-commit merge: !5627 merge br_prof into master feator(machine): Add prof for draicore Created-by: wan_jianfen Commit-by: wan_jianfen 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!5627 | 3 months ago | |
fix(machine): Fix HUB stack overflow causing DRCO deadlock Co-authored-by: wan_jianfen<wanjianfen@hisilicon.com> # message auto-generated for no-merge-commit merge: !5760 merge fix-drco-hub-stack-overflow into master fix(machine): Fix HUB stack overflow causing DRCO deadlock Created-by: wan_jianfen Commit-by: wan_jianfen Merged-by: cann-robot Description: DRCO scheduling uses a fixed-size hubStack (64) for inline HUB task dependency resolution. When HUB task count exceeds 64, overflowed tasks were silently discarded, breaking dependency chains and causing all cores to spin until timeout. Changes: - Push overflowed HUB tasks to drcoCoreType ready queue as fallback - Consumer checks task coreType, HUB tasks skip ExecCoreFunctionKernel and directly call ExecDrcoResolve - HUB tasks do not increment executedTaskCount (not in totalTaskCount) Related Issues: #3148 See merge request: cann/pypto!5760 | 3 months ago | |
refactor(machine): Using KernelLaunchInfo and decouple device pref from device runner Co-authored-by: arthur_morgan_hw<lipeijie@huawei.com> # message auto-generated for no-merge-commit merge: !3542 merge br_runtime into master refactor(machine): Using KernelLaunchInfo and decouple device pref from device runner Created-by: arthur_morgan_hw Commit-by: arthur_morgan_hw Merged-by: cann-robot Description: 1、Kernel launch的所需要的可变的入参统一由新增的KernelLaunchInfo承载 2、把device perf相关的逻辑解耦出去 See merge request: cann/pypto!3542 | 5 months ago | |
fix(machine): Fix missing unit issue. Co-authored-by: chai-hw<chaizhengtong@huawei.com> # message auto-generated for no-merge-commit merge: !5489 merge machine_format into master fix(machine): Fix missing unit issue. Created-by: chai-hw Commit-by: chai-hw Merged-by: cann-robot Description: 修复日志中单位的缺失,使日志信息更便于阅读 See merge request: cann/pypto!5489 | 3 months ago | |
refactor(machine): Remove DeviceRunner and redistribute init flow Co-authored-by: wan_jianfen<wanjianfen@hisilicon.com> # message auto-generated for no-merge-commit merge: !5426 merge refactor/remove-device-runner into master refactor(machine): Remove DeviceRunner and redistribute init flow Created-by: wan_jianfen Commit-by: wan_jianfen Merged-by: cann-robot Description: refactor(machine): Remove DeviceRunner and redistribute init flow DeviceRunner was a god-class singleton that mixed device init, HostProf management, DevicePerf management, stream synchronization, and AiCpu .so loading. This PR dissolves it entirely, redistributing each responsibility to its natural module. Changes: - Move init flow (InitDeviceArgs / InitDeviceArgsCore / GetAicoreRegs / InitAiCpuSoBin / SetAiCpuSoOverride) into KernelBinary with static g_deviceArgs + std::call_once guard (EnsureInitialized / InitMetaData / GetEnableDumpDevPref) - Move HostProf methods (SetHostProfFunction / GetHostProfType / ReportHostProfInfo) into HostProf::GetInstance() singleton - Move DevicePerf methods (ResetPerData / SyncProfData / SetDebugEnable) into DevicePerf::GetInstance() singleton - Move DynamicLaunchSynchronize into DeviceLauncher - Move KernelLaunchInfo struct into device_launcher_types.h - Delete device_runner.h and device_runner.cpp - Update all call sites: device_launcher.cpp, kernel_bundle_launch.cpp, pypto_bundle_api.cpp, test_dev_func_runner.h, UT files - Remove device_runner.h from CMakeLists.txt install list Related Issues: #2967 See merge request: cann/pypto!5426 | 3 months ago | |
fix(machine): Add ring event sync for early launch slot reuse Co-authored-by: LordOfMysteries<duhongxiang@huawei.com> # message auto-generated for no-merge-commit merge: !5516 merge fix-ctrl-wait-sche-num into master fix(machine): Add ring event sync for early launch slot reuse Created-by: LordOfMysteries Commit-by: LordOfMysteries Merged-by: cann-robot Description: https://gitcode.com/cann/pypto/issues/3133 目前整网遇到个问题,mla这个算子(非值依赖,会走host cache完成stitch,每次上板只做restore和task下发)本地单跑ok,但是接入整网跑推理有问题,首先是pypto的aicore部分报scalar访问地址超过48bit。接入整网的模型大概是:图中mla算子每一次decode会穿插跑很多次(多层),每一次decode开头会有一些并发stream上的其它aicpu算子抢核,与这个并列的pypto sche cpu可能抢占不到同一个cluster的核,从开日志看确实有ArbitrationLevel从几次5后面全变成4的情况。然后整网hccl是通过aiv展开的,不存在抢aicpu核 现在实验了多种场景:(1)launch_sched_aicpu_num默认值或者设为2,整网都有上述问题,只有设为1才好(2)开了info日志就不复现了(3)launch_early_mode设为2,关闭提前发射后也不复现(4)怀疑ctrl下一轮的restore过程可能与sche上一轮的执行重叠,导致公用元数据被篡改。 [ERROR] RUNTIME(3043280,python3):2026-08-26-17:52:27.047.381 [stars_engine.cc:1619]3045153 ProcLogicCqReport:Task run failed, device_id=12, stream_id=47, task_id=13487, sqe_type=7(notify wait), errType=0x20(sq sw status error), sqSwStatus=0x102d0559 [ERROR] RUNTIME(3043280,python3):2026-08-26-17:52:27.051.967 [device_error_core_proc.cc:1108]3045153 AddExceptionRegInfo:add error register: core_id=11, stream_id=9, task_id=1369 [ERROR] RUNTIME(3043280,python3):2026-08-26-17:52:27.051.980 [device_error_core_proc.cc:1198]3045153 PrintCoreInfo:An error occurs on the device(chipId:6, dieId:0), the serial number is 14, the error is fftsplus aivector error, core id is 11, error code = 0x800000, dump info: pc start: 0x125801dcbf14, current: 0x125801dbce18, vec error info: 0xd31d5eefbd, mte error info: 0xf306000080, ifu error info: 0x79c5ef6198880, ccu error info: 0x241cd0879800080, cube error info: 0, biu error info: 0, aic error mask: 0x6500020bd00028c, para base: 0x12c1415a6080, aic cond: 0. The extend info: errcode:(0x800000, 0x4000, 0) errorStr: MTE accesses an invalid GM address or the cross-device memory access times out.The GM address accessed by scalar exceeds 48 bits. fixp_error0 info: 0x6000080, fixp_error1 info: 0xf3, fsmId:0, tslot:1, thread:0, ctxid:0, blk:6, sublk:1, subErrType:4. For details, see the troubleshooting document on the Ascend official website. Search for the keyword "AI Core Error". 4 ## 1. 现象 **首错(PyPTO AICore)** text kernel_name=PyPTO_mla_prolog_v4_0 MTE error: The GM address accessed by scalar exceeds 48 bits AICore 已执行 kernel,MTE 读到非法 GM 地址;不是算子精度问题,也不是 sche under-enqueue hang 的直接后果。 **复现条件**:capture replay / early launch、ctrl-flow cache hit、**多轮 pipeline 深度 ≥ ring 容量(4)** 后复用同一 slot。 --- ## 2. 根因 ### 2.1 RuntimeDataRingBuffer 与 cache 按 slot 隔离 DEFAULT_RUNTIME_DATA_RING_BUFFER_COUNT = 4。每轮 InitDyn: - AllocatePrepare / AllocateSubmit 占用 ring 中一个 **DevStartArgs slot**(index % 4)。 - ctrl-flow cache 按 **同一 slot 下标** 分片,而非全局共享一份: cpp // device_ctrl.h InitDyn ctrlFlowCache = base + usedCacheSize * ringBufferHead->GetIndexPendingIndex(); // GetIndexPendingIndex() == indexPending % 4 因此 **前 4 轮**(sequence 1–4)各用 slot 0/1/2/3,各自 IncastOutcastAddrRestore 写各自 cache 里的 rawTensorAddr,**相邻轮次之间不因 restore 互相覆盖**。 ### 2.2 重叠只发生在 ring 绕回同 slot 第 **5** 轮起复用 slot 0(与第 1 轮同槽),第 6 轮复用 slot 1(与第 2 轮同槽),以此类推。 early launch 跳过 RunPreSync,允许最多 **4 路** ctrl/sche/aicore pipeline 同时进行。若第 1 轮对应 slot 0 的 **AICore 仍在跑**(读该 slot cache 里的 rawTensorAddr),第 5 轮 ctrl 已对 **同一 slot 0** 执行 IncastOutcastAddrRestore → **同 slot 读写竞态** → 48bit MTE。 slot 释放(Deallocate)发生在 **sche 全部退出** 时,**不保证** AICore 已结束,故「sche 已释放 slot、AICore 仍存活」是竞态窗口。 ### 2.3 restore 改写内容与 AICore 读点 cache hit 时 InitCtrlFlowCache 对该 **slot** 的 cache 执行: text IncastOutcastAddrRestore() → DevMemcpyS 覆盖该 slot 的 live rawTensorAddr TaskAddrRestoreWorkspace() → 恢复 workspace 描述 RuntimeAddrRelocWorkspace() → reloc 该 slot freelist BlockHeader.ptr AICore kernel 通过 GM 读 func->rawTensorAddr[...](incast/outcast 地址表)。 ### 2.4 freelist reloc 缺失(master 已修) 同 slot restore 路径上,若 live BlockHeader.ptr 未 reloc 成 workspace 绝对地址,会返回 offset 当 GM(MR !5579)。与 slot 绕回复用时的并发 restore 同属 cache restore 类 GM 错误。 ### 2.5 因果链 text early launch → 最多 4 路 pipeline,跳过 RunPreSync → 第 5 轮复用 ring slot 0(与第 1 轮同槽) → 第 1 轮 AICore 仍读 slot 0 的 rawTensorAddr → 第 5 轮 ctrl InitDyn 对该 slot restore/reloc → MTE: "address exceeds 48 bits" 与 ctrl/sche under-enqueue hang **无关**。 ### 2.6 故障时序(slot 绕回) mermaid sequenceDiagram participant R1 as Round 1 (slot 0) participant R5 as Round 5 (slot 0) participant AIC as AICore (R1) Note over R1: sequence=1,cache slot 0 R1->>AIC: dispatch,读 slot0 rawTensorAddr Note over R5: sequence=5,复用 slot 0<br/>early,无 RunPreSync R5->>R5: InitDyn → IncastOutcastAddrRestore(slot0) Note over AIC: 仍读 slot0 旧表 AIC->>AIC: MTE 48bit GM error --- ### 3.1 本 PR:按算子隔离的 ping-pong event sync Device ring 仍是每算子 4 slot;host 侧**不**用 4 个全局 event 对齐 slot 下标,改为: - **每个 KernelBinary 独立** 2 个 ACL event(ping / pong)+ 独立 ringSequence_ - 同一算子最多 **2 路** early-launch 重叠;第 N 次 ctrl 启动前等第 N-2 次 aicore 结束 - 比 4-slot 绕回更保守,因此 slot 复用时上一轮 aicore 一定已退出 - globalRound 仍用进程级计数,只打日志,**不参与**同步 | 时机 | 行为 | |------|------| | 该算子 ringSequence ≤ 2 | 不 wait | | ringSequence > 2,ctrl 启动前 | wait 该算子 event [(N-3)%2],即上一拍 ping/pong 在 **本算子** aicore stream 上的完成 | | aicore launch 后 | record 该算子 event [(N-1)%2] | 启用条件(同时满足): - launch_early_mode != 2 - host ctrl-flow cache 已生效(FindOrBuildDevCache 得到非空 cache,含首次 Build) - 未设 PYPTO_LAUNCH_RING_EVENT_SYNC=false - 非 aicore-resolve 多算子整网:MLA / 其它 PyPTO 算子各自一份 ping-pong,互不踩 event、互不混计数。 ### 3.2 算子流时序(profiling 视图) 横向为时间。sche AICPU 负责 dispatch,与 aicore stream 上 PyPTO_mla_prolog_v4 **同段重叠**。ctrl stream 单独一行,early launch 下可 **领先** sche/aicore。 **修复前(early launch,无 ring event)— seq5 绕回 slot0 与 seq1 算子尾段重叠** text 时间 ──────────────────────────────────────────────────────────────────────────────► ctrl stream │[R1 Init │[R2 Init │[R3 Init │[R4 Init │[R5 Init restore slot0] (AICPU ctrl) │ restore s0]│ restore s1]│ restore s2]│ restore s3]│ ▲ 改写 s0 rawTensorAddr │ │ │ │ │ │ │ │ │ │ ┌─ 重叠 ─┐ stream 9 │[ sche ──── PyPTO_mla_prolog_v4 (seq1 · slot0) ────────────────►│ (sche≈aicore) │ dispatch ═══════════════════════════════════════════════════ │ │ │ │[sche──PyPTO (s1)──]│ │ │ │ │ │ │ │[sche─PyPTO(s2)─]│ │ │ │ │ │ │ │[sche PyPTO(s3)]│ │ │ │ │ │ │ │ └─┘ │ ring slot │ slot0 │ slot1 │ slot2 │ slot3 │ slot0 reuse 要点:seq1–4 **错开 slot**,restore 互不踩;seq5 ctrl restore 落在 seq1 算子流 **尚未结束** 的 tail 上。 **修复后(每算子 ping-pong)— 第 3 次 ctrl 先等第 1 次 aicore 结束** text 时间 ──────────────────────────────────────────────────────────────────────────────► ctrl stream │[R1 Init s0]│[R2 Init s1]│ wait evt0 │[R3 Init s2]│ wait evt1 │[R4 …] │ │ │ ◄─sync──►│ │ stream 9 │[ PyPTO seq1/slot0 ────]│ rec evt0 │ │ (本算子 aicore)│ │[seq2/s1 ──]│ rec evt1 │[seq3/s2──► │ ping-pong │ seq≤2:不 wait │ evt0=seq1 │ │ evt1=seq2 第 5 次复用 slot0 时,已经过「seq3 wait seq1」「seq5 wait seq3」,seq1 aicore 必已结束。  See merge request: cann/pypto!5516 | 3 months ago | |
fix(machine): Add ring event sync for early launch slot reuse Co-authored-by: LordOfMysteries<duhongxiang@huawei.com> # message auto-generated for no-merge-commit merge: !5516 merge fix-ctrl-wait-sche-num into master fix(machine): Add ring event sync for early launch slot reuse Created-by: LordOfMysteries Commit-by: LordOfMysteries Merged-by: cann-robot Description: https://gitcode.com/cann/pypto/issues/3133 目前整网遇到个问题,mla这个算子(非值依赖,会走host cache完成stitch,每次上板只做restore和task下发)本地单跑ok,但是接入整网跑推理有问题,首先是pypto的aicore部分报scalar访问地址超过48bit。接入整网的模型大概是:图中mla算子每一次decode会穿插跑很多次(多层),每一次decode开头会有一些并发stream上的其它aicpu算子抢核,与这个并列的pypto sche cpu可能抢占不到同一个cluster的核,从开日志看确实有ArbitrationLevel从几次5后面全变成4的情况。然后整网hccl是通过aiv展开的,不存在抢aicpu核 现在实验了多种场景:(1)launch_sched_aicpu_num默认值或者设为2,整网都有上述问题,只有设为1才好(2)开了info日志就不复现了(3)launch_early_mode设为2,关闭提前发射后也不复现(4)怀疑ctrl下一轮的restore过程可能与sche上一轮的执行重叠,导致公用元数据被篡改。 [ERROR] RUNTIME(3043280,python3):2026-08-26-17:52:27.047.381 [stars_engine.cc:1619]3045153 ProcLogicCqReport:Task run failed, device_id=12, stream_id=47, task_id=13487, sqe_type=7(notify wait), errType=0x20(sq sw status error), sqSwStatus=0x102d0559 [ERROR] RUNTIME(3043280,python3):2026-08-26-17:52:27.051.967 [device_error_core_proc.cc:1108]3045153 AddExceptionRegInfo:add error register: core_id=11, stream_id=9, task_id=1369 [ERROR] RUNTIME(3043280,python3):2026-08-26-17:52:27.051.980 [device_error_core_proc.cc:1198]3045153 PrintCoreInfo:An error occurs on the device(chipId:6, dieId:0), the serial number is 14, the error is fftsplus aivector error, core id is 11, error code = 0x800000, dump info: pc start: 0x125801dcbf14, current: 0x125801dbce18, vec error info: 0xd31d5eefbd, mte error info: 0xf306000080, ifu error info: 0x79c5ef6198880, ccu error info: 0x241cd0879800080, cube error info: 0, biu error info: 0, aic error mask: 0x6500020bd00028c, para base: 0x12c1415a6080, aic cond: 0. The extend info: errcode:(0x800000, 0x4000, 0) errorStr: MTE accesses an invalid GM address or the cross-device memory access times out.The GM address accessed by scalar exceeds 48 bits. fixp_error0 info: 0x6000080, fixp_error1 info: 0xf3, fsmId:0, tslot:1, thread:0, ctxid:0, blk:6, sublk:1, subErrType:4. For details, see the troubleshooting document on the Ascend official website. Search for the keyword "AI Core Error". 4 ## 1. 现象 **首错(PyPTO AICore)** text kernel_name=PyPTO_mla_prolog_v4_0 MTE error: The GM address accessed by scalar exceeds 48 bits AICore 已执行 kernel,MTE 读到非法 GM 地址;不是算子精度问题,也不是 sche under-enqueue hang 的直接后果。 **复现条件**:capture replay / early launch、ctrl-flow cache hit、**多轮 pipeline 深度 ≥ ring 容量(4)** 后复用同一 slot。 --- ## 2. 根因 ### 2.1 RuntimeDataRingBuffer 与 cache 按 slot 隔离 DEFAULT_RUNTIME_DATA_RING_BUFFER_COUNT = 4。每轮 InitDyn: - AllocatePrepare / AllocateSubmit 占用 ring 中一个 **DevStartArgs slot**(index % 4)。 - ctrl-flow cache 按 **同一 slot 下标** 分片,而非全局共享一份: cpp // device_ctrl.h InitDyn ctrlFlowCache = base + usedCacheSize * ringBufferHead->GetIndexPendingIndex(); // GetIndexPendingIndex() == indexPending % 4 因此 **前 4 轮**(sequence 1–4)各用 slot 0/1/2/3,各自 IncastOutcastAddrRestore 写各自 cache 里的 rawTensorAddr,**相邻轮次之间不因 restore 互相覆盖**。 ### 2.2 重叠只发生在 ring 绕回同 slot 第 **5** 轮起复用 slot 0(与第 1 轮同槽),第 6 轮复用 slot 1(与第 2 轮同槽),以此类推。 early launch 跳过 RunPreSync,允许最多 **4 路** ctrl/sche/aicore pipeline 同时进行。若第 1 轮对应 slot 0 的 **AICore 仍在跑**(读该 slot cache 里的 rawTensorAddr),第 5 轮 ctrl 已对 **同一 slot 0** 执行 IncastOutcastAddrRestore → **同 slot 读写竞态** → 48bit MTE。 slot 释放(Deallocate)发生在 **sche 全部退出** 时,**不保证** AICore 已结束,故「sche 已释放 slot、AICore 仍存活」是竞态窗口。 ### 2.3 restore 改写内容与 AICore 读点 cache hit 时 InitCtrlFlowCache 对该 **slot** 的 cache 执行: text IncastOutcastAddrRestore() → DevMemcpyS 覆盖该 slot 的 live rawTensorAddr TaskAddrRestoreWorkspace() → 恢复 workspace 描述 RuntimeAddrRelocWorkspace() → reloc 该 slot freelist BlockHeader.ptr AICore kernel 通过 GM 读 func->rawTensorAddr[...](incast/outcast 地址表)。 ### 2.4 freelist reloc 缺失(master 已修) 同 slot restore 路径上,若 live BlockHeader.ptr 未 reloc 成 workspace 绝对地址,会返回 offset 当 GM(MR !5579)。与 slot 绕回复用时的并发 restore 同属 cache restore 类 GM 错误。 ### 2.5 因果链 text early launch → 最多 4 路 pipeline,跳过 RunPreSync → 第 5 轮复用 ring slot 0(与第 1 轮同槽) → 第 1 轮 AICore 仍读 slot 0 的 rawTensorAddr → 第 5 轮 ctrl InitDyn 对该 slot restore/reloc → MTE: "address exceeds 48 bits" 与 ctrl/sche under-enqueue hang **无关**。 ### 2.6 故障时序(slot 绕回) mermaid sequenceDiagram participant R1 as Round 1 (slot 0) participant R5 as Round 5 (slot 0) participant AIC as AICore (R1) Note over R1: sequence=1,cache slot 0 R1->>AIC: dispatch,读 slot0 rawTensorAddr Note over R5: sequence=5,复用 slot 0<br/>early,无 RunPreSync R5->>R5: InitDyn → IncastOutcastAddrRestore(slot0) Note over AIC: 仍读 slot0 旧表 AIC->>AIC: MTE 48bit GM error --- ### 3.1 本 PR:按算子隔离的 ping-pong event sync Device ring 仍是每算子 4 slot;host 侧**不**用 4 个全局 event 对齐 slot 下标,改为: - **每个 KernelBinary 独立** 2 个 ACL event(ping / pong)+ 独立 ringSequence_ - 同一算子最多 **2 路** early-launch 重叠;第 N 次 ctrl 启动前等第 N-2 次 aicore 结束 - 比 4-slot 绕回更保守,因此 slot 复用时上一轮 aicore 一定已退出 - globalRound 仍用进程级计数,只打日志,**不参与**同步 | 时机 | 行为 | |------|------| | 该算子 ringSequence ≤ 2 | 不 wait | | ringSequence > 2,ctrl 启动前 | wait 该算子 event [(N-3)%2],即上一拍 ping/pong 在 **本算子** aicore stream 上的完成 | | aicore launch 后 | record 该算子 event [(N-1)%2] | 启用条件(同时满足): - launch_early_mode != 2 - host ctrl-flow cache 已生效(FindOrBuildDevCache 得到非空 cache,含首次 Build) - 未设 PYPTO_LAUNCH_RING_EVENT_SYNC=false - 非 aicore-resolve 多算子整网:MLA / 其它 PyPTO 算子各自一份 ping-pong,互不踩 event、互不混计数。 ### 3.2 算子流时序(profiling 视图) 横向为时间。sche AICPU 负责 dispatch,与 aicore stream 上 PyPTO_mla_prolog_v4 **同段重叠**。ctrl stream 单独一行,early launch 下可 **领先** sche/aicore。 **修复前(early launch,无 ring event)— seq5 绕回 slot0 与 seq1 算子尾段重叠** text 时间 ──────────────────────────────────────────────────────────────────────────────► ctrl stream │[R1 Init │[R2 Init │[R3 Init │[R4 Init │[R5 Init restore slot0] (AICPU ctrl) │ restore s0]│ restore s1]│ restore s2]│ restore s3]│ ▲ 改写 s0 rawTensorAddr │ │ │ │ │ │ │ │ │ │ ┌─ 重叠 ─┐ stream 9 │[ sche ──── PyPTO_mla_prolog_v4 (seq1 · slot0) ────────────────►│ (sche≈aicore) │ dispatch ═══════════════════════════════════════════════════ │ │ │ │[sche──PyPTO (s1)──]│ │ │ │ │ │ │ │[sche─PyPTO(s2)─]│ │ │ │ │ │ │ │[sche PyPTO(s3)]│ │ │ │ │ │ │ │ └─┘ │ ring slot │ slot0 │ slot1 │ slot2 │ slot3 │ slot0 reuse 要点:seq1–4 **错开 slot**,restore 互不踩;seq5 ctrl restore 落在 seq1 算子流 **尚未结束** 的 tail 上。 **修复后(每算子 ping-pong)— 第 3 次 ctrl 先等第 1 次 aicore 结束** text 时间 ──────────────────────────────────────────────────────────────────────────────► ctrl stream │[R1 Init s0]│[R2 Init s1]│ wait evt0 │[R3 Init s2]│ wait evt1 │[R4 …] │ │ │ ◄─sync──►│ │ stream 9 │[ PyPTO seq1/slot0 ────]│ rec evt0 │ │ (本算子 aicore)│ │[seq2/s1 ──]│ rec evt1 │[seq3/s2──► │ ping-pong │ seq≤2:不 wait │ evt0=seq1 │ │ evt1=seq2 第 5 次复用 slot0 时,已经过「seq3 wait seq1」「seq5 wait seq3」,seq1 aicore 必已结束。  See merge request: cann/pypto!5516 | 3 months ago | |
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 months ago | |
feat(machine): Change aicpu kernel launch method Co-authored-by: wan_jianfen<wanjianfen@hisilicon.com> # message auto-generated for no-merge-commit merge: !5045 merge br_aicpuKernelLaunch into master feat(machine): Change aicpu kernel launch method Created-by: wan_jianfen Commit-by: wan_jianfen Merged-by: cann-robot Description: 改变kernel_launch 接口,更换成acl 接口 See merge request: cann/pypto!5045 | 3 months ago | |
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 months ago | |
refactor(machine): Reduce private variable of DeviceRunner and decouple runtime agent Co-authored-by: arthur_morgan_hw<lipeijie@huawei.com> # message auto-generated for no-merge-commit merge: !3342 merge br_machine into master refactor(machine): Reduce private variable of DeviceRunner and decouple runtime agent Created-by: arthur_morgan_hw Commit-by: arthur_morgan_hw Merged-by: cann-robot Description: 1、内存相关的操作从runtime agent中抽离出去,只保留对寄存器信息的获取 2、梳理device runner的代码,减少非必要的成员变量 See merge request: cann/pypto!3342 | 6 months ago | |
feat(machine): Change aicpu kernel launch method Co-authored-by: wan_jianfen<wanjianfen@hisilicon.com> # message auto-generated for no-merge-commit merge: !5045 merge br_aicpuKernelLaunch into master feat(machine): Change aicpu kernel launch method Created-by: wan_jianfen Commit-by: wan_jianfen Merged-by: cann-robot Description: 改变kernel_launch 接口,更换成acl 接口 See merge request: cann/pypto!5045 | 3 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 | |
fix(machine): Fix dump perf data under multi-round by another way Co-authored-by: arthur_morgan_hw<lipeijie@huawei.com> # message auto-generated for no-merge-commit merge: !3917 merge br_runtime into master fix(machine): Fix dump perf data under multi-round by another way Created-by: arthur_morgan_hw Commit-by: arthur_morgan_hw Merged-by: cann-robot Description: 1. 原本这个问题,在跑多轮情况下,只有第一轮dump的原因是只有第一轮从C侧获取的runtime_debug_mode是1,后续多轮获取的都是0,导致只有第一轮会同步数据,后续不会同步数据。 2. 之前修复方式是还原之前的代码逻辑,即从py侧触发的kernel launch每次都强制去同步数据。 3. 现在进一步定位发现,py侧的options同步给C侧只有在触发编译的时候才会做,多轮的情况下,只有第一轮才会触发编译,后续多轮复用第一次的编译结果。因此修复方案即为同步options给C侧的调用,每次都会调用,而不是只在编译的时候才调用。 See merge request: cann/pypto!3917 | 5 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 | |
fix(machine): Fix missing unit issue. Co-authored-by: chai-hw<chaizhengtong@huawei.com> # message auto-generated for no-merge-commit merge: !5489 merge machine_format into master fix(machine): Fix missing unit issue. Created-by: chai-hw Commit-by: chai-hw Merged-by: cann-robot Description: 修复日志中单位的缺失,使日志信息更便于阅读 See merge request: cann/pypto!5489 | 3 months ago |
| Files | Last commit | Last update |
|---|---|---|
| 3 months ago | ||
| 3 months ago | ||
| 3 months ago | ||
| 3 months ago | ||
| 3 months ago | ||
| 5 months ago | ||
| 3 months ago | ||
| 4 months ago | ||
| 3 months ago | ||
| 3 months ago | ||
| 3 months ago | ||
| 5 months ago | ||
| 3 months ago | ||
| 3 months ago | ||
| 3 months ago | ||
| 3 months ago | ||
| 3 months ago | ||
| 3 months ago | ||
| 3 months ago | ||
| 6 months ago | ||
| 3 months ago | ||
| 4 months ago | ||
| 5 months ago | ||
| 4 months ago | ||
| 3 months ago |