Skip to content

with pto.simt(x, y, z) - Inline SIMT 实现#927

Open
and0d0 wants to merge 6 commits into
hw-native-sys:mainfrom
and0d0:486_simt_inline
Open

with pto.simt(x, y, z) - Inline SIMT 实现#927
and0d0 wants to merge 6 commits into
hw-native-sys:mainfrom
and0d0:486_simt_inline

Conversation

@and0d0

@and0d0 and0d0 commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

TODO:
需要看一下和 叠加pto.persistent还有什么没考虑到的:#925

实现:

  • 添加dsl 层面的simt inline
  • 添加vpto层面 simt inline -> pto.simt_launch + pto.simt_entry

需求参考:
mouliangyu#495
https://github.com/KurrinQu/PTOAS/blob/qkl/ptoas-persistent-simt-fragment-design/docs/designs/ptoas_persistent_simt_fragment_plan.md

  • 文档位置需要改一下(改了)
  • 带维度的检查一下是否可以传递(实现了)
  • 确认一下其他simt有无误伤(无)

@reedhecre

reedhecre commented Jul 10, 2026

Copy link
Copy Markdown

Codex Review

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

  • PR: with pto.simt(x, y, z) - Inline SIMT 实现 #927 with pto.simt(x, y, z) - Inline SIMT 实现
  • Author: and0d0
  • Base/Head: main / 486_simt_inline
  • Head SHA: e04a8dad40b4
  • Trigger: 检测到新的 open PR
  • Generated At: 2026-07-10T02:05:42Z
  • Status: failed at codex-review (exit=1)

Summary

Review failed at stage codex-review: exit=1

Findings

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

Log Tail

===== STAGE clone @ 2026-07-10 10:05:28 =====
set -euo pipefail
rm -rf '/tmp/ptoas-pr-review-monitor/runs/20260710_100527_pr927/repo'
git clone --branch 'main' --depth 50 'https://github.com/hw-native-sys/PTOAS.git' '/tmp/ptoas-pr-review-monitor/runs/20260710_100527_pr927/repo'
cd '/tmp/ptoas-pr-review-monitor/runs/20260710_100527_pr927/repo'
git fetch origin 'refs/pull/927/head:pr-927' --depth 50
git fetch origin 'main' --depth 50 || true
git checkout -f 'pr-927'
git rev-parse HEAD
git diff --stat 'origin/main...HEAD' || true
Cloning into '/tmp/ptoas-pr-review-monitor/runs/20260710_100527_pr927/repo'...
From https://github.com/hw-native-sys/PTOAS
 * [new ref]           refs/pull/927/head -> pr-927
From https://github.com/hw-native-sys/PTOAS
 * branch              main       -> FETCH_HEAD
Switched to branch 'pr-927'
e04a8dad40b4d9fdea448009e1fb0a174b9b4679
 .../user_guide/03-kernel-entry-and-subkernels.md    | 19 +++++++++++--------
 ptodsl/ptodsl/_tracing/session.py                   | 21 +++++++++++++++++++++
 ptodsl/tests/test_jit_compile.py                    | 21 +++++++++++++--------
 3 files changed, 45 insertions(+), 16 deletions(-)
===== END STAGE clone rc=0 @ 2026-07-10 10:05:33 =====

===== STAGE codex-review @ 2026-07-10 10:05:33 =====
set -euo pipefail
cd '/tmp/ptoas-pr-review-monitor/runs/20260710_100527_pr927/repo'
'codex' exec -C '/tmp/ptoas-pr-review-monitor/runs/20260710_100527_pr927/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/20260710_100527_pr927/review_schema.json' -o '/tmp/ptoas-pr-review-monitor/runs/20260710_100527_pr927/codex_last_message.json' --color never - < '/tmp/ptoas-pr-review-monitor/runs/20260710_100527_pr927/review_prompt.txt'
[monitor] stage timeout: 1800s
OpenAI Codex v0.115.0 (research preview)
--------
workdir: /tmp/ptoas-pr-review-monitor/runs/20260710_100527_pr927/repo
model: gpt-5.4
provider: codereview
approval: never
sandbox: read-only
reasoning effort: xhigh
reasoning summaries: none
session id: 019f49c5-e5e2-7b30-914e-3969d113eb40
--------
user
你现在在审查 GitHub PR。

仓库:hw-native-sys/PTOAS
PR:#927 with pto.simt(x, y, z) - Inline SIMT 实现
作者:and0d0
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 #927 存在问题,并返回 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":"INSUFFICIENT_BALANCE","message":"Insufficient account balance"}, url: https://codex.0u0o.com/responses, cf-ray: a18c0110fec0da3a-LAX, request id: 721b921c-d272-41bc-ae72-e049b530d630)
Reconnecting... 2/5 (unexpected status 403 Forbidden: {"code":"INSUFFICIENT_BALANCE","message":"Insufficient account balance"}, url: https://codex.0u0o.com/responses, cf-ray: a18c011389adae6a-LAX, request id: c96b08b2-0f62-4203-ba4c-b55a48a3ead6)
Reconnecting... 3/5 (unexpected status 403 Forbidden: {"code":"INSUFFICIENT_BALANCE","message":"Insufficient account balance"}, url: https://codex.0u0o.com/responses, cf-ray: a18c01179fdf4383-LAX, request id: fc540921-ace9-45b3-8c8d-683dd1711c9e)
Reconnecting... 4/5 (unexpected status 403 Forbidden: {"code":"INSUFFICIENT_BALANCE","message":"Insufficient account balance"}, url: https://codex.0u0o.com/responses, cf-ray: a18c011db8056f97-LAX, request id: 8f68f29c-74d8-490f-a00b-5dee452333d4)
Reconnecting... 5/5 (unexpected status 403 Forbidden: {"code":"INSUFFICIENT_BALANCE","message":"Insufficient account balance"}, url: https://codex.0u0o.com/responses, cf-ray: a18c0129e840b82d-LAS, request id: 7fa3ea0d-eb2b-4f43-885d-053345748927)
ERROR: unexpected status 403 Forbidden: {"code":"INSUFFICIENT_BALANCE","message":"Insufficient account balance"}, url: https://codex.0u0o.com/responses, cf-ray: a18c01413a4f5578-LAX, request id: 4c07e1cc-5402-4ce0-b90a-2f45210d09fa
Warning: no last agent message; wrote empty content to /tmp/ptoas-pr-review-monitor/runs/20260710_100527_pr927/codex_last_message.json
===== END STAGE codex-review rc=1 @ 2026-07-10 10:05:42 =====

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

Gemini encountered an error creating the review. You can try again by commenting /gemini review.

Comment on lines +1163 to +1166
- `with pto.simt(dim_x, dim_y, dim_z):` is a true inline SIMT scope: PTODSL
emits `pto.store_vfsimt_info` at the current location, keeps the block body in
the enclosing kernel function, and does not create an anonymous helper or
`pto.simt_launch`.

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.

这里我没明白,用户写with pto.simt(x, y, z): 的本意就是想launch一个simt函数啊,如果不发射pto.simt_launch要如何实现呢?

@and0d0
and0d0 force-pushed the 486_simt_inline branch from e04a8da to 229c5bf Compare July 15, 2026 09:47

@Zhendong404 Zhendong404 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.

重点看了 inline simt launch 这条路径,整体上我理解这个方案的核心收益是:把 SIMT outline / ABI 收口到 PTOAS,DSL 只保留 lexical region,前端会更轻,也更方便后续在 PTOAS 里统一做 SIMT 相关变换。相对地,代价是新的中间形态 pto.section.simt 需要所有相关 verifier / lowering / backend 一起跟上,否则就容易出现“前端能写、后端不能过”的分叉。

当前我看到两个比较具体的问题:

  1. emitc 路径看起来没有覆盖到这个新形态。DSL 现在会把 inline with pto.simt(): 发成 pto.section.simt,但 pto-outline-simt-sections 只接在 VPTO pipeline 里,emitc pipeline 这边没有对应处理。如果 emitc 侧也允许走到 inline simt,这里会留下未处理 IR。

  2. SIMT scope 的语义覆盖还没完全对齐。这个 PR 已经把 syncthreads/threadfence/threadfence_block 放宽到 pto.section.simt,但 keep/resume 这类 op 目前看还是只认 pto.simt_entry。也就是说 inline SIMT 如果后面要支持 keep/resume,这里还会在 outline 之前被 verifier 拒掉。

从方案角度看,我觉得“DSL 标记 region,PTOAS 做 outline”相比“DSL 直接生成 outline helper”主要是这几个 tradeoff:

  • 优势:前端职责更单一;SIMT ABI 只在 PTOAS 一处定义;后面如果要在 outline 前看 lexical 邻接关系,region 形态会更好做。
  • 劣势:管线耦合更强;所有后端和 verifier 都要认识这层新 IR;问题会更偏 pipeline integration,而不是前端本地闭合。
  • 风险:后续只要还有任何 pass / verifier / backend 默认把 pto.simt_entry 当成唯一 SIMT 作用域,就会继续出现类似漏点。

所以我对方向本身没有异议,但建议至少把 backend 覆盖边界和 section.simt 支持范围说清楚,并把剩余只认 pto.simt_entry 的点再系统扫一遍。

Comment thread tools/ptoas/ptoas.cpp
@@ -2605,6 +2530,7 @@ static void prepareVPTOForEmission(PassManager &pm) {
// backend checks catch any illegal barrier that still leaks through.
kernelModulePM.addNestedPass<func::FuncOp>(
pto::createLoweringSyncToPipePass());
kernelModulePM.addPass(pto::createPTOOutlineSIMTSectionsPass());

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.

这个outline的时机会不会太晚了,导致前面所有pass都要对没有outline的SIMT Section做适配

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