You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Extend TensorMap from a producer-only map into an outstanding-access tracker so automatic dependency generation derives write-after-read (WAR) edges for overlapping tensor regions. Pure INPUT readers must remain concurrent with each other, while a later INOUT or OUTPUT_EXISTING writer automatically waits for every overlapping live reader.
Motivation / Use Case
Issue #1306 demonstrated a deterministic correctness failure for a loop-carried buffer:
The current TensorMap records only writers, so it derives W0 -> R0 (RAW) and W0 -> W1 (WAW), but misses R0 -> W1 (WAR). W1 may overwrite buf while R0 is reading it, causing silent wrong results.
Promoting readers to INOUT serializes independent readers. Requiring explicit dependencies makes every frontend/user responsible for detecting aliasing WAR patterns. Automatic scopes should preserve correctness without losing reader concurrency.
Keep the public orchestration API unchanged and enhance TensorMap internally.
Add an access kind (READER/WRITER) to PTO2TensorMapEntry; generalize producer_task_id into the task owning the access.
After fanin calculation, register automatic-scope, non-manual_depINPUT arguments as reader entries. Continue registering INOUT and OUTPUT_EXISTING as writers.
Apply access-specific lookup rules:
INPUT:
depend on overlapping writers (RAW)
never depend on readers
register reader
INOUT:
depend on overlapping writers (RAW/WAW)
depend on overlapping readers (WAR)
retire fully covered old accesses
register writer
OUTPUT_EXISTING:
preserve existing write-only semantics for old writers
depend on overlapping readers (WAR)
retire fully covered old accesses
register writer
Reuse existing overlap and per-task cleanup semantics. A fully covering writer may remove an old access after wiring its dependency; partially overlapping entries must remain. Reader entries become stale when their task retires.
Host reads should wait only for writers. Host writes, including set_tensor_data(), should also wait for overlapping readers.
Replace output-only entry counting with access-entry counting. Re-evaluate entry-pool/bucket sizing, arena memory, pool back-pressure, bucket-chain length, and fanin spill capacity.
Keep runtime and replay behavior equivalent across a2a3 tensormap_and_ringbuffer, a2a3 host_build_graph, a5 tensormap_and_ringbuffer, and dep_gen_replay/DFX paths.
A correctness-first implementation may use one mixed chain with access-kind filtering. If reader-heavy profiling shows a significant RAW lookup regression, split reader/writer bucket indexes while sharing the entry pool.
Summary
Extend TensorMap from a producer-only map into an outstanding-access tracker so automatic dependency generation derives write-after-read (WAR) edges for overlapping tensor regions. Pure
INPUTreaders must remain concurrent with each other, while a laterINOUTorOUTPUT_EXISTINGwriter automatically waits for every overlapping live reader.Motivation / Use Case
Issue #1306 demonstrated a deterministic correctness failure for a loop-carried buffer:
The current TensorMap records only writers, so it derives
W0 -> R0(RAW) andW0 -> W1(WAW), but missesR0 -> W1(WAR).W1may overwritebufwhileR0is reading it, causing silent wrong results.Promoting readers to
INOUTserializes independent readers. Requiring explicit dependencies makes every frontend/user responsible for detecting aliasing WAR patterns. Automatic scopes should preserve correctness without losing reader concurrency.Related: #1306 and hw-native-sys/pypto#2058.
Proposed API / Behavior
Keep the public orchestration API unchanged and enhance TensorMap internally.
READER/WRITER) toPTO2TensorMapEntry; generalizeproducer_task_idinto the task owning the access.manual_depINPUTarguments as reader entries. Continue registeringINOUTandOUTPUT_EXISTINGas writers.set_tensor_data(), should also wait for overlapping readers.tensormap_and_ringbuffer, a2a3host_build_graph, a5tensormap_and_ringbuffer, anddep_gen_replay/DFX paths.A correctness-first implementation may use one mixed chain with access-kind filtering. If reader-heavy profiling shows a significant RAW lookup regression, split reader/writer bucket indexes while sharing the entry pool.
Acceptance criteria
W0(inout X) -> R0(input X) -> W1(inout X)containsR0 -> W1.set_tensor_data()waits for a pureINPUTreader of the target region.Alternatives Considered
INOUT: creates the edge but serializes readers as WAW.add_dep: precise, but omitted detection silently corrupts results.Additional Context
Relevant implementation areas:
src/{arch}/runtime/{variant}/runtime/pto_dep_compute.hsrc/{arch}/runtime/{variant}/runtime/pto_tensormap.hsrc/{arch}/runtime/{variant}/runtime/pto_orchestrator.cppsrc/{arch}/runtime/{variant}/runtime/pto_runtime2.cppsrc/{arch}/runtime/{variant}/host/dep_gen_replay.cppCurrent commit reviewed:
cddf2b6cb38e2f9bcc4739b5f888feaf33129675.