Skip to content

feat: fixpipe tpipe design#883

Open
HecreReed wants to merge 2 commits into
hw-native-sys:mainfrom
HecreReed:codex/fixpipe-tpipe-design-draft
Open

feat: fixpipe tpipe design#883
HecreReed wants to merge 2 commits into
hw-native-sys:mainfrom
HecreReed:codex/fixpipe-tpipe-design-draft

Conversation

@HecreReed

Copy link
Copy Markdown
Collaborator

Summary

  • add a design draft for tpipe support of fixpipe-style TPUSH
  • document why PTOAS should model fixpipe config per pipe instead of per tpush
  • scope the first implementation cut to C2V + Acc producer + no-split, with vector quant included

Notes

  • docs-only change, no code changes in this PR
  • the draft compares current pto-isa TPUSH/TPOP/FixpipeParams semantics with PTOAS frontend pipe IR
  • the design recommends lowering pipe-level config into TPUSH<Pipe, TileProd, TConfig> during EmitC

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@reedhecre

reedhecre commented Jun 30, 2026

Copy link
Copy Markdown

Codex Review

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

  • PR: feat: fixpipe tpipe design #883 feat: fixpipe tpipe design
  • Author: HecreReed
  • Base/Head: main / codex/fixpipe-tpipe-design-draft
  • Head SHA: 2418a9abe833
  • Trigger: PR 有新提交
  • Generated At: 2026-07-06T01:46:25Z
  • Previous Head SHA: 8d733c6457f9
  • Status: failed at codex-review (exit=1)

Summary

Review failed at stage codex-review: exit=1

Findings

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

Log Tail

 .../fixpipe_frontend_verify_additional_invalid.pto |  410 +++++
 ...fixpipe_frontend_verify_contract_invalid_a5.pto |  301 ++++
 ...rontend_verify_hidden_fixpipe_attrs_invalid.pto |  147 ++
 ...ontend_verify_missing_peer_consumer_init_a5.pto |   43 +
 ...frontend_verify_missing_set_quant_scalar_a5.pto |   62 +
 ...frontend_verify_missing_set_quant_vector_a5.pto |   62 +
 .../fixpipe_frontend_verify_missing_tpop_a5.pto    |   55 +
 ...frontend_verify_no_convert_type_mismatch_a5.pto |   62 +
 ...verify_no_convert_type_mismatch_cross_id_a5.pto |   62 +
 .../pto/fixpipe_frontend_verify_non_a5_gating.pto  |   63 +
 ...pipe_frontend_verify_quant_state_binding_a5.pto |  352 +++++
 ...ipe_frontend_verify_req8_vec_ui8_invalid_a5.pto |   59 +
 ...verify_set_quant_vector_bad_payload_type_a5.pto |   62 +
 ...pipe_frontend_verify_slot_size_too_small_a5.pto |  113 ++
 ...ixpipe_frontend_verify_split_ops_invalid_a5.pto |  223 +++
 .../fixpipe_frontend_verify_src_type_invalid.pto   |  435 ++++++
 ...xpipe_frontend_verify_tpop_split_invalid_a5.pto |   58 +
 ...ipe_frontend_verify_untraceable_peer_buf_a5.pto |   62 +
 test/lit/pto/fixpipe_invalid_dir_mask.pto          |   32 +
 test/lit/pto/fixpipe_invalid_dir_mask_both.pto     |   29 +
 50 files changed, 8411 insertions(+), 33 deletions(-)
===== END STAGE clone rc=0 @ 2026-07-06 09:46:16 =====

===== STAGE codex-review @ 2026-07-06 09:46:16 =====
set -euo pipefail
cd '/tmp/ptoas-pr-review-monitor/runs/20260706_094526_pr883/repo'
'codex' exec -C '/tmp/ptoas-pr-review-monitor/runs/20260706_094526_pr883/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/20260706_094526_pr883/review_schema.json' -o '/tmp/ptoas-pr-review-monitor/runs/20260706_094526_pr883/codex_last_message.json' --color never - < '/tmp/ptoas-pr-review-monitor/runs/20260706_094526_pr883/review_prompt.txt'
[monitor] stage timeout: 1800s
OpenAI Codex v0.115.0 (research preview)
--------
workdir: /tmp/ptoas-pr-review-monitor/runs/20260706_094526_pr883/repo
model: gpt-5.4
provider: codereview
approval: never
sandbox: read-only
reasoning effort: xhigh
reasoning summaries: none
session id: 019f351a-d10b-7611-b56b-933e39f93093
--------
user
你现在在审查 GitHub PR。

仓库:hw-native-sys/PTOAS
PR:#883 feat: fixpipe tpipe design
作者:HecreReed
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 #883 存在问题,并返回 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: a16aef56f8872163-LAX, request id: 96009c63-2871-448d-bfc7-1000eb0972e4)
Reconnecting... 2/5 (unexpected status 403 Forbidden: {"code":"INSUFFICIENT_BALANCE","message":"Insufficient account balance"}, url: https://codex.0u0o.com/responses, cf-ray: a16aef598dd4c8c1-LAX, request id: a095867e-212d-4f71-9b02-2d690e7f7151)
Reconnecting... 3/5 (unexpected status 403 Forbidden: {"code":"INSUFFICIENT_BALANCE","message":"Insufficient account balance"}, url: https://codex.0u0o.com/responses, cf-ray: a16aef5d7cec2bab-LAX, request id: 0e191294-9682-4837-b694-327ba8437227)
Reconnecting... 4/5 (unexpected status 403 Forbidden: {"code":"INSUFFICIENT_BALANCE","message":"Insufficient account balance"}, url: https://codex.0u0o.com/responses, cf-ray: a16aef63bc684f0f-LAS, request id: d42df840-a123-4a6a-9d49-f7019d5f0f95)
Reconnecting... 5/5 (unexpected status 403 Forbidden: {"code":"INSUFFICIENT_BALANCE","message":"Insufficient account balance"}, url: https://codex.0u0o.com/responses, cf-ray: a16aef6e989b2f68-LAX, request id: 03ff9448-fe41-4e3e-be81-388099839b4e)
ERROR: unexpected status 403 Forbidden: {"code":"INSUFFICIENT_BALANCE","message":"Insufficient account balance"}, url: https://codex.0u0o.com/responses, cf-ray: a16aef839c80c69d-LAX, request id: 27528997-b909-46af-8caf-3f00f8d6bcbf
Warning: no last agent message; wrote empty content to /tmp/ptoas-pr-review-monitor/runs/20260706_094526_pr883/codex_last_message.json
===== END STAGE codex-review rc=1 @ 2026-07-06 09:46:25 =====

@HecreReed HecreReed force-pushed the codex/fixpipe-tpipe-design-draft branch 10 times, most recently from 57383b6 to 85f7319 Compare July 1, 2026 02:07
@HecreReed HecreReed marked this pull request as ready for review July 1, 2026 02:45
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 85f7319d98

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

推荐把 fixpipe 配置挂到 `initialize_pipe`:

```mlir
pto.aic_initialize_pipe {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Mirror the fixpipe contract on the consumer init

In the current frontend pipe flow, each data op resolves its id against an initialize_pipe in the same function, so a Vector-side tpop_from_aic will only see the peer function's aiv_initialize_pipe, not this Cube-side init. If the fixpipe attrs are only shown/defined on pto.aic_initialize_pipe, verifier rules that check the consumer result type/layout and any consumer lowering have no local pipe-level contract unless a new cross-function propagation path is designed. Please require the peer aiv_initialize_pipe to carry the same attrs (and verify equality), or document the cross-function lookup explicitly.

Useful? React with 👍 / 👎.

Comment thread docs/designs/fixpipe-tpipe-design.md Outdated
@HecreReed HecreReed force-pushed the codex/fixpipe-tpipe-design-draft branch from 85f7319 to 9a54ecb Compare July 1, 2026 03:17
@HecreReed

Copy link
Copy Markdown
Collaborator Author

/run a3 rope_kv_cache

@HecreReed

Copy link
Copy Markdown
Collaborator Author

/run a5 rope_kv_cache

@reedhecre

Copy link
Copy Markdown

已接收 /run a5 rope_kv_cache,A5 板测器会处理这条请求。

页面会自动刷新,可以直接看当前阶段、排队情况和最近结果。

@reedhecre

Copy link
Copy Markdown

A5 板测成功

  • 触发方式:manual
  • 源码提交:abb5b4638c31
  • 结果汇总:OK 1 / FAIL 0 / SKIP 0
  • 日志:/root/ptoas-board-monitor-a5/logs/20260701_153506_manual_pr883.log
  • 结果 TSV:/root/ptoas-board-monitor-a5/logs/20260701_153506_manual_pr883.tsv
  • 手动指令:/run a5 rope_kv_cache
  • 触发人:HecreReed
  • 指定用例:rope_kv_cache
  • 触发评论:feat: fixpipe tpipe design #883 (comment)

@HecreReed HecreReed force-pushed the codex/fixpipe-tpipe-design-draft branch from 9a54ecb to 11c96f4 Compare July 1, 2026 07:48
@reedhecre

Copy link
Copy Markdown

已接收 /run a3 rope_kv_cache,A3 板测器会处理这条请求。

页面会自动刷新,可以直接看当前阶段、排队情况和最近结果。

@reedhecre

Copy link
Copy Markdown

A3 板测成功

  • 触发方式:manual
  • 源码提交:5e9fc35cd34d
  • 结果汇总:OK 1 / FAIL 0 / SKIP 0
  • 日志:/home/zhongxuan/ptoas-board-monitor/runtime/logs/20260701_155420_manual_pr883.log
  • LLVM cache:/home/zhongxuan/ptoas-board-monitor/cache/llvm-project-vpto-feature/build-shared
  • 结果 TSV:/home/zhongxuan/ptoas-board-monitor/runtime/logs/20260701_155420_manual_pr883.tsv
  • 手动指令:/run a3 rope_kv_cache
  • 触发人:HecreReed
  • 指定用例:rope_kv_cache
  • 触发评论:feat: fixpipe tpipe design #883 (comment)

@HecreReed HecreReed force-pushed the codex/fixpipe-tpipe-design-draft branch 7 times, most recently from 88a1fe2 to 7662777 Compare July 2, 2026 04:44
@HecreReed HecreReed force-pushed the codex/fixpipe-tpipe-design-draft branch 23 times, most recently from 3fb3eea to 6999392 Compare July 4, 2026 14:23
@HecreReed HecreReed force-pushed the codex/fixpipe-tpipe-design-draft branch from 6999392 to 8d733c6 Compare July 4, 2026 14:59
@HecreReed

Copy link
Copy Markdown
Collaborator Author

/run a3

@reedhecre

Copy link
Copy Markdown

已接收 /run a3,A3 板测器会处理这条请求。

页面会自动刷新,可以直接看当前阶段、排队情况和最近结果。

@reedhecre

Copy link
Copy Markdown

A3 板测完成(有跳过)

  • 触发方式:manual
  • 源码提交:87a8f13de276
  • 结果汇总:OK 220 / FAIL 0 / SKIP 2
  • 日志:/home/zhongxuan/ptoas-board-monitor/runtime/logs/20260706_100609_manual_pr883.log
  • LLVM cache:/home/zhongxuan/ptoas-board-monitor/cache/llvm-project-vpto-llvm21/build-shared
  • 结果 TSV:/home/zhongxuan/ptoas-board-monitor/runtime/logs/20260706_100609_manual_pr883.tsv
  • 手动指令:/run a3
  • 触发人:HecreReed
  • 触发评论:feat: fixpipe tpipe design #883 (comment)

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

Review: fixpipe-over-tpipe implementation (full cross-layer)

Reviewed head 2418a9ab end to end — ODS (PTOAttrs.td/PTOOps.td), verifiers (PTO.cpp), frontend lowering, EmitC, manual, and the ~40 lit tests — cross-checked against the local pto-isa source. Overall this is a high-quality, faithful implementation; the design-doc iterations landed cleanly in code. Verified in particular:

  • EmitC symbolic mapping is correct (getFixpipeLayoutToken/getFixpipeQuantToken/getFixpipeReluToken): explicit symbol switches, never an ordinal cast. This matters because the new dedicated PTO_FixpipeLayoutEnum ordinals (NZ2ND=0/NZ2DN=1/NZ2NZ=2) do not match pto-isa LayoutMode_t (NZ2NZ=0/NZ2ND=1/NZ2DN=2) — an integer cast would have silently mapped nz2nd→NZ2NZ. Good.
  • Type/layout/signedness helpers are faithful to pto-isa FixpipeConsDType_t and to the design's src-type table, including the scalar-8bit si8/ui8 vs vector-8bit si8-only split (correct — SET_QUANT_VECTOR has no <OutType> channel, unlike SET_QUANT_SCALAR<OutType>).
  • A5 gating is enforced (verifyFrontendInitCommon): qs322bf16_pre_* and qf322hif8/fp8 are rejected on non-A5.
  • Effects modeling is complete (rule 18): set_quant_* Write an id-partitioned FixpipeQuantStateResource; TPushOp/TPushToAivOp Read it — establishing the ordering dependency.
  • si8/ui8 carrier is real MLIR unsigned/signed IntegerType (getEmitCScalarTypeToken keys on signedness; manual updated accordingly).
  • Frontend lowering propagates acc_push_epilogue + the peer-key attrs symmetrically; the PTOResolveReservedBuffers relaxation to allow different local ids per peer is correct.

CI: build-and-test passes (all lit tests green). No blockers on the mechanical correctness.

One latent correctness issue worth fixing before the vector-quant reuse path is relied on, plus a coverage gap that lets it hide — details inline. Summary:

1. (P2, latent silent-miscompile) Scaling-tile liveness gap under vector-quant rematerialization. See inline on PTOPlanMemory.cpp. MemLivenessAnalysis sees the scaling tile's live range end at the original set_quant_vector, but EmitC rematerializes SET_QUANT_VECTOR(%fp) before every later reusing fixpipe TPUSH (the "bind once, reuse" pattern the design allows and vector_remat_a5.pto tests). SCALING is a normally-reused planned space, so under buffer pressure the tile's slot can be reused in the gap → the rematerialized SET_QUANT_VECTOR reads clobbered scaling data → silent wrong quant. Scalar reuse is safe (the payload is an f32 SSA value, not planned memory). I reached this by static analysis, not an executed repro — would appreciate a buffer-pressure A5 sim case to confirm/refute.

2. (coverage) Fixpipe has no executed validation. vpto-sim-validation and remote-npu-validation are skipped, and the A3 board run (OK 220) exercises the existing sample suite, not the new fixpipe lit files (FileCheck-only: IR verify + EmitC text match). So the A5-only modes and the whole EmitC/rematerialize/plan-memory interaction are validated only as text — exactly where finding #1 hides. Recommend at least one A5 sim/board run of a vector-quant fixpipe kernel with real buffer pressure.

3. (robustness, non-blocking) Peer-contract verification runs inside AivInitializePipeOp::verify() with moduleOp.walk() — see inline. Also verifyFixpipeConsumerType (from TPopFromAicOp::verify) duplicates the consumer element/layout checks AivInitializePipeOp::verify already does; both walk all tpops.

4. (minor) EmitC rematerializeFixpipeQuantBindings hard-fails the whole pass if peer resolution fails at EmitC time (resolveFixpipeConsumerTileTypefindPeerFixpipeConsumerInit). It fails loudly, but it re-resolves the peer at codegen time rather than stashing the resolved consumer OutType during the earlier verified peer pass.

Design direction and the bulk of the implementation are solid — the substance is #1 (guard the vector-quant reuse liveness) and #2 (get one execution behind it).

UpdateOpGenInfo(curOpInfo, llvm::to_vector(callOp->getOperands()));
OpKillHandle(curOpInfo, live, op->getBlock());
} else if (isa<pto::TAllocOp, pto::TPushOp, pto::TFreeOp,
pto::SetQuantScalarOp, pto::SetQuantVectorOp,

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.

Adding set_quant_scalar/set_quant_vector here marks their operands live only at the original op position — but that isn't sufficient for the vector case once EmitC rematerializes.

rematerializeFixpipeQuantBindings (PTOToEmitC.cpp) erases the original set_quant_vector and clones SET_QUANT_VECTOR(%scaling_tile) before every later fixpipe TPUSH that reuses the same-id binding — the "bind once, reuse" pattern the design allows and that test/lit/pto/fixpipe_frontend_emitc_vector_remat_a5.pto exercises:

set_quant_vector(%fp0){id=0}
tpush{id=0}
set_quant_vector(%fp1){id=1}
tpush{id=1}
tpush{id=0}            // EmitC re-emits SET_QUANT_VECTOR(%fp0) here (CHECK line ~118)

In the IR, %fp0's only use is the original set_quant_vector. So MemLivenessAnalysis sees %fp0 dead after that op — including across the gap up to the 3rd tpush. SCALING is a normally-reused planned space (PTOPlanMemory.cpp:1752 goes through the same allocator as VEC/ACC, no pinning), so under buffer pressure another scaling tile can be assigned %fp0's slot in that gap. Then the rematerialized SET_QUANT_VECTOR(%fp0) before the 3rd tpush reads clobbered scaling data → silent wrong quantization.

The vector_remat_a5 test doesn't catch it: %fp0/%fp1 have overlapping original live ranges so they don't share a slot, there's no third scaling tile to force reuse, it's FileCheck-only, and vpto-sim-validation is skipped — so no execution ever runs the planner under pressure here.

Scalar reuse is safe: the payload is an f32 SSA value, not planned memory, and clones dominate.

Fix options:

  • Extend the scaling tile's live range to the last reusing fixpipe TPUSH (treat those TPUSHes as pseudo-uses of the set_quant_vector operand in liveness), or
  • Run the rematerialization before PlanMemory so the re-reads are real IR uses visible to liveness, or
  • For v1, forbid vector-quant binding reuse across a gap — require an explicit set_quant_vector immediately before each vector-quant TPUSH (scalar can still reuse).

I got here by static analysis, not an executed repro — a buffer-pressure A5 sim case would confirm.

Comment thread lib/PTO/IR/PTO.cpp

ImportReservedBufferOp matchedImport;
unsigned matchedImportCount = 0;
moduleOp.walk([&](ImportReservedBufferOp candidateImport) {

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.

This peer-contract verification does a full moduleOp.walk() (plus lookupPeerFuncAcrossContainer and further walks of the peer function) from inside verify(). Two concerns:

  • Cost/robustness: op verifiers run on every verification (after parse and, in expensive-checks builds, after every pass). Walking the whole module from each fixpipe aiv_initialize_pipe is O(inits x module size) each time. This is generally discouraged for op verifiers, which are expected to be local.
  • The design doc (§9.1) itself frames peer-contract checking as a step done "while the frontend init is still visible" — which reads more like a dedicated verification pass than an op verifier. A pass would run once at a well-defined point, avoid the repeated full-module walks, and give clearer ordering guarantees.

Not a correctness blocker (parse-time verification does see the whole module), but consider moving the cross-function peer-contract resolution into a dedicated verification/prepare pass.

Separately: verifyFixpipeConsumerType (called from TPopFromAicOp::verify) re-derives and re-checks the consumer element type + layout that this init verifier already checks, and both walk all tpop_from_aic for the id. Worth consolidating so the two can't drift.

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