Fix: keep a newer same-run TensorMap entry when its predecessor is consumed - #1485
Conversation
…nsumed Fixes hw-native-sys#1480 `TensorMap::erase_task_outputs` erased every key unconditionally, so a consumed task's cleanup could drop a mapping that a later same-run task already owns. Two `OUTPUT` / `OUTPUT_EXISTING` writers of one key carry no edge between them — that path inserts without looking up — so the first writer can reach CONSUMED while the second is still running. Its cleanup then removed the entry pointing at the second writer, and a subsequent `INPUT` consumer looked up an empty slot, inferred no dependency, and could be dispatched before the second writer had written the buffer. `INOUT` is unaffected: it looks up before inserting, so the writers are ordered and the erase is harmless. The erase now takes the consumed slot and drops a key only while it still maps to that slot, matching how the L2 TensorMap reclaims a retired task's entries (`pto_tensormap.h::cleanup_retired`). Whether two unordered `OUTPUT` writers of one key should instead be a diagnosed error is left open. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Warning Review limit reached
Next review available in: 28 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Fixes #1480
Problem
TensorMap::erase_task_outputs(run_id, keys)erased every key unconditionally.Orchestrator::on_consumedcalls it with the consumed task'soutput_keys, sothe cleanup could drop a mapping that a later task in the same run already
owns.
Two
OUTPUT/OUTPUT_EXISTINGwriters of one key carry no edge between them —that path inserts without looking up — so the first can reach
CONSUMEDwhilethe second is still running:
OUTPUTK →insert(run, K, A)OUTPUTK →insert(run, K, B)(overwrites; A and B unordered)erase_task_outputs(run, [K])removes the entry pointing at BINPUTK →lookupreturnsINVALID_SLOT→ no dependency on BC can then be dispatched and read K before B has written it.
INOUTis unaffected: it looks up before inserting, so B depends on A and Acannot reach
CONSUMEDuntil B has released its reference.Fix
erase_task_outputstakes the consumed slot and drops a key only while it stillmaps to that slot. This mirrors how the L2 TensorMap reclaims a retired task's
entries —
pto_tensormap.h::cleanup_retired, "Only remove if this entry belongsto the retiring task (slot may have been reused by a newer task)".
Tests
OrchestratorFixture.ConsumingASupersededProducerKeepsTheNewerMapping— theend-to-end repro. Verified failing on the pre-fix code: C came back with
fanin_producers.size() == 0andfanin_count == 0.TensorMap.EraseKeepsNewerSameRunProducer— same-run WAW at the map level,alongside the existing cross-run isolation test. Also asserts the owning
slot's erase still removes the entry.
Existing
erase_task_outputscall sites intest_tensormap.cpptake the ownerslot argument.
Verification
ctest --test-dir tests/ut/cpp/build -LE requires_hardware— 60/60 passedpytest tests/ut/py— 824 passed, 2 skippedpytest tests/st/worker --platform a2a3sim --device 0-3(level-3 collectives,the hierarchical orchestrator's ST coverage) — 18/18 passed
pre-commit runon the touched files — all hooks passHost-only change; no hardware run required.
Left open
Whether two unordered
OUTPUTwriters of one key should be a diagnosed errorrather than a silently unordered WAW — raised in the issue, deliberately not
decided here.
🤖 Generated with Claude Code