Skip to content

feat(sync): split cross and intra block interfaces - #1204

Merged
zhangstevenunity merged 5 commits into
mainfrom
codex/sync-block-interfaces
Aug 17, 2026
Merged

feat(sync): split cross and intra block interfaces#1204
zhangstevenunity merged 5 commits into
mainfrom
codex/sync-block-interfaces

Conversation

@Zhendong404

@Zhendong404 Zhendong404 commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Align the named PTO IR synchronization interfaces with PTODSL: pto.set_cross_block, pto.wait_cross_block, pto.set_intra_block, and pto.wait_intra_block.
  • Keep pto.sync.set/wait limited to FFTS modes 0/1/2.

Lowering

  • Cross-block: named IR ops canonicalize to pto.sync.set/wait with mode 0.
  • A5 intra-block: named IR ops lower directly to __builtin_cce_set_intra_block / __builtin_cce_wait_intra_block.
  • A2/A3 intra-block: named IR ops fall back to ffts_cross_core_sync / wait_flag_dev using CANN 9.1 FFTS_MODE_VAL (mode 2); static IDs are [0,15].
  • VPTO applies the same normalization, including its no-tile-op fast path.

Rebase

  • Rebased onto current official/main (e0647ffa).
  • Dropped a1d0f724938283c8a65679cacc8a640b68fa6522: its ptobc test-data fix is already on main.

Validation

  • ninja -C build PTOASCompiler
  • PYTHONPATH=build/python:ptodsl python3 -m unittest discover -s ptodsl/tests -p test_vector_cube_ops.py
  • A5 EmitC smoke: cross-block lowers to FFTS and intra-block to dedicated builtins.
  • A3 EmitC smoke: intra-block lowers to mode-2 FFTS and never to A5 builtins.

@github-actions github-actions Bot added the ci-slow this pr make ci too slow, makesure your pr doesn't cause this label Aug 10, 2026
@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Resolved: ci-sim runtime is back within its soft budget.

  • Latest vpto-sim-validation runtime: 1h 5m 40s
  • Soft budget: 1h 30m
  • Workflow run

The previous duration warning is resolved. This status is advisory only.

@Zhendong404
Zhendong404 marked this pull request as ready for review August 11, 2026 02:16
@github-actions github-actions Bot removed the ci-slow this pr make ci too slow, makesure your pr doesn't cause this label Aug 11, 2026
@Zhendong404
Zhendong404 marked this pull request as draft August 11, 2026 08:36
@Zhendong404
Zhendong404 marked this pull request as ready for review August 11, 2026 13:27
@Zhendong404
Zhendong404 force-pushed the codex/sync-block-interfaces branch 2 times, most recently from 0e4b1c7 to e7fef55 Compare August 11, 2026 13:56
@Zhendong404
Zhendong404 marked this pull request as draft August 11, 2026 13:56
@Zhendong404
Zhendong404 marked this pull request as ready for review August 11, 2026 15:19
@github-actions github-actions Bot added ci-slow this pr make ci too slow, makesure your pr doesn't cause this and removed ci-slow this pr make ci too slow, makesure your pr doesn't cause this labels Aug 11, 2026

@zhangstevenunity zhangstevenunity left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

结论:建议 Request changes。基于当前 PR head 93f6339,发现 4 个接口相关问题。

  1. [P1] A5 旧 sync.set/wait 调用方迁移不完整

    新实现忽略 targetArch,统一把 pto.sync.set/wait 降成 FFTS cross-block 操作(PTOToEmitC.cpp),同时 A5 静态 event ID 被限制为 0..15PTO.cpp)。

    但仓库仍有 A5 调用明确依赖旧的 intra-block 语义,例如:

    静态 ID 16 会被 verifier 拒绝;其余调用会静默进入错误的同步域,可能导致运行时死锁。需要全面搜索 A5 调用并迁移到 pto.set_intra_block/pto.wait_intra_block,同步更新校验脚本及生成样例。

  2. [P1] ffts_mode=2 会被静默改成 mode 0

    _named_sync_event_op 对值 2 不生成属性,但 pto.set_cross_block 的 ODS 默认值是 0PTOOps.td)。因此公开接口:

    pto.set_cross_block(..., ffts_mode=2)

    不会报错,实际却生成 mode 0。同步模式被静默改变可能造成错误匹配或死锁。既然 named cross-block 接口固定为 mode 0,建议删除该参数,或只接受 0 并立即报错。

  3. [P2] 删除旧公共名称后,内部生成规范仍引用旧接口

    PR 只导出新名称(ptodsl/pto.py),但 VMI 重写规范仍要求生成 set_cross_flagwait_cross_flagset_intra_flagwait_intra_flagmi-dsl-spec.md)。

    按该规范生成的新代码会直接遇到不存在的接口。需要同步规范;另外这次是硬删除公共 API,最好提供弃用别名或明确的 breaking-change/migration 说明。

  4. [P2] 用户文档与实际接口约束矛盾

    文档先声明 cross-block event ID 为 0..15,实现也允许五种 pipe,但:

    应统一 pipe 集合和 event ID 范围,避免用户按错误契约编写同步代码。

@Zhendong404

Copy link
Copy Markdown
Collaborator Author

已按 review 完成修复,提交:f66862220(fix(sync): address block interface review)。

  1. A5 旧 sync 调用已完整迁移为 set_intra_block / wait_intra_block:四个 A5 Python 样例、tinsert_acc2vec.pto,以及审计发现的 test/samples/Complex/mix_kernel.pto;后者同时补充了 pto.target_arch = "a5",使 ID 16 在脱离 CLI 架构参数时也按 A5 校验。
  2. 移除了 named set_cross_blockffts_mode 参数,并增加回归测试,传入该参数会直接报 TypeError,不再存在 mode 2 静默变为 mode 0 的情况。
  3. 已将 VMI rewrite 规范里的旧 *_flag 接口名更新为 *_block
  4. 已统一 PTODSL 用户文档中的 cross-block pipe 集合与 event ID 范围;同时明确静态 intra-block 的 A5/A2/A3 范围。

验证:

  • ninja -C build PTOASCompiler
  • PYTHONPATH=build/python:ptodsl python3 -m unittest discover -s ptodsl/tests -p test_vector_cube_ops.py(54 passed)
  • 四个 A5 Python 样例的生成、PTO IR 和 EmitC 输出检查,确认输出使用 __builtin_cce_{set,wait}_intra_block 且不含 FFTS 路径
  • tinsert_acc2vecmix_kernel PTO IR 验证
  • git diff --check

另执行了 test/samples/runop.sh -t Sync:四个本次相关 A5 用例均通过;脚本仍报告若干无关的既有 Sync 样例失败。

@Zhendong404
Zhendong404 force-pushed the codex/sync-block-interfaces branch from f668622 to e232d25 Compare August 17, 2026 03:17
@Zhendong404

Copy link
Copy Markdown
Collaborator Author

已 rebase 到 main@5c5fe0dbd 并更新 PR。

本次 CI 失败是 scf_while_generic_domains_emitc.pto 仍断言旧的 A5 intra-block 输出;legacy pto.sync.set 在本 PR 语义下应走 FFTS cross-block lowering。已将 CHECK 更新为 getFFTSMsg + __builtin_cce_ffts_cross_core_sync,同时整理了变更行的括号和 Python 换行格式,未改变同步语义。

本地验证:

  • scf_while_generic_domains_emitc.ptonamed_sync_a5_emitc.ptosync_set_a5_emitc_physical_ids.pto 的 A5 FileCheck 均通过
  • python3 -m py_compile(受影响 Python 文件)通过
  • git diff --check official/main 通过

新 CI 已触发:31990667766

@zhangstevenunity
zhangstevenunity merged commit 7742265 into main Aug 17, 2026
11 checks passed
@reedhecre

Copy link
Copy Markdown

A3 板测失败

  • 触发方式:merged
  • 源码提交:7742265dabe3
  • 结果汇总:OK 313 / FAIL 2 / SKIP 30
  • 日志:/home/zhongxuan/ptoas-board-monitor/runtime/logs/20260817_014128_merged_pr1204.log
  • 结果 TSV:/home/zhongxuan/ptoas-board-monitor/runtime/logs/20260817_014128_merged_pr1204.tsv
  • 失败阶段:board-validation / exit=1

失败用例

  • Ci/ci (run, exit=2)
  • Qwen3_14BPrefillA3/out_proj_aiv (run, exit=2)

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.

3 participants