Skip to content

Add validated A5 VPTO ops#834

Open
mouliangyu wants to merge 1 commit into
hw-native-sys:mainfrom
mouliangyu:codex/a5-vpto-prune-unsupported-ops
Open

Add validated A5 VPTO ops#834
mouliangyu wants to merge 1 commit into
hw-native-sys:mainfrom
mouliangyu:codex/a5-vpto-prune-unsupported-ops

Conversation

@mouliangyu

@mouliangyu mouliangyu commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add validated A5 VPTO ops for spr store, pltm, histogram, extrema-predicate, and vmadd in both LLVM emitters
  • remove unsupported A5 VPTO ops from the public VPTO surface after SIM abort evidence
  • add focused VPTO lit coverage and a SIM validation case for vmadd

Validation

  • CCACHE_DISABLE=1 ninja -C build ptoas
  • llvm-lit -a build/test/lit --filter 'a5_extra_arith|a5_extra_predicate|a5_histogram|a5_spr_store'
  • llvm-lit build/test/lit --filter 'vpto'
  • DEVICE=SIM CASE_NAME=micro-op/a5-extra/vmadd test/vpto/scripts/run_host_vpto_validation.sh
  • git diff --check HEAD~1..HEAD

@reedhecre

reedhecre commented Jun 17, 2026

Copy link
Copy Markdown

Codex Review

该评论由 review 机器人自动更新。

  • PR: Add validated A5 VPTO ops #834 Add validated A5 VPTO ops
  • Author: mouliangyu
  • Base/Head: main / codex/a5-vpto-prune-unsupported-ops
  • Head SHA: dd67946e9e5f
  • Trigger: PR 有新提交
  • Generated At: 2026-06-17T14:40:49Z
  • Previous Head SHA: 1b6fa33a4edf
  • Status: failed at codex-review (exit=1)

Summary

Review failed at stage codex-review: exit=1

Findings

未生成结构化 findings,因为 review 过程提前失败。

Log Tail

Switched to branch 'pr-834'
dd67946e9e5f3aec30b04610af826e5cf70e9834
 docs/isa/micro-isa/03-vector-load-store.md         |  40 +++
 docs/isa/micro-isa/05-materialization-predicate.md |  29 ++
 docs/isa/micro-isa/07-binary-vector-ops.md         |  21 ++
 docs/isa/micro-isa/10-reduction-ops.md             |  85 ++++++
 docs/vpto-spec.md                                  |  10 +-
 include/PTO/IR/VPTOOps.td                          | 126 ++++++++
 lib/PTO/IR/VPTO.cpp                                | 159 ++++++++++
 lib/PTO/Transforms/PTOValidateVPTOIR.cpp           |   4 +-
 lib/PTO/Transforms/VPTOCANN900LLVMEmitter.cpp      | 339 ++++++++++++++++++++-
 lib/PTO/Transforms/VPTOLLVMEmitter.cpp             | 316 ++++++++++++++++++-
 test/lit/vpto/a5_extra_arith_vpto_llvm.pto         |  41 +++
 test/lit/vpto/a5_extra_predicate_vpto_llvm.pto     |  31 ++
 test/lit/vpto/a5_histogram_vpto_llvm.pto           |  28 ++
 test/lit/vpto/a5_spr_store_vpto_llvm.pto           |  26 ++
 test/vpto/cases/micro-op/a5-extra/vmadd/compare.py |  59 ++++
 test/vpto/cases/micro-op/a5-extra/vmadd/golden.py  |  40 +++
 test/vpto/cases/micro-op/a5-extra/vmadd/kernel.pto |  59 ++++
 test/vpto/cases/micro-op/a5-extra/vmadd/launch.cpp |  45 +++
 test/vpto/cases/micro-op/a5-extra/vmadd/main.cpp   | 120 ++++++++
 19 files changed, 1562 insertions(+), 16 deletions(-)
===== END STAGE clone rc=0 @ 2026-06-17 22:40:40 =====

===== STAGE codex-review @ 2026-06-17 22:40:40 =====
set -euo pipefail
cd '/tmp/ptoas-pr-review-monitor/runs/20260617_224033_pr834/repo'
'codex' exec -C '/tmp/ptoas-pr-review-monitor/runs/20260617_224033_pr834/repo' -s read-only -c 'model_provider="codereview"' -c 'model="gpt-5.4"' -c 'model_reasoning_effort="xhigh"' --output-schema '/tmp/ptoas-pr-review-monitor/runs/20260617_224033_pr834/review_schema.json' -o '/tmp/ptoas-pr-review-monitor/runs/20260617_224033_pr834/codex_last_message.json' --color never - < '/tmp/ptoas-pr-review-monitor/runs/20260617_224033_pr834/review_prompt.txt'
OpenAI Codex v0.115.0 (research preview)
--------
workdir: /tmp/ptoas-pr-review-monitor/runs/20260617_224033_pr834/repo
model: gpt-5.4
provider: codereview
approval: never
sandbox: read-only
reasoning effort: xhigh
reasoning summaries: none
session id: 019ed606-f6ba-7612-b25b-f1c0b7f2895f
--------
user
你现在在审查 GitHub PR。

仓库:hw-native-sys/PTOAS
PR:#834 Add validated A5 VPTO ops
作者:mouliangyu
base branch:origin/main
head branch:HEAD(当前已 checkout 到 PR head)

要求:
1. 只审查这个 PR 相对 origin/main 的改动,必要时可以看上下文文件。
2. 重点找真实的 correctness / regression / contract mismatch / CI / runtime / compatibility 问题。
3. 不要提纯风格建议,不要提低价值猜测。
4. 严格按优先级输出:
   - P1:高概率会导致错误结果、编译/运行失败、严重回归、发布阻断
   - P2:重要缺陷、行为回归、遗漏校验/测试、较大兼容性问题
   - P3:次要但明确可改的问题
5. 如果没有问题,summary 直接写:未检查到 PR #834 存在问题,并返回 findings=[]。
6. 如果有问题,summary 简洁概括,findings 里每条都要给出:
   - severity
   - title
   - body(说明为什么是问题,尽量具体)
   - file(尽量给相对路径)
   - line(能确定就填整数,否则 null)

建议先查看:
- git status --short
- git diff --stat origin/main...HEAD
- git diff --unified=80 origin/main...HEAD

最终输出必须严格匹配 JSON schema。

mcp startup: no servers
Reconnecting... 1/5 (unexpected status 403 Forbidden: {"code":"GROUP_DISABLED","message":"API Key 所属分组已停用"}, url: https://codex.0u0o.com/responses, cf-ray: a0d2cf927f8d29ab-LAX, request id: 164d73c6-d3ea-4076-829c-58dd8dd6294f)
Reconnecting... 2/5 (unexpected status 403 Forbidden: {"code":"GROUP_DISABLED","message":"API Key 所属分组已停用"}, url: https://codex.0u0o.com/responses, cf-ray: a0d2cf95e89bf6b1-LAX, request id: 5c11f699-eeb7-4b4d-9a45-8fec4eed2c3f)
Reconnecting... 3/5 (unexpected status 403 Forbidden: {"code":"GROUP_DISABLED","message":"API Key 所属分组已停用"}, url: https://codex.0u0o.com/responses, cf-ray: a0d2cf9afb26585e-LAX, request id: cf056c78-0e08-429d-bc8c-225862a1bedd)
Reconnecting... 4/5 (unexpected status 403 Forbidden: {"code":"GROUP_DISABLED","message":"API Key 所属分组已停用"}, url: https://codex.0u0o.com/responses, cf-ray: a0d2cfa2abd069c7-LAX, request id: 9f35099a-0cfe-42de-8ab0-6aa93fb9666e)
Reconnecting... 5/5 (unexpected status 403 Forbidden: {"code":"GROUP_DISABLED","message":"API Key 所属分组已停用"}, url: https://codex.0u0o.com/responses, cf-ray: a0d2cfae6ed5e4ec-LAX, request id: 5ed6fb06-f2ec-4ef8-aadd-c47d5e0ecebd)
ERROR: unexpected status 403 Forbidden: {"code":"GROUP_DISABLED","message":"API Key 所属分组已停用"}, url: https://codex.0u0o.com/responses, cf-ray: a0d2cfc2b9b22abd-LAX, request id: 9ce253a1-33c3-4610-bad3-c889588a0fed
Warning: no last agent message; wrote empty content to /tmp/ptoas-pr-review-monitor/runs/20260617_224033_pr834/codex_last_message.json
===== END STAGE codex-review rc=1 @ 2026-06-17 22:40:49 =====

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces several new VPTO operations for the A5 architecture, including SPR state operations (sprclr, sprsti, sprsts), loop-indexed tail predicates (pltm_b8/16/32), fused multiply-add (vmadd), extrema predicate reductions (vcbmax, vcbmin), and histogram updates (chistv2, dhistv2). Additionally, it restricts trem and trems operations on A5 to floating-point types, removing integer support. The review feedback points out potential ValueError exceptions in the test comparison script (compare.py) when comparing arrays of mismatched shapes.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +25 to +27
if not ok:
diff = np.max(np.abs(golden.astype(np.float64) - output.astype(np.float64)))
print(f"[ERROR] compare failed: {label}, max_abs_diff={diff}")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

If golden.shape != output.shape, ok will be False. In the error reporting block, evaluating golden.astype(np.float64) - output.astype(np.float64) will raise a ValueError due to shape mismatch, masking the actual error. We should check if the shapes match before performing element-wise operations.

Suggested change
if not ok:
diff = np.max(np.abs(golden.astype(np.float64) - output.astype(np.float64)))
print(f"[ERROR] compare failed: {label}, max_abs_diff={diff}")
if not ok:
if golden.shape != output.shape:
print(f"[ERROR] shape mismatch: golden={golden.shape}, output={output.shape}")
else:
diff = np.max(np.abs(golden.astype(np.float64) - output.astype(np.float64)))
print(f"[ERROR] compare failed: {label}, max_abs_diff={diff}")

Comment on lines +38 to +45
if not ok:
mismatch = np.flatnonzero(golden != output)
first = int(mismatch[0]) if mismatch.size else -1
print(
f"[ERROR] compare failed: {label}, first_mismatch={first}, "
f"golden={golden[first] if first >= 0 else 'n/a'}, "
f"output={output[first] if first >= 0 else 'n/a'}"
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

If golden.shape != output.shape, ok will be False. In the error reporting block, evaluating golden != output will raise a ValueError due to shape mismatch, masking the actual error. We should check if the shapes match before performing element-wise operations.

Suggested change
if not ok:
mismatch = np.flatnonzero(golden != output)
first = int(mismatch[0]) if mismatch.size else -1
print(
f"[ERROR] compare failed: {label}, first_mismatch={first}, "
f"golden={golden[first] if first >= 0 else 'n/a'}, "
f"output={output[first] if first >= 0 else 'n/a'}"
)
if not ok:
if golden.shape != output.shape:
print(f"[ERROR] shape mismatch: golden={golden.shape}, output={output.shape}")
else:
mismatch = np.flatnonzero(golden != output)
first = int(mismatch[0]) if mismatch.size else -1
print(
f"[ERROR] compare failed: {label}, first_mismatch={first}, "
f"golden={golden[first] if first >= 0 else 'n/a'}, "
f"output={output[first] if first >= 0 else 'n/a'}"
)

@mouliangyu mouliangyu force-pushed the codex/a5-vpto-prune-unsupported-ops branch from 3c6fbeb to 1b6fa33 Compare June 17, 2026 14:29
@mouliangyu mouliangyu force-pushed the codex/a5-vpto-prune-unsupported-ops branch from 1b6fa33 to dd67946 Compare June 17, 2026 14:36
@mouliangyu mouliangyu marked this pull request as ready for review June 17, 2026 15:06
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