| Files | Last commit | Last update |
|---|---|---|
perf(machine): Move task-level fields to DynFuncHeader and isolate debug-only code Co-authored-by: gaoxingwang<camuel.gao@huawei.com> # message auto-generated for no-merge-commit merge: !5588 merge perf/move-task-fields-to-dynfuncheader into master perf(machine): Move task-level fields to DynFuncHeader and isolate debug-only code Created-by: gaoxingwang Commit-by: gaoxingwang Merged-by: cann-robot Description: perf(machine): Move task-level fields to DynFuncHeader and isolate debug-only code ## 优化概述 将 task 级字段从 DynFuncData 移至 DynFuncHeader(每 task 一次赋值,而非每 func),缩小 per-func 结构体大小;隔离 debug-only 和 host-only 代码路径。 ## 优化点 ### 1. Task 级字段上移 - startArgs / stackWorkSpaceAddr / stackWorkSpaceSize 从 DynFuncData 移至 DynFuncHeader - FillOneDynFuncData 移除 startArgs / workspace 参数,在 BuildDynFuncData 中一次性赋值到 header - Reloc/backup/restore 在 header 层执行(每 task 一次,非每 func) ### 2. Debug-only 代码隔离 - CheckAddrAligned 和 leafFunc 统计包裹在 DEV_IF_DEBUG 中 - host-only 字段(exprNum / opAttrSize / rawTensorAddrSize / rawTensorDescSize)包裹在 DEV_IF_NONDEVICE 中 ### 3. 局部变量提取 - dupFunc.GetSource() 提取为局部变量 source(13 次调用 → 1 次) ### 4. CoreFuncParam 扩展 - funcHeader 指针加入 CoreFuncParam,供 AICORE kernel 直接访问 ### 5. 仿真器适配 - DynPvModelImpl::RunModel 构造 DynFuncHeader + DynFuncData 连续内存写入 GM,适配新的 kernel entry 签名 Changes: - Move startArgs/stackWorkSpaceAddr/stackWorkSpaceSize from DynFuncData to DynFuncHeader - Add funcHeader pointer to CoreFuncParam for AICORE kernel access - Update all consumers (aicore_entry, aicore_runtime, ctrlflow_cache, device_execute_context, PvModelImpl) to read from header - Wrap CheckAddrAligned and leafFunc stats in DEV_IF_DEBUG - Wrap host-only fields in DEV_IF_NONDEVICE - Extract dupFunc.GetSource() into local variable - Adapt DynPvModelImpl RunModel to construct DynFuncHeader for simulation Extracted from PR #5382 as independent commit, rebased onto latest master. Related Issues: #5382 See merge request: cann/pypto!5588 | 3 months ago | |
fix(machine): Fix in graph bug Co-authored-by: LordOfMysteries<duhongxiang@huawei.com> # message auto-generated for no-merge-commit merge: !6417 merge oom into master fix(machine): Fix in graph bug Created-by: LordOfMysteries Commit-by: LordOfMysteries Merged-by: cann-robot Description: https://gitcode.com/cann/pypto/issues/3381 ## 1. 停核代码风险 **原因**:同一颗 AICore 上一轮还没完全收干净,下一轮又上来了。原先停核时「清槽」和「发 GOODBYE」搅在一起,甚至 GOODBYE 之后又把握手缓冲清成 0,把下一轮刚写上的 HELLO 抹掉。 **改法**:固定顺序—— 1. 先让 STOP 被对面看见 2. 再清任务槽、清 HELLO 3. 再 barrier 4. 最后只发 GOODBYE 这样下一轮不会读到脏指针,也不会被误清握手标记。 --- ## 2. Ring sync 跨 eager / aclgraph 报错 **背景**:环形缓存槽复用时「ctrl 要等前几轮 aicore」这套 ring sync,**以前已经修好了**。 **现象**:同一算子先走eager,再走 aclgraph(capture / replay),在二者跨越部分插入的notify再底层会被拦截报错,这个硬同步信号不允许跨eager和aclgraph。 **原因**:原先 eager 和图模式共用同一对 ping-pong event、同一套序号。图里已经 record 过的 event,eager 侧再 wait 会碰到图里留下的旧信号;反过来也一样。 **本次改法**: - eager 和 aclgraph **各用一套 event**(两套 ping-pong)。 - 用 epoch 区分:普通模式 epoch=0,图模式用当前 capture model;换 epoch 时 **序号清零**,图模式再分配自己的 event 池(旧图的 event 留给 replay,不和新 capture / eager 混用)。 - wait / record 时带上「是不是 capture」,只碰对应那一套 event。 - 调用收成一次 BeginRingLaunch(切 epoch → 确保 event 建好 → 取本轮序号),语义不变。 **改前(串扰)**: text ── aclgraph capture / replay ── ── eager ── ctrl [c1][c2][c3 wait 共用 E0] ... [c' wait 共用 E0] ← 可能等的是图里的旧 E0 aicore [a1][a2] E0^ E1^ ... [a'] event 同一对 E0/E1 贯穿两种模式 ─────────────────────────────► **改后(隔离)**: text ── aclgraph(epoch=model,graphEvents)── ── eager(epoch=0,eagerEvents)── ctrl [c1][c2][c3 wait gE0] ... [c' wait eE0] ← 只等 eager 自己的 eE0 aicore [a1][a2] gE0^ gE1^ ... [a'] eE0^ sequence 在图内递增;切到 eager 时 sequence 归零,两套 event 互不 wait --- ## 3. 暂时关掉「控核缩核」 **现象**:按实际 maxC/maxV 把核数缩小后,和提前下发、多轮重叠叠在一起,整网执行发现控到极小核的几个核会卡死。 **改法(临时策略)**: - Host:启动前不再按缓存里的 maxC/maxV 改小 blockdim,一律用配置的满核数。 - Device:handshake 之后不再做按任务缩核(CalcAdjAicoreEnd)。 代码里用开关挡住,实现还留着,待定位清楚后再酌情打开。 --- ## 4. Sche 分波撞到同一个 threadIdx **现象**:A5 压测报 Duplicate threadIdx(例如 cpu=3, threadIdx=1, bitmap 已占用)。 **原因**:aicpu的任务调度是NormalMode, 一次 launch 的 AICPU block 数可以大于同时能跑的核。核不够时会分波:第一波跑完退出,第二波又绑到同一批物理核,算出的 threadIdx 和第一波一样。第一波其实已经把活干完了,第二波再跑同一编号是错的,也不该当成致命错误直接失败(还可能清不掉分配状态)。 **改法**:发现 threadIdx 已被占用时,把本 block 标成丢弃(threadIdx=-1),不再进 sche,但仍正常退出凑齐人数,好清状态。顺带给真正的失败路径补了更清楚的 ERROR 日志。 See merge request: cann/pypto!6417 | 2 months ago | |
fix(machine): Fix machine shedule perf Co-authored-by: LordOfMysteries<duhongxiang@huawei.com> # message auto-generated for no-merge-commit merge: !6712 merge fix/aicpu-sync-mode-if-branch into master fix(machine): Fix machine shedule perf Created-by: wan_jianfen 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!6712 | 2 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 | |
test(machine): Supplement machine UT test cases_6. Co-authored-by: chai-hw<chaizhengtong@huawei.com> # message auto-generated for no-merge-commit merge: !5244 merge ut_7 into master test(machine): Supplement machine UT test cases_6. Created-by: chai-hw Commit-by: chai-hw Merged-by: cann-robot Description: machine ut补充 See merge request: cann/pypto!5244 | 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 | |
perf(machine): Mix pending general Co-authored-by: xuyi_37<xuyi37@huawei.com> # message auto-generated for no-merge-commit merge: !4855 merge master into master perf(machine): Mix pending general Created-by: xuyi_37 Commit-by: xuyi_37 Merged-by: cann-robot Description: perf(machine): Mix pending general Related Issue: [#2670](https://gitcode.com/cann/pypto/issues/2670) See merge request: cann/pypto!4855 | 4 months ago | |
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 months ago | |
test(machine): Supplement machine UT test cases_12. Co-authored-by: chai-hw<chaizhengtong@huawei.com> # message auto-generated for no-merge-commit merge: !5361 merge ut_12 into master test(machine): Supplement machine UT test cases_12. Created-by: chai-hw Commit-by: chai-hw Merged-by: cann-robot Description: machine ut补充 See merge request: cann/pypto!5361 | 3 months ago | |
fix(machine): Fix os throttle bug Co-authored-by: LordOfMysteries<duhongxiang@huawei.com> # message auto-generated for no-merge-commit merge: !5847 merge memleak into master fix(machine): Fix os throttle bug Created-by: LordOfMysteries Commit-by: LordOfMysteries Merged-by: cann-robot Description: https://gitcode.com/cann/pypto/issues/3203 # Device OS AICPU 节流导致调度误超时 ## 1. 背景 Device OS 对单个 AICPU 线程存在节流策略: - 连续跑约 **950ms** 后强制让出约 **50ms** - **按 AICPU 独立生效**(非整机统一掐断) - 节流期间该 AICPU 上的调度逻辑暂停;AICore 本身不受此策略直接打断 - PyPTO 超时用 cntvct_el0(GetCycles()),节流期间计时器仍前进 典型现象: - A5 启动仲裁失败:#sche.arbitration.failed: scheCpuNum=4, currentCpuNum=2, cpumask=0x88 - A2/A3 单 sche 等 ctrl 启动时偶发 WAIT_CTRL_TIMEOUT - 稳态派发偶见 ProcessTaskLoop / F72001(多为依赖断流放大后的终态,而非 50ms 本身直接打爆 10s 超时) ## 2. 问题根因 ### 2.1 直接根因 调度启动路径上存在一批 **≤50ms 的 spin 等待超时**。当被等待的 AICPU 因 OS 节流晚到时,等待方在 50µs~数 ms 内判超时,触发: - 仲裁失败(ARBIT_FAILED) - 单 sche 等 ctrl 失败(直接报错) - 或依赖解算窗口错位,后续放大成派发超时 ### 2.2 关键失败路径(A5 实测) ComputeArbitrationLevel 三级降级中,**Level 3(等 scheCpuNum 个 CPU 报到)** 原先仍用 GetArbitTimeOutVal()(ERROR 级默认 **50µs**): text AICPU 启动 → fetch_or(cpumask) → CAS 赢者跑 ComputeArbitrationLevel Level1: 等 nrAicpu (短超时,快速探测) Level2: 等 die0 cluster (短超时,快速探测) Level3: 等 scheCpuNum (原 50µs → 节流场景误失败) 现场日志 cpumask=0x88, currentCpuNum=2 含义: - 0x88 = bit3 | bit7 → 仅 CPU3、CPU7 完成登记 - popcount(0x88)=2 与 currentCpuNum=2 一致(cpumask 是位图,不是个数) - scheCpuNum=4,Level3 在 50µs 内等不到另外 2 个 AICPU → ARBIT_FAILED ### 2.3 非根因澄清 | 路径 | 是否会被 50ms 节流直接打爆 | 说明 | |---|---|---| | ProcessTaskLoop / TIMEOUT_DISPATCH | 否 | 超时约 **10s**,单次 50ms 只造成抖动 | | AICore 侧超时(aicore_entry.h) | 否 | 最短失败超时约 **13s** | | A220 降级循环 scheCpuNum→1 | 否(功能上) | 当前线程已登记 cpumask,降到 1 必成功 | | A220 WaitForScheCpuInSameCluster | 否(功能上) | 失败后走降级,不直接报错 | ## 3. 修改方案 原则:**只对“超时即功能失败、且确实在等其他 AICPU”的路径加 55ms 兜底**;可降级/快速探测路径保持短超时,避免无谓拉长启动。 ### 3.1 统一 55ms 常量 文件:framework/src/machine/device/dynamic/device_utils.h | 常量 | Cycle 数 | 平台时钟假设 | |---|---|---| | TIMEOUT_A2A3_55MS | 2750000 | A2/A3 ≈ 50MHz | | TIMEOUT_A5_55MS | 55000000 | A5 ≈ 1GHz(约为 A2/A3 的 20×) | Helper: cpp inline uint64_t GetOsThrottleSafeWaitTimeout(ArchInfo archInfo) { return (archInfo == ArchInfo::DAV_3510) ? TIMEOUT_A5_55MS : TIMEOUT_A2A3_55MS; } 55ms 略大于 OS 强制让出窗口(~50ms),用于覆盖节流误超时。 ### 3.2 A5 仲裁:仅兜底级改 55ms 文件:device_sche_alloc_thread.h WaitForCpuMaskReadyForArbitration 增加参数 osThrottleFallback: - false:继续 GetArbitTimeOutVal()(50µs~数 ms),用于 Level1/2 快速探测 - true:GetOsThrottleSafeWaitTimeout()(55ms),用于最终兜底 | 级别 | 等待目标 | 超时 | 失败后果 | |---|---|---|---| | Level1 | nrAicpu | 短 | 降级 | | Level2 | die0 cluster + 2 | 短 | 降级 | | **Level3** | **scheCpuNum** | **55ms** | **ARBIT_FAILED(功能失败)** | ### 3.3 Follower 等仲裁结果:55ms WaitForArbitrationLevel:CAS 失败者等待赢家 store(level)。 - A5 Level3 最长可阻塞约 55ms,follower 超时必须 ≥ 该时间,否则会在赢家尚未发布结果时误报失败 - 正常路径赢家很快 publish,不会固定多等 55ms ### 3.4 A220 等 ctrl:仅单 sche 用 55ms 文件:device_sche_wait_ctrl.h → CalcWaitTimeout | 场景 | 超时 | 理由 | |---|---|---| | 单 sche 等 ctrl 起来 | **55ms** | 超时 → CTRL_WAIT_FAILED,直接报错 | | 多 sche 等 ctrl 起来 | 100µs~3ms | 超时 → CTRL_WAIT_DROPPED,丢一个线程继续跑 | | 等决策终态 | 1s | 原本已足够 | ### 3.5 明确不改的路径 | 路径 | 保持短超时的原因 | |---|---| | A5 Level1/2 | 拓扑优化探测,失败即降级 | | A220 WaitForCpuMaskReadyForArbitration 降级循环 | 可降到 1,当前 CPU 已在 mask,必成功 | | A220 WaitForScheCpuInSameCluster | 失败后降级,非硬失败 | | ProcessTaskLoop / AICore 超时 | 已远大于 50ms | See merge request: cann/pypto!5847 | 2 months ago | |
test(machine): Supplement machine UT test cases_12. Co-authored-by: chai-hw<chaizhengtong@huawei.com> # message auto-generated for no-merge-commit merge: !5361 merge ut_12 into master test(machine): Supplement machine UT test cases_12. Created-by: chai-hw Commit-by: chai-hw Merged-by: cann-robot Description: machine ut补充 See merge request: cann/pypto!5361 | 3 months ago | |
feat(machine): Enable launch early start Co-authored-by: qq_52905393<liuzhen180@huawei.com> # message auto-generated for no-merge-commit merge: !5968 merge dev-launch-early into master feat(machine): Enable launch early start Created-by: qq_52905393 Commit-by: qq_52905393 Merged-by: cann-robot Description: 1、A5 最大调度线程改为 4 2、在 launch_early_start 未设置的时候,如果没有值依赖或者配置了 ready on host tensor 则改为 capture 模式下开启提前发射 See merge request: cann/pypto!5968 | 2 months ago | |
tests(machine): Migrate ST cases to UT and Python ST. Co-authored-by: chai-hw<chaizhengtong@huawei.com> # message auto-generated for no-merge-commit merge: !5649 merge ST into master tests(machine): Migrate ST cases to UT and Python ST. Created-by: chai-hw Commit-by: chai-hw Merged-by: cann-robot Description: CPP ST 整改;部分删除;部分改成ut;部分重写成python st See merge request: cann/pypto!5649 | 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 | |
perf(machine): Lazy-init ItemPool free-list in chunks Co-authored-by: LordOfMysteries<duhongxiang@huawei.com> # message auto-generated for no-merge-commit merge: !5004 merge perf/item-pool-lazy-init into master perf(machine): Lazy-init ItemPool free-list in chunks Created-by: LordOfMysteries Commit-by: LordOfMysteries Merged-by: cann-robot Description: https://gitcode.com/cann/pypto/issues/2597 perf(machine): Bump-allocate virgin ItemPool slots without freelist Defer ItemPool slot activation until first use. Virgin slots are taken by bumping initReadyCount (no freelist link/pop). Freelist is only used for slots returned by Destroy. Changes: - Remove chunked LinkFreeListChunk / EnsureFreeSlotAvailable expansion - Create: freelist hit for recycled slots, else bump high-water mark - Rename count_ / ItemPoolMeta.count to size_ - UT covers bump + recycle reuse Related Issues: N/A See merge request: cann/pypto!5004 | 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 | |
test(machine): Supplement machine UT test cases_8. Co-authored-by: chai-hw<chaizhengtong@huawei.com> # message auto-generated for no-merge-commit merge: !5271 merge ut_9 into master test(machine): Supplement machine UT test cases_8. Created-by: chai-hw Commit-by: chai-hw Merged-by: cann-robot Description: machine ut 补充 See merge request: cann/pypto!5271 | 3 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 | |
feat(pypto_pro):unified error codes Co-authored-by: huanyongben<huanyongben1@hisilicon.com> # message auto-generated for no-merge-commit merge: !6453 merge master into master feat(pypto_pro):unified error codes Created-by: huanyongben Commit-by: huanyongben Merged-by: cann-robot Description: pypto pro整改错误码以及日志规范 See merge request: cann/pypto!6453 | 2 months ago |
| Files | Last commit | Last update |
|---|---|---|
| 3 months ago | ||
| 2 months ago | ||
| 2 months ago | ||
| 4 months ago | ||
| 3 months ago | ||
| 4 months ago | ||
| 4 months ago | ||
| 2 months ago | ||
| 3 months ago | ||
| 2 months ago | ||
| 3 months ago | ||
| 2 months ago | ||
| 3 months ago | ||
| 3 months ago | ||
| 4 months ago | ||
| 4 months ago | ||
| 3 months ago | ||
| 7 months ago | ||
| 2 months ago |