Skip to content

fix: guard co-live multi-tile slots in InsertSync - #1132

Merged
zhangstevenunity merged 3 commits into
mainfrom
codex/fix-issue-1118-multi-tile-sync
Aug 5, 2026
Merged

fix: guard co-live multi-tile slots in InsertSync#1132
zhangstevenunity merged 3 commits into
mainfrom
codex/fix-issue-1118-multi-tile-sync

Conversation

@zhangstevenunity

Copy link
Copy Markdown
Collaborator

Summary

  • Reject ambiguous multi-slot dependency groups for dynamic event IDs and conservatively fall back to one static event for the complete pipe group.
  • Stop treating slot-keyed dynamic events as whole-pipe synchronization records.
  • Add a level2 regression with two co-live multi_tile_get results consumed by one vector operation.

Root cause

Legacy InsertSync selected the first viable producer/consumer slot expression when creating a multi-event back-edge sync. It then recorded that slot-keyed event as though the complete source pipe were synchronized. With two co-live dynamic slots, this could leave the second access unguarded.

Validation

  • Built PTOASPythonPackage against LLVM 21.1.8 in WSL with -j1 (360/360 initial build; 6/6 final incremental build).
  • Ran all multi_tile_ lit tests: 26/26 passed.
  • Ran the new reproducer through the complete default code-generation pipeline successfully.
  • Verified the corrected order is a static V -> MTE2 wait, both TLOADs, TADD, then the matching static set; unambiguous single-slot cases still use dynamic event IDs.

Closes #1118

@zhangstevenunity
zhangstevenunity marked this pull request as ready for review August 5, 2026 01:26
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

zhangstevenunity and others added 2 commits August 5, 2026 10:56
PR #1132 fixed two of the three places that treat a `set_flag_dyn` /
`wait_flag_dyn` pair as whole-pipe ordering, but left
`RemoveRedundantSync::CanMatchedSync` untouched. That is now the sole
remaining suppressor: with two distinct `pto.alloc_multi_tile` regions in
one loop body the analysis correctly produces both back-edge pairs, and
redundancy removal then deletes the second one, so the second region's
tload ships with no WAR guard against the previous iteration's reader.

A slot-keyed pair rendezvouses on the event lane `slotSSAExpr % slotCount`,
so it orders only the accesses that land on that lane. Apply the rule
one-directionally: such a pair may BE covered by a whole-pipe pair, which
is strictly stronger, but may never PROVIDE coverage. Static-covers-dyn
elimination and every existing static-covers-static decision are unchanged.

Hoist the predicate into SyncCommon.h as `isLaneKeyedBackEdgeSync` and route
PR #1132`s two inlined copies through it so there is one definition.

Measured on a3/level2:
- two distinct regions: each keeps its own correctly keyed dyn pair on its
  own lane group (ids {0,1} and {2,3}); the wait and set of each pair share
  one slot expression, so the N prologue primes stay balanced.
- the same-region two-gets shape from #1132 is unchanged: still one static
  V -> MTE2 pair, and the redundant second static pair is still removed.
- event-id pressure unchanged on five_regions; the pipe_barrier(PIPE_ALL)
  exhaustion cliff is not reached any earlier.

lit: 1609 discovered, 1608 passed, 1 unsupported, 0 failed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The predicate tests `eventIdNum > 1 && slotSSAExpr`; it never checks for a
back edge, so the old name asserted a property the body does not verify.

Testing for one would also be the wrong judgement call. Slot keying is only
ever established on a back-edge dependency, which makes `GetForEndIndex()`
look like a valid stand-in -- but the synthetic prologue-prime and
epilogue-drain pairs built by SyncEventIdAllocation::UpdateBackwardMatchSync
inherit both `forEndIndex` and `eventIdNum` from the pair they derive from
while deliberately carrying no slot, and they lower to static flags. Keying
off the back edge would classify those as slot-keyed. They are created after
all three current call sites, so this is a latent trap rather than a live
defect, and the misclassification would be over-conservative rather than
unsound -- but it is exactly the kind of thing a later reader fixes back.

Name it for the property actually tested, aligned with the existing
`slotSSAExpr` / `slotCount` vocabulary, and record in the doc comment why
`slotSSAExpr` is the discriminator.

No functional change: identical emitted sync on two_regions,
two_regions_skewed and two_gets; all 27 multi_tile lit tests pass.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@zhangstevenunity

Copy link
Copy Markdown
Collaborator Author

/run a3

@reedhecre

Copy link
Copy Markdown

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

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

@reedhecre

Copy link
Copy Markdown

A3 板测完成(有跳过)

  • 触发方式:manual
  • 源码提交:4fe248964129
  • 结果汇总:OK 220 / FAIL 0 / SKIP 3
  • 日志:/home/zhongxuan/ptoas-board-monitor/runtime/logs/20260804_214219_manual_pr1132.log
  • 结果 TSV:/home/zhongxuan/ptoas-board-monitor/runtime/logs/20260804_214219_manual_pr1132.tsv
  • 手动指令:/run a3
  • 触发人:zhangstevenunity
  • 触发评论:fix: guard co-live multi-tile slots in InsertSync #1132 (comment)

@zhangstevenunity
zhangstevenunity merged commit 3c3dbd5 into main Aug 5, 2026
10 checks passed
@reedhecre

Copy link
Copy Markdown

A3 板测失败

  • 触发方式:merged
  • 源码提交:3c3dbd52319b
  • 结果汇总:OK 0 / FAIL 0 / SKIP 0
  • 日志:/home/zhongxuan/ptoas-board-monitor/runtime/logs/20260805_032146_merged_pr1132.log
  • 失败阶段:internal / fetch-source failed after 3 attempts: IncompleteRead(0 bytes read)

日志尾部

bc54076931fc
download attempt 1 failed: IncompleteRead(0 bytes read)
download attempt 2 failed: IncompleteRead(0 bytes read)
download attempt 3 failed: IncompleteRead(0 bytes read)
===== END STAGE fetch-source rc=1 @ 2026-08-05 03:29:50 =====

===== INTERNAL ERROR =====
Traceback (most recent call last):
  File "/usr/lib64/python3.10/http/client.py", line 591, in _read_chunked
    value.append(self._safe_read(chunk_left))
  File "/usr/lib64/python3.10/http/client.py", line 632, in _safe_read
    raise IncompleteRead(data, amt-len(data))
http.client.IncompleteRead: IncompleteRead(15229 bytes read, 17539 more expected)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/zhongxuan/ptoas-board-monitor/monitor.py", line 1748, in download_repo_archive
    shutil.copyfileobj(resp, out)
  File "/usr/lib64/python3.10/shutil.py", line 195, in copyfileobj
    buf = fsrc_read(length)
  File "/usr/lib64/python3.10/http/client.py", line 459, in read
    return self._read_chunked(amt)
  File "/usr/lib64/python3.10/http/client.py", line 597, in _read_chunked
    raise IncompleteRead(b''.join(value))
http.client.IncompleteRead: IncompleteRead(0 bytes read)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/zhongxuan/ptoas-board-monitor/monitor.py", line 3236, in run_once
    summary = runner.run()
  File "/home/zhongxuan/ptoas-board-monitor/monitor.py", line 2638, in run
    self.download_repo_archive()
  File "/home/zhongxuan/ptoas-board-monitor/monitor.py", line 1755, in download_repo_archive
    raise RuntimeError(f"fetch-source failed after 3 attempts: {exc}") from exc
RuntimeError: fetch-source failed after 3 attempts: IncompleteRead(0 bytes read)

@reedhecre

Copy link
Copy Markdown

A5 板测成功

  • 触发方式:merged
  • 源码提交:3c3dbd52319b
  • 结果汇总:OK 21 / FAIL 0 / SKIP 0
  • 日志:/root/ptoas-board-monitor-a5/logs/20260805_183107_merged_pr1132.log
  • 结果 TSV:/root/ptoas-board-monitor-a5/logs/20260805_183107_merged_pr1132.tsv

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.

[Pass Bug] level2 insert-sync guards only the first multi_tile_get of an iteration; a second co-live slot is left unsynchronized

2 participants