Skip to content

Update: elide A5 terminal releases after orchestration - #13

Draft
yanghaoran29 wants to merge 1 commit into
mainfrom
feat/a5-terminal-release-elision-20260829
Draft

Update: elide A5 terminal releases after orchestration#13
yanghaoran29 wants to merge 1 commit into
mainfrom
feat/a5-terminal-release-elision-20260829

Conversation

@yanghaoran29

@yanghaoran29 yanghaoran29 commented Aug 29, 2026

Copy link
Copy Markdown
Owner

目的

减少 A5 成功终态中逐 task deferred release 的集中开销,同时保留运行期和错误路径的精确生命周期维护。

本实验只针对 A5。A5 泳道图中能看到有效任务结束后仍有大量集中 release,包含 refcount 更新和 ring advance;本次检查的 A2/A3 泳道图没有出现同类的大段结尾 release 阻塞,因此没有修改 A2/A3 路径。

优化方式

  • Orchestrator 尚未结束时,保持逐 task deferred release。
  • Orchestrator seal 后,在原有 buffer-full、idle drain 和 exit drain 边界跳过本地 release backlog,不在 Scheduler 每轮热循环顶部读取 orchestrator_done
  • 全部 task complete 且所有 Scheduler 离开 dispatch 后,由 terminal barrier 最后到达的线程一次性关闭各 ring 的 live slots,并发布最终 ring 状态。
  • 错误、超时和非成功终态继续走精确 lifecycle bookkeeping。
  • 恢复 Main 原有的 AicpuExecutor::run() Scheduler 入口 gate,避免额外改变已验证敏感的 Scheduler 热函数布局。
  • 两个 terminal 协调原子复用 SchedulerContext 的 8 B 尾部空洞,不扩大对象。
  • 泳道图新增 terminal-close phase,并增加 terminal close 的 A5 SchedulerState 单元测试。

为什么这样设计是安全的

orchestrator_done 是任务图的 seal:Orchestrator 编排结束后不会再有新任务提交。逐 task release 在运行期的主要作用是归还 slot、heap 和依赖资源,供后续编排继续分配;seal 后不存在这种后续分配,因此停止增量回收不会阻塞新任务到来。

已有任务仍然正常完成。只有确认全部 task complete、所有 Scheduler 已离开 dispatch、并且没有 Orchestrator/Scheduler 错误后,terminal leader 才统一关闭剩余 live slots。错误、超时和未 seal 的退出仍执行精确逐 task release,因此不会把这项放宽带到需要继续前进或需要诊断的路径。

为什么在 A5 上做

A5 默认是 1 Orchestrator + 4 Schedulers,线程跨 cluster、可能跨 die;其 Batch Paged Attention 泳道图显示结尾集中 release 会形成明显 Scheduler 尾部并增加与 Orchestrator 共享状态的竞争。对应 A2/A3 轨迹没有观察到结尾大量 release 阻塞,当前没有可证明的 A2/A3 优化目标,因此本 PR 保持 A2/A3 行为不变。

平台差异和实验范围已经补充到 docs/tensormap-and-ringbuffer-a2a3-vs-a5.md

优化效果

实验设备为 A5 card 1。非 Qwen 样例各 100 轮,Qwen3 5 轮;精测回退按 Orchestrator 时间判断。

  • 8/8 个样例没有 5% Orchestrator 回退。
  • Batch Paged Attention Orchestrator:
    • 刷新的 A5 Main 基线:5918.916 us
    • 恢复入口 gate 前:6947.106 us
    • 当前方案:5819.991 us
    • 当前方案相对 Main:-1.67%
    • 当前方案相对实验前:-16.22%
  • 全量 Device 几何平均相对 Main:-9.994%(补充指标,不作为本轮回退判定条件)。
  • 8 个泳道图的 Device 时间均未相对 Main 回退 5%;最差为 Batch Paged Attention +1.59%

验证

  • A5 全量粗测:8 个样例各 1 轮。
  • A5 level-4 泳道图:8 个样例各 1 轮。
  • A5 deps:8 个样例各 1 轮,与泳道图串行执行。
  • A5 精测:7 个非 Qwen 样例各 100 轮,Qwen3 5 轮。
  • C++ UT:125/125 通过。
  • test_swimlane_converter.py:28/28 通过。
  • 主仓 pre-commit:全部通过。

@yanghaoran29
yanghaoran29 force-pushed the feat/a5-terminal-release-elision-20260829 branch 3 times, most recently from 1cdfbc9 to 92b12d3 Compare August 29, 2026 07:29
- Stop per-task deferred release after orchestration is sealed
- Close live ring slots after every scheduler leaves dispatch
- Preserve exact lifecycle handling for errors and non-terminal exits
- Document the A5-only measurement scope and A2/A3 comparison
@yanghaoran29
yanghaoran29 force-pushed the feat/a5-terminal-release-elision-20260829 branch 2 times, most recently from 4dca8be to 34f7101 Compare August 29, 2026 08:42
@yanghaoran29 yanghaoran29 changed the title Update: A5 终态 deferred release 收口实验 Update: elide A5 terminal releases after orchestration Aug 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant