Skip to content

[IR] 建立规范化资源接口与事务阶段契约 - #363

Merged
zhoubot merged 2 commits into
PTO-ISA:mainfrom
hmljy2020:feat/acir-resource-contract-v2
Oct 27, 2026
Merged

zhoubot merged 2 commits into
PTO-ISA:mainfrom
hmljy2020:feat/acir-resource-contract-v2

Conversation

@hmljy2020

@hmljy2020 hmljy2020 commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

为 issue #361 建立正式 ACIR v2 资源与阶段基础。后续 Rule/Method 和 link 需要一致地回答:资源由谁分配、输出由谁提供、导出是否复制,以及实例是否已闭合。本 PR 将这些规则放入正式 Dialect,复用实验分支的结构验证模式;不增加另一条 frontend。

linked 仅表示资源/实例结构闭合,不代表事务可执行。Python 默认入口、Runtime 和后端生成未切换。

Change type

  • Feature / behavior change
  • Tests / CI
  • Documentation / configuration

Related issues

Related to #361。PR-01,无前置实现 PR,不关闭整个 issue。feat/transactional-acir-gfsim 是复用来源,不是语义权威。

Changes

  • 区分 primitive<T>、state<T>、queue<T> 和 module_ref<@M>。State/Queue 显式分配并保留身份;Queue 深度属于分配配置;实例引用不创建实例。
  • output_kinds 区分外部提供的 bound 和导出已有资源的 export,打印明确显示 inputs(...) bound(...)。
  • 独立 v2 验证器检查阶段、接口和资源/实例闭包;旧 source/link、Routed/final、anchor 和两个 emitter 拒绝新阶段。
  • 按用户指导精简测试:新增 lit 从 1139 行减至 137 行,保留资源身份、绑定/导出、payload、重读和阶段边界;56 个反例减至 3 个核心检查。移除的 53 个案例是覆盖范围缩减,不计为当前 PASS,也不把临时实现限制固化为语言要求。
  • 更新普通 Instance 打印的测试适配器,保留原数值、时序和实例数量断言;未重写 DUT。修复这些 Python 改动的 Black 格式问题。
  • AGENTS.md 增加两项长期要求:每次提交/更新 PR 前精简内容,测试验证核心意图;提交前运行 CI changed-file Ruff/Black 等检查,格式化修改后复跑,不能以语法或功能测试替代。

主要修改所有者为 IR/Dialect、旧路径接纳边界、测试适配器和文档。编译器逻辑在本轮精简中未改变。PR 总新增行数从 2022 减至 1019;保留契约文档 docs/development/transactional-resource-ir.md。

Validation

当前提交:b69202aa8f63a89d81f23f0839e317009850d852;基线:b986bb0ad721bc0834a71fc710dddca4bde339f4。使用本 checkout 构建的 Clang/LLVM/MLIR 22.1.8 工具链,通过 pyc6/scripts/run.sh 执行:

范围 实际结果
精简后的新增 lit 5/5 PASS,含 3 个核心拒绝案例
本轮 lit gate + 原生 anchor 测试 PASS,退出码 0
changed-file pre-commit(与 CI 相同 hook 选择) PASS,包含 Ruff、Black、Markdown 检查
暂存文档快照 mkdocs build --strict PASS;工作目录未提交 RFC 草稿的失效链接单独保留为本地失败记录
独立精简审查 clear;16 个格式化 Python 文件 AST 不变,编译器逻辑不变
git diff --cached --check PASS

本轮运行:ctest --test-dir .pycircuit_out/local-clang22/build -R '^(ACIRLitGateTests|ACIRAnchorArtifactTests)$' --output-on-failure --no-tests=error;SKIP=pyc-api-hygiene pre-commit run --files <PR changed files>。

精简前同一编译器实现已通过完整 API gate 25/25 和新消费者目录 example gate 13/13,包括既有 C++/RTL/四态回归;本轮未重复整个硬件矩阵。旧版本远端 Python Checks 的 Black 失败已修复,当前远端 CI 以 checks 为准。

NOT RUN:新事务契约执行仿真(本批无执行 lowering)、nightly/长 oracle/变异矩阵、非 gate 历史 helper 执行。原始日志与两个版本的审查记录保留在本地忽略目录 docs/gates/logs/20261027-pr01-resources/;上表是远端可读摘要,不将本地路径冒充公开 artifact。

  • Executed checks and outcomes are recorded above
  • Skipped, deferred or unavailable checks and reasons are recorded above

Review checklist

  • Scope and affected contracts are identified; new proposals are distinguished from approved behavior
  • Tests cover relevant supported behavior and rejection/rollback boundaries
  • Both backends preserve common-IR semantics where affected; no fixture-specific admission or fallback shim
  • Active documentation and remaining callers are updated where needed
  • No generated build output, temporary evidence logs or secrets are committed
  • Required CI and independent reviews are complete for this candidate

Reviewer notes

本地独立审查已完成,最后一项等待当前远端 CI。实现与测试由不同实例负责;独立架构/审查使用 gpt-6-astra,其余实例继承会话模型/effort,未显式 override。本轮独立审查确认核心意图保留,并按用户最新要求移除边缘矩阵,未以减少覆盖宣称额外能力。

后续:PR-02 Rule/Method;PR-07 primitive 具体化、实际绑定和默认 Queue;PR-09 泛型 Module 要求与跨文件 link。无自动 merge。

@zhoubot zhoubot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed PR #363 head b69202a with its full diff and all review/comment/thread surfaces. Independent resource review and independent core-boundary tests found no remaining actionable defect.

Fixed an integration regression in prerequisite #366 (merged as c220222): the new normal instance printer caused three void-module tests from #364 to count zero children. Only two text filters changed; exact callee, instance-count, result and execution checks remain.

Fresh verification of the combined candidate 19fcf70b3a00e32ac47dbb7e723dfd438cdb0aac, tree 55cbb4999cdd2bd5aad5df99a34b08969e61d6e2, built and installed from its own checkout with LLVM/MLIR 22.1.8 and lit 18.1.8:

  • bash tools/run_api_tests.sh --tier gate: PASS 25/25.
  • bash tools/run_examples.sh --tier gate: PASS 13/13.
  • python -m pytest -q tests/system/test_void_module_results.py: PASS 30/30 (previously three reproduced failures).
  • New transactional lit: PASS 5/5; anchor tests PASS.
  • Independent checks: forwarded bound/export aliases, distinct allocations under CSE, reload stability, ownerless alias cycle and bound replacement rejection, both emitter boundary rejections PASS.
  • Changed-file pre-commit (CI hook selection), mkdocs build --strict, git diff --check: PASS.

No transaction execution/lowering capability is claimed. Nightly/long mutation matrices were not run. Implementation/integration, independent resource testing and independent review used separate instances; children inherited session model/effort without override. Raw receipts remain locally under docs/gates/logs/20261027-review-pr363/; this review supplies the remotely readable outcome summary.

@zhoubot
zhoubot merged commit a1a3fa2 into PTO-ISA:main Oct 27, 2026
10 checks passed
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.

2 participants