Fix: cleanup_retired frees only the retiring task's entries (a2a3 + a5) - #1511
Fix: cleanup_retired frees only the retiring task's entries (a2a3 + a5)#1511yanghaoran29 wants to merge 1 commit into
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThe change selectively cleans retired tensor-map entries by producer task, adds slot-reuse coverage for A2A3 and A5, and documents A5 cross-cluster ChangesA5 last_task_alive cleanup
Estimated code review effort: 3 (Moderate) | ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/investigations/2026-07-a5-last-task-alive-cross-cluster.md`:
- Line 1: Update the document title to remove the stale “待上机测量” wording, while
preserving the existing A5 cross-cluster last_task_alive optimization plan and
its completed measurement and B/C decision details.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: c97bc815-840d-407a-957b-d594169286a2
📒 Files selected for processing (6)
docs/investigations/2026-07-a5-last-task-alive-cross-cluster.mddocs/investigations/README.mdsrc/a2a3/runtime/tensormap_and_ringbuffer/runtime/pto_tensormap.hsrc/a5/runtime/tensormap_and_ringbuffer/runtime/pto_tensormap.htests/ut/cpp/a2a3/test_tensormap.cpptests/ut/cpp/a5/test_tensormap.cpp
5997fde to
ac38165
Compare
cleanup_retired walked a slot's whole task_entry_head chain and freed every entry, assuming — only via a debug_assert, which compiles out in release — that the chain belonged to one task. When cleanup lagged ring advancement, a reused slot's chain mixed entries from a later, still-live task, and those were freed too: silent tensormap corruption in release builds. Free only entries whose producer_task_id matches the retiring local_id, unlinking each from the task chain; entries from other tasks stay linked. Applied to both a2a3 and a5 tensormap_and_ringbuffer. - Add CleanupRetiredSparesLaterTaskReusingSlot unit test (a2a3 + a5) as the regression barrier; both test_tensormap suites pass (33 each), a2a3sim/a5sim runtimes rebuild clean, a5sim mixed_example passes. - Onboard before/after (a5, spmd_multiblock_mix, 100 rounds, task-submit device 0): Device/Effective/Orch/Sched all within +-2% — no regression, as expected for a correctness fix that is a no-op on the common path. Extracted from hw-native-sys#906.
760db31 to
bae4564
Compare
来自 #906 的相关原文(对照)本 PR 从 #906 的调查中抽出;#906 的
|
Selective free in
cleanup_retired(extracted from #906)Bug. When
cleanup_retired(pto_tensormap.h, a2a3 + a5) retires alocal_id, it frees the slot's entire task-entry chain. But when a slot isreused by a later task and cleanup lags behind ring advancement, that chain
also holds entries from a still-live task (
link_entryonly resets thechain head on the first touch of a slot per run epoch, not on slot reuse).
Cleanup therefore frees the live entries too; the only guard was a
debug_assert, which compiles out in release → silent tensormap corruption.Fix. Free only entries whose
producer_task_id == retired_task, unlinkingeach from the task chain (
prev_in_task/next_in_task) and fixing up thehead pointer as it goes; entries from other tasks stay linked. No change to the
reclaim_retired_all/sync_tensormapcall contract. Applied to both a2a3and a5.
Regression barrier. Add
CleanupRetiredSparesLaterTaskReusingSlot(
tests/ut/cpp/{a2a3,a5}/test_tensormap.cpp): task 0 and task 0+WINDOW share aslot; after retiring task 0, asserts task 0+WINDOW's entry survives. Before the
fix this throws
AssertionErrorin debug and silently frees in release → fail;after the fix it passes. Both suites green (33 cases each).
Onboard before/after (a5,
task-submitdevice 0, 100 rounds, one run each):Sample:
paged_attention_unroll/Case1All |Δ| < 2%, mixed signs → within noise: no regression, no gain, consistent
with this being a correctness fix that is a no-op on the common path.
Extracted from #906.