| Files | Last commit | Last update |
|---|---|---|
feat(machine): Support BN parallel for DRCO Co-authored-by: gaoxingwang<camuel.gao@huawei.com> # message auto-generated for no-merge-commit merge: !7246 merge drco-bn-parallel-final into master feat(machine): Support BN parallel for DRCO Created-by: gaoxingwang Commit-by: gaoxingwang Merged-by: cann-robot Description: feat(machine): Support BN parallel for DRCO Add a device-side parallel window for DRCO devTask execution under BN parallel mode (device_sched_parallelism > 1) on 2201: block0 acts as the single admission/handover/recycle/stop leader while all cores visit slots in try-mode rotation, replacing the legacy SyncAllMix barrier per devTask. Squashed from the window feature, its cross-core visibility fixes, the minimal atomic protocol reduction, and two late hardening changes (per-slot activation now issues the ENTIRE_DATA_CACHE invalidation before loading queue/matrix read sets; ready-queue entries are published via atomic release stores ahead of the tail gateway). BN parallel mode and DRCO L2-affinity scheduling are temporarily made mutually exclusive (BN wins): enabling both together exposes a stale-data window between the L2 affinity dispatch order and the BN window admit/handover protocol. Proper fusion is left for a follow-up. Changes: - Add DrcoParallelWindow slot ring, per-slot activation/visit/exit protocol and leader poll loop - Encode stop as cross-launch epoch with entry barrier clear for non-block0 cores - Guard stale slot activation with posId validation and invalidate freed slots on idle - Reset window cursors and BN link fields deterministically across launches and replays - Publish ready-queue entries (func/root/forId/wsId) with atomic release stores - Move UpdateCacheDevTask entire-cache dcci ahead of activation read-set loads - Force DRCO_FLAG_L2_CLOSE=0 when ENABLE_AICORE_BN_PARALLEL=1 (temporary mutex) Related Issues: #7147 See merge request: cann/pypto!7246 | 30 days ago | |
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 | 23 days ago | |
fix(machine): Add value depend check for ifstmt Co-authored-by: qq_52905393<liuzhen180@huawei.com> # message auto-generated for no-merge-commit merge: !7361 merge dev-fix-host-ctrl into master fix(machine): Add value depend check for ifstmt Created-by: qq_52905393 Commit-by: qq_52905393 Merged-by: cann-robot Description: 检测值依赖和 insert wait_aicore_start 的时候,增加 ifstmt 的检测 See merge request: cann/pypto!7361 | 24 days ago | |
fix(runtime): dump tensors for extended AICore launch arguments Co-authored-by: hubowen<hubowen17@huawei.com> # message auto-generated for no-merge-commit merge: !7311 merge fix/aicerr_noinput into master fix(runtime): dump tensors for extended AICore launch arguments Created-by: W4termy Commit-by: hubowen Merged-by: cann-robot Description: kernel启动参数扩展,argsize将会大于56,而异常dump严格校验argsize=56导致dump流程被跳过 See merge request: cann/pypto!7311 | 24 days ago | |
Normalized framework for pgo Co-authored-by: LordOfMysteries<duhongxiang@huawei.com> Co-authored-by: Jie Yin<yinjie27@huawei.com> # message auto-generated for no-merge-commit merge: !7044 merge pgo-framework into master Normalized framework for pgo Created-by: yinjie27_ Commit-by: Jie Yin;LordOfMysteries Merged-by: cann-robot Description: # feat(machine): 重构 FedProf 为 Holder/Manager 实例化结构,并修复 CTRL 泳道只 dump 一轮的回归 ## 一、背景与问题 fed_prof(device 侧性能数据 dump)原实现是一个单例 FedProf:内部直接持有 perCoreProf_ / aicpuProf_ 两个裸 device 指针,dump 线程、轮次管理、JSON 序列化 全部堆在同一个类里;DeviceArgs 里也以 perCoreProfAddr / aicpuProfAddr 两个散落字段 传地址。新增一类 profile 需要同时改结构体、改分配逻辑、改 dump 分支,扩展成本高。 同时暴露出一个回归:DUMP_DEVICE_PERF=true 时 python/tests/st/test_ctrl_cpu_perf.py 断言 len(metrics) >= 30 失败,实际只解析出 **1 轮** CTRL 数据: AssertionError: expected >= 30 CTRL rounds, got 1 ... assert 1 >= 30 **根因链**: 1. DUMP_DEVICE_PERF=true ⇒ KernelBinary::GetEnableDumpDevPref() 恒为真, 于是**每次** LaunchKernel 都会走到 DeviceLauncher::SetDevPerfAddr()(device_launcher.cpp:658)→ FedProfManager::SetDebugEnable(); 2. SetDebugEnable() 每次都对**所有 core** 全量 memset per-core prof 元数据 (PerCoreProfResetMetadata()),把 device 侧 status.currLaunchRound 清零; 3. 而 currLaunchRound 只在 AICore 退出时 ++(aicore_entry_dfx.h:174), 因此连续 30 次 launch 后它仍然只有 **1**; 4. AicpuProfDumpSwimlaneCheck() 以 currLaunchRound 作为 dump 轮次上界 (fed_prof_manager_aicpu.cpp:101),FedProfLaunchAicpuDumpJson() 只遍历 [lastDumpRound, currLaunchRound)(fed_prof_io_json.cpp:181), 最终 dump 里只剩 round _0。 ## 二、改动总览 共 4 个提交,34 个文件。 ### 1. 数据结构:用 FedProfKind + 地址列表替代散落字段 framework/src/interface/machine/device/tilefwk/aikernel_profile.h - 新增 enum FedProfKind { FED_PROF_PER_CORE_PROF, FED_PROF_AICPU_PROF, FED_PROF_KIND_MAX } 与 struct FedProfDataBase {} 作为类型化基类; - FedProfPerCoreProf / FedProfAicpuProf 改为继承 FedProfDataBase。 framework/src/interface/machine/device/tilefwk/aicpu_common.h - DeviceArgs 中 perCoreProfAddr / aicpuProfAddr 两个字段合并为 uint64_t fedProfAddrList[FED_PROF_KIND_MAX]{},按 FedProfKind 索引。 ### 2. Host 侧:把单例拆成 Holder(数据面)+ Manager(控制面) - fed_prof.h / fed_prof.cpp → **删除**,拆为: - fed_prof_holder.h / fed_prof_holder.cpp:FedProfHolderBase 虚基类 + 模板 FedProfHolder<kind> + FedProfPerCoreProfHolder / FedProfAicpuProfHolder。 device buffer 的分配(DeviceDataAllocate)、清理(DeviceDataClear)、 D2H 搬运(DeviceDataGet<T>)、JSON 序列化(DumpJson<T> / DumpJsonAicpuProf) 全部收敛为按类型实现的虚接口;编排逻辑不再感知具体 profile 类型。 - fed_prof_manager.h / fed_prof_manager.cpp:FedProfManager 单例,负责 dump 线程生命周期、轮次判定(AicpuProfDumpSwimlaneCheck)、dump 编排与落盘。 - fed_prof_aicpu_prof.cpp → fed_prof_manager_aicpu.cpp。 - FedProfManager 内部用 std::unique_ptr<FedProfHolderBase> profList_[FED_PROF_KIND_MAX] 取代原来的两个具名成员,对外统一为 DeviceDataAllocate(FedProfKind), 新增 profile 类型只需在枚举和 profList_ 中登记一处。 - DeviceDfx::Init() 改为按 kind 遍历分配,并在拿到 devDfxArgAddr 后再次 InitDeviceArgs() 刷新 args_(device_dfx.cpp:57-70)。 - 顶层 CMakeLists.txt 的安装头文件清单同步更新(fed_prof.h → fed_prof_manager.h + fed_prof_holder.h)。 ### 3. Device 侧与调用方:地址来源统一切到 fedProfAddrList aicore_entry.h、aicore_entry_drco.h、device_sche.cpp、aicore_hal.h、 aicpu_task_manager.h、aicore_model_launcher.cpp、emulation_launcher.cpp、 kernel_binary.{h,cpp}、device_launcher.{h,cpp}、device_dfx.cpp、 framework/tests/st/utils/include/test_dev_func_runner.h - devArgs->perCoreProfAddr → devArgs->fedProfAddrList[FED_PROF_PER_CORE_PROF]; - devArgs->aicpuProfAddr → devArgs->fedProfAddrList[FED_PROF_AICPU_PROF]; - KernelBinary::InitMetaData() / GetEnableDumpDevPref() 改为按 kind 循环拷贝 / 判空。 ### 4. 关键缺陷修复:per-core 元数据不再被每轮清零 framework/src/machine/runtime/runner/fed_prof_manager.{h,cpp} - void PerCoreProfResetMetadata(const uint32_t coreId); + void PerCoreProfResetMetadata(bool multipleLaunch); - 外层 per-core 循环内移,函数自身负责 reset **全部** core; - 新增成员 bool perCoreProfDataInited_{false},在 multipleLaunch 下每个 core 只 reset 一次(恢复重构前的保护); - SetDebugEnable() 不再自己写循环,改为 PerCoreProfResetMetadata(AicpuProfDevAddr() != 0)——即 aicpu prof 使能 (DUMP_DEVICE_PERF=true)时传 true,否则传 false,保持「每次 launch 全量 reset」的原有语义。 修复后 status.currLaunchRound 随 launch 累加,dump 可覆盖全部 30 轮。 ### 5. 其它 - aikernel_define.h:UNUSED 由单参宏扩展为 1~16 变参宏 (UNUSED_SELECT 参数选择),满足 UNUSED(a, b, ...) 用法; 同时删除 framework/include/tilefwk/data_type.h 中重复的 UNUSED 定义。 - 626560468:析构时显式 AicpuProfReleaseData()(dump 线程 stop 之后), 修正 online 场景的资源释放顺序。 ### 6. UT 适配 test_device_perf.cpp(6 处调用点改 bool 实参,ResetMetadata_IndexOutOfRange 重命名为 ResetMetadata_MultipleLaunch)、test_dynamic_runner.cpp、 test_device_dfx.cpp、test_device_launcher_host/npu.cpp、 test_device_runner.cpp、test_dump_device_perf.cpp 等跟随接口调整。 ## 三、行为对比 | 场景 | 修复前 | 修复后 | |---|---|---| | DUMP_DEVICE_PERF=true(aicpu prof 使能)30 次 launch | 每次 launch 清零 currLaunchRound,dump 只含 1 轮 | 每 core 仅首次 reset,currLaunchRound 累加,dump 覆盖 30 轮 | | 仅 runtime debug / host prof(无 aicpu prof) | 每次 SetDebugEnable 全量 reset | 语义不变(multipleLaunch=false,仍每次全量 reset) | | 新增一类 profile | 需改结构体字段 + FedProf 成员 + dump 分支 | 加 FedProfKind 枚举项 + 一个 Holder 子类即可 | ## 四、验证 - **UT**(tile_fwk_utest,machine 模块,本机设备 0): 受影响的 14 个套件共 **43 例通过**,其中直接覆盖改动的 DevicePerfTest.*(含新增 ResetMetadata_MultipleLaunch)10/10 PASS, TestDeviceRunner.DevicePerf_SetDebugEnable、DeviceLauncherNpuTest.SetDevPerfAddr_*、 DumpDevicePerfTest.*、PerfEvtMgrTest.* / PerfettoMgrTest.* 等均 PASS。 另有 2 例(SetDevPerfAddr_CaptureMode、MiscNoOpFunctions_NoCrash)因本机 UT 运行环境未部署 libtilefwk_backend_server.so / pypto_op_info.json 而失败, 已确认抛错点在 SetDebugEnable 之前的条件求值阶段,与本次改动无关。 - **构建**:tile_fwk_runtime、tile_fwk_interface、tile_fwk_utest 编译通过。 - **待上板回归**:python/tests/st/test_ctrl_cpu_perf.py —— 期望 len(metrics) >= 30(本 PR 修复的目标用例);同时观察 mean/max EXEC_DYN、first DEV_TASK_BUILD 门限是否满足(该用例阈值按 ctrl cpu 效率标定,若仍有回退需单独定位)。 ## 五、影响面与风险 - **接口变更**:DeviceArgs.perCoreProfAddr / aicpuProfAddr → fedProfAddrList[FED_PROF_KIND_MAX],host/device 两侧同步修改, 属不兼容变更;生成侧、模拟器(aicore_model_kernel_meta_hook.h)与 ST 基建已同步。 - **文件结构变更**:fed_prof.h/.cpp 被删除并由 fed_prof_holder.* + fed_prof_manager.* 取代,需注意下游对旧头文件的直接 include(本仓已全部更新)。 - **风险点**:per-core 元数据 reset 时机的语义依赖 multipleLaunch 取值, 已在 UT 中分别覆盖 true / false 两条分支。 - **回滚**:本 PR 为独立重构 + 修复,回滚即回到 FedProf 单例实现。 See merge request: cann/pypto!7044 | 1 month ago | |
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 | 23 days ago | |
feat(machine): Optimize left pingpong Co-authored-by: LordOfMysteries<duhongxiang@huawei.com> # message auto-generated for no-merge-commit merge: !6866 merge fix-ctrlflow-pypto-page-align into master feat(machine): Optimize left pingpong Created-by: LordOfMysteries Commit-by: LordOfMysteries Merged-by: cann-robot Description: ## Summary 控制流 cache 重放头两处优化:Mix wrap 队列 ping-pong,以及 DRCO ready-queue shadow 与 metadata predcount ping-pong。 PushTask 前不再整段重建这两块。 ## 1. Mix wrap 队列 ping-pong ### 原来的缺点 readyWrapCoreFunctionQue 的 elem 会被调度改掉。旧路径在 PushTask 前 MixTaskDataRestore 整段 memcpy,串在所有核前面。opWrapList / wrapIdNum 录制后只读,却和队列元素捆在同一次恢复里。 ### 现在的做法 录制 MixTaskDataBackup 留下: | 字段 | 含义 | |---|---| | queue.elem | 不可变快照,只作 restore 源 | | queue.head/tail/capacity | 录制时刻游标 | | pingElem / pongElem | 两块工作缓冲;pong OOM 时回退 in-place memcpy | | opWrapList / wrapIdNum | backup 写一次;Swap 时仍写回 live(sche 依赖) | 重放: 1. **头**(须在 ReadyQueue swap **之前**):MixTaskDataPingPongSwap。回退路径 DrcoReadyQueueDataRestore 会读 wrap 队列,必须先干净。 2. **退出** MixTaskDataPingPongRestore:把快照 memcpy 进当前未挂载的那一块。 旧 API MixTaskDataRestore 已删除。 ## 2. DRCO 重放 ping-pong ### 原来的缺点 enableAicoreResolve 时,每次重放都在 PushTask 前做两件事:DrcoPredCountDataRestore 重填 metadata predcount,以及 DrcoReadyQueueDataRestore + DrcoRootFuncListRestorePrecount 按 ready queue 重新铺 per-core pending / local ready。Die ready queue 的 swap 还会再往 per-core 队列灌一次。 ### 现在的做法 录制结束 BackupDrcoReplayShadow 为下列结构各留 canon(不可变快照)、ping(录制时的 live)、pong(第二份工作副本): - per-core pending - local ready queue / local ready matrix - stitch node matrix / hub task matrix metadata predcount 另留 drcoPredCountImage,以及 ping/pong 两个 offset;选中的 offset 写在 funcDynamicDataOffset 低 32 位。 重放: 1. **头** DrcoPredCountPingPongSwap:把 funcDynamicDataOffset 切到另一块 predcount。 2. **头** ReadyQueueDataPingPongSwap:shadow 已就绪(drcoShadowReady)时改走 DrcoShadowPingPongSwap,只交换指针并 RestorePrecount。shadow 未就绪(backup OOM)时仍回退 DrcoReadyQueueDataRestore。 3. Die ready queue 只交换自己的 elem,不再向 per-core 队列重灌;那份镜像由 DRCO shadow swap 负责。 4. **退出** DrcoShadowPingPongRestore / DrcoPredCountPingPongRestore:把 canon / image memcpy 进当前未挂载的那一块。 ## Ping-pong 的数据 录制发生在 PushTask 之前。此时 per-core pending 已经按 wrap、AIC、AIV 和 die 队列派发完;local ready、local matrix、stitch、hub 还是分配时的空表。影子把这个初态 memcpy 成 canon 和 pong,重放只换指针。launch 结束后把 canon 再 memcpy 进没挂上的那一块,下一轮换上来仍是初态。 和主线 DrcoReadyQueueDataRestore 的对应: | 数据 | 作用 | 主线重放 | 影子 | |---|---|---|---| | per-core pending | 每个核开跑时直接执行的初始 leaf 列表 | 先把 head/size 清 0,再按 wrap、AIC、AIV 重入队,die swap 再补 die 任务 | memcpy 录制时已经派发好的队列,换指针。内容与重入队相同,不再重灌 | | local ready queue | 矩阵放不下的后继就绪队列,AIC/AIV/MIX 各一组 | head/tail 置 0,任务区 memset 0 | 录制时空表,memcpy 后换指针,等价于清零 | | local ready matrix | 按消费者行投放刚解开的后继 | rowList memset 0 | 同上 | | stitch node matrix | 跨核帮忙展开的 stitch 槽,空槽为 0 | stitchNodeList memset 0 | 同上 | | hub task matrix | hub 溢出和类型越界的兜底任务槽,空槽为 0 | hubTaskList memset 0 | 同上 | | metadata predcount | AICore 使用的 int32 前驱计数 | 从 uint16 backup 逐项写回当前缓冲 | drcoPredCountImage 加一块 pong,切换 funcDynamicDataOffset。pong 没申请到时仍逐项写回 | | mix wrap elem | mix 任务的 AIC/AIV 包装,DrcoReadyQueueDataRestore 回退路径会读它 | 整段 memcpy 回 live elem | ping/pong 换指针;pong 申请失败时仍 memcpy | 不进影子、两边都直接写的字段: - readyMatrixPushCol:每轮写 0,后继行游标从 0 开始。 - staticExecCount 和完成 flag:DrcoRootFuncListRestorePrecount 写回录制时的预计数。 - shardExecCount:设备运行时的动态分片计数。主线每轮清 0;影子换指针不管这块,所以交换后同样清 0。 - devTaskFinished:每轮写 0。 没有做 ping-pong 的: - middleQueue:队列内容只读,设备不写回 GM,沿用 slab 镜像。 - bitmap:仍是原来的 BitmapDataRestoreTask,full cache 只恢复一次。 - AIC/AIV ready queue 和 die ready queue 的 elem ping-pong 是更早的改动,这次只让 die swap 在影子成功时不再往 per-core 重灌。 影子申请失败时 drcoShadowReady 保持 0,重放退回 DrcoReadyQueueDataRestore,die 任务仍按主线补进 pending。 ## 重放头顺序 text for each deviceTask: RelocIncastOutcastTask PredCountPingPongSwap [enableAicoreResolve] DrcoPredCountPingPongSwap [!fullCache || !bitmapRestoreDone] BitmapDataRestoreTask MixTaskDataPingPongSwap // before ReadyQueue ReadyQueueDataPingPongSwap // publishes DRCO shadow when ready DieReadyQueuePingPongSwap PushTask 优化前后头开销对比:  See merge request: cann/pypto!6866 | 1 month ago |
| Files | Last commit | Last update |
|---|---|---|
| 30 days ago | ||
| 23 days ago | ||
| 24 days ago | ||
| 24 days ago | ||
| 1 month ago | ||
| 23 days ago | ||
| 1 month ago |