Skip to content

fix tfillpad#939

Open
Likai-19 wants to merge 1 commit into
hw-native-sys:mainfrom
Likai-19:bugfix_tfillpad
Open

fix tfillpad#939
Likai-19 wants to merge 1 commit into
hw-native-sys:mainfrom
Likai-19:bugfix_tfillpad

Conversation

@Likai-19

Copy link
Copy Markdown

No description provided.

@reedhecre

reedhecre commented Jul 14, 2026

Copy link
Copy Markdown

Codex Review

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

  • PR: fix tfillpad #939 fix tfillpad
  • Author: Likai-19
  • Base/Head: main / bugfix_tfillpad
  • Head SHA: 70331db7cbc5
  • Trigger: 检测到新的 open PR
  • Generated At: 2026-07-14T13:55:52Z
  • 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-14 21:55:34 =====
set -euo pipefail
rm -rf '/tmp/ptoas-pr-review-monitor/runs/20260714_215533_pr939/repo'
git clone --branch 'main' --depth 50 'https://github.com/hw-native-sys/PTOAS.git' '/tmp/ptoas-pr-review-monitor/runs/20260714_215533_pr939/repo'
cd '/tmp/ptoas-pr-review-monitor/runs/20260714_215533_pr939/repo'
git fetch origin 'refs/pull/939/head:pr-939' --depth 50
git fetch origin 'main' --depth 50 || true
git checkout -f 'pr-939'
git rev-parse HEAD
git diff --stat 'origin/main...HEAD' || true
Cloning into '/tmp/ptoas-pr-review-monitor/runs/20260714_215533_pr939/repo'...
From https://github.com/hw-native-sys/PTOAS
 * [new ref]           refs/pull/939/head -> pr-939
From https://github.com/hw-native-sys/PTOAS
 * branch              main       -> FETCH_HEAD
Switched to branch 'pr-939'
70331db7cbc5615d1cccfebbd8a1076317b8dbbf
 lib/TileOps/tfillpad_expand_template.py | 31 ++++++++++++++++---------------
 lib/TileOps/tfillpad_template.py        | 31 ++++++++++++++++---------------
 2 files changed, 32 insertions(+), 30 deletions(-)
===== END STAGE clone rc=0 @ 2026-07-14 21:55:43 =====

===== STAGE codex-review @ 2026-07-14 21:55:43 =====
set -euo pipefail
cd '/tmp/ptoas-pr-review-monitor/runs/20260714_215533_pr939/repo'
'codex' exec -C '/tmp/ptoas-pr-review-monitor/runs/20260714_215533_pr939/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/20260714_215533_pr939/review_schema.json' -o '/tmp/ptoas-pr-review-monitor/runs/20260714_215533_pr939/codex_last_message.json' --color never - < '/tmp/ptoas-pr-review-monitor/runs/20260714_215533_pr939/review_prompt.txt'
[monitor] stage timeout: 1800s
OpenAI Codex v0.115.0 (research preview)
--------
workdir: /tmp/ptoas-pr-review-monitor/runs/20260714_215533_pr939/repo
model: gpt-5.4
provider: codereview
approval: never
sandbox: read-only
reasoning effort: xhigh
reasoning summaries: none
session id: 019f60e9-831d-7992-af53-ee32dc19d0d7
--------
user
你现在在审查 GitHub PR。

仓库:hw-native-sys/PTOAS
PR:#939 fix tfillpad
作者:Likai-19
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 #939 存在问题,并返回 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: a1b106db1e8a36e7-LAX, request id: 54f92d26-01d7-4807-adfa-3b1c18cd4729)
Reconnecting... 2/5 (unexpected status 403 Forbidden: {"code":"INSUFFICIENT_BALANCE","message":"Insufficient account balance"}, url: https://codex.0u0o.com/responses, cf-ray: a1b106de5c7c50a9-LAX, request id: c8817f0f-5950-4b4a-adab-e03c936b0e2c)
Reconnecting... 3/5 (unexpected status 403 Forbidden: {"code":"INSUFFICIENT_BALANCE","message":"Insufficient account balance"}, url: https://codex.0u0o.com/responses, cf-ray: a1b106e45d1e3f37-LAX, request id: cabfa4d9-4bd2-43fd-adac-e3207f57e50b)
Reconnecting... 4/5 (unexpected status 403 Forbidden: {"code":"INSUFFICIENT_BALANCE","message":"Insufficient account balance"}, url: https://codex.0u0o.com/responses, cf-ray: a1b106eb6f7dcba2-LAX, request id: 03ef7d87-5b1c-4c04-a377-b38537056c12)
Reconnecting... 5/5 (unexpected status 403 Forbidden: {"code":"INSUFFICIENT_BALANCE","message":"Insufficient account balance"}, url: https://codex.0u0o.com/responses, cf-ray: a1b106f7be41e9e3-LAX, request id: 895d0b47-2cd2-436f-8cbb-0d029047ecf8)
ERROR: unexpected status 403 Forbidden: {"code":"INSUFFICIENT_BALANCE","message":"Insufficient account balance"}, url: https://codex.0u0o.com/responses, cf-ray: a1b1070bcc1c2d61-LAX, request id: 201e3b0b-b2ce-4d80-b3ce-421a3530be4e
Warning: no last agent message; wrote empty content to /tmp/ptoas-pr-review-monitor/runs/20260714_215533_pr939/codex_last_message.json
===== END STAGE codex-review rc=1 @ 2026-07-14 21:55:52 =====

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request adds a safety check if aligned_col > 0 before copying aligned valid blocks in Phase 1 of both tfillpad_expand_template.py and tfillpad_template.py. The reviewer identified high-severity correctness issues in both templates where uninitialized memory or garbage values can remain in the destination tile when src_valid_rows < dst_valid_rows. This is because the expansion rows are not fully filled with the fill_scalar, and the reviewer provided actionable code suggestions to correct the loop bounds and row expansion logic.

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 +143 to 144
if aligned_col < dst_valid_cols:
for row in range(0, dst_valid_rows, 1):

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.

high

High Severity Correctness Issue

Issue: Potential uninitialized memory/garbage values in the destination tile when src_valid_rows < dst_valid_rows.

Explanation:
If src_valid_rows < dst_valid_rows (i.e., the destination has more valid rows than the source), the rows from src_valid_rows to dst_valid_rows are part of the expansion region and must be fully filled with fill_scalar.

However:

  1. Phase 1 and Phase 3 (copying valid blocks and tail) only loop up to src_valid_rows.
  2. Phase 2 (filling column padding) loops up to dst_valid_rows, but it only fills columns from aligned_col to dst_valid_cols.
  3. Phase 4 (filling row expansion) only runs if src_rows < dst_rows (physical shapes differ), and even then, it only fills from src_rows to dst_rows.

As a result, for any row in range(src_valid_rows, min(src_rows, dst_valid_rows)), the columns from 0 to aligned_col are never filled or copied, leaving them with uninitialized/garbage values.

Suggested Fix:

  1. Change Phase 2 to only loop up to src_valid_rows (since the remaining rows will be fully filled by Phase 4).
  2. Change Phase 4 to fill the entire row expansion from src_valid_rows to dst_rows for all columns from 0 to dst_valid_cols:
    # Phase 4: Fill row expansion
    if pto.constexpr(src_valid_rows < dst_rows):
        for row in range(src_valid_rows, dst_rows, 1):
            remained = dst_valid_cols
            for col in range(0, dst_valid_cols, lanes):
                mask, remained = pto.make_mask(dtype, remained)
                vec = pto.vdup(fill_scalar, mask)
                pto.vsts(vec, dst[row, col:], mask)
Suggested change
if aligned_col < dst_valid_cols:
for row in range(0, dst_valid_rows, 1):
if aligned_col < dst_valid_cols:
for row in range(0, src_valid_rows, 1):


# Phase 2: Fill cols from aligned_col to dst_cols-1
if aligned_col < dst_cols:
if aligned_col < dst_cols:

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.

high

High Severity Correctness Issue

Issue: Potential uninitialized memory/garbage values in the destination tile when src_valid_rows < dst_valid_rows.

Explanation:
In tfillpad_template.py, if src_valid_rows < dst_valid_rows (i.e., the destination has more valid rows than the source), the rows from src_valid_rows to dst_valid_rows are part of the expansion region and must be fully filled with fill_scalar.

However:

  1. Phase 1 and Phase 3 (copying valid blocks and tail) only loop up to src_valid_rows.
  2. Phase 2 (filling column padding) only loops up to src_valid_rows.
  3. Phase 4 (filling row expansion) only runs if src_rows < dst_rows. Since tfillpad requires src.shape == dst.shape (same physical size), src_rows < dst_rows is always False, so Phase 4 never runs.

As a result, any rows from src_valid_rows to dst_rows are never filled or copied, leaving them with uninitialized/garbage values.

Suggested Fix:
Change Phase 4 to fill the entire row expansion from src_valid_rows to dst_rows for all columns from 0 to dst_cols:

    # Phase 4: Fill row expansion
    if pto.constexpr(src_valid_rows < dst_rows):
        for row in range(src_valid_rows, dst_rows, 1):
            remained = dst_cols
            for col in range(0, dst_cols, lanes):
                mask, remained = pto.make_mask(dtype, remained)
                vec = pto.vdup(fill_scalar, mask)
                pto.vsts(vec, dst[row, col:], mask)

@Likai-19

Copy link
Copy Markdown
Author

Fixes #940

fill_scalar = pto.f32(_NEG1_F32)
else:
fill_scalar = pto.f32(0.0)
if pto.constexpr(dtype == pto.f32):

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.

现在TileLib已经切到PTODSL框架了,旧的TileLib不再使用,请直接更新到新的TileLib库:ptodsl/ptodsl/tilelib

else:
fill_scalar = pto.f32(0.0)
if pto.constexpr(dtype == pto.f32):
if pto.constexpr(dst.pad_value == pto.PadValue.ZERO):

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.

PTODSL中对应的语法是pto.const_expr,请一并修改

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