fix(store): propagate phase for phased accumulators - #2396
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:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (13)
Included review availability: Your plan includes up to 2 reviews per rolling hour; 1 remains after this review. 📝 WalkthroughWalkthrough
ChangesTile Store Phase Protocol
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to The change adds phased accumulator-store handling while preserving default store behavior, with matching producer and final-store phases and extensive validation. No actionable merge-blocking risk remains beyond normal checks and review. Sequence Diagram(s)sequenceDiagram
participant LanguageTileStore
participant TileStoreIR
participant PTOStoreEmitter
LanguageTileStore->>TileStoreIR: forward st_phase
TileStoreIR->>TileStoreIR: validate st_phase
TileStoreIR->>PTOStoreEmitter: provide validated attributes
PTOStoreEmitter->>PTOStoreEmitter: emit stPhase and atomicType
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 |
- replace string phase arguments with typed AccPhase/STPhase enums - keep verifier, codegen, printer, docs, and tests synchronized
Summary
How it was found
This bug was exposed while investigating repeated
system-tests-directfailures on the unrelated reciprocal-precision PR #2376. That PR did not change GEMV,tile.store, the runtime, or the failing test; it only caused the full device suite to run. The first genuine failure repeatedly occurred inTestGemvAcc::test_tile_gemv_acc_partial_final_phasesas a schedulerS1:running-stalledtimeout, while later failures were cascades after the shared device runner became unusable.The device shard executes up to 64 compiled artifacts in one hot process and reuses one
ChipWorker. This made the existing cross-invocation unit-flag leak observable: an individual final-phase GEMV could return the correct value and pass, yet leave state that stalled a later phased GEMV on the same worker. Repeated failures on different runners, together with clean-main/control passes and the lack of any GEMV path in the #2376 diff, isolated the issue from the reciprocal change.Root cause
On the A2/A3 phase-aware path, a final accumulator producer performs producer-side check-and-set. PyPTO then emitted a plain
pto.tstore, becausepl.storehad no way to forward a store phase and does not inherit the producer phase from its input. The consumer therefore did not perform the matching check-and-clear operation. When the worker was reused, the uncleared unit flag could leave a later phased GEMV waiting indefinitely.Before this change:
Fix
pl.AccPhaseandpl.STPhaseenums;AccPhasesupportsUnspecified,Partial, andFinal, whileSTPhaseintentionally supports onlyUnspecifiedandFinaland rejects PTO-ISA's lower-level check-only store phasest_phaseforwarding topl.storeand the directtile.storeIR APIaccPhaseandstPhaseattributes while keeping default stores attribute-free and combiningstPhasecleanly withatomicTypeAccStorePhaseValidverification immediately afterInlineFunctions: track the exact producer SSA value (including plain aliases), require exactly one matching final store in the same straight-line region, and reject missing, mismatched, duplicate, or cross-control-flow pairs before code generationUsage
The corrected producer/consumer pairing is:
Existing non-phased calls remain unchanged:
The default
pl.STPhase.Unspecifiedis omitted from IR and PTO output, preserving previous store codegen exactly. A final GEMV-family producer without its matching final store—or a final store without its producer—is now rejected at compile time instead of being allowed to stall the device silently.Testing
cmake --build build --parallelPYTHONPATH=python pytest tests/ut -n 2— 9,724 passed, 8 skippedAccStorePhaseValid, store phase/atomic, GEMV codegen, printer, and IR tests — 27 passedRelated to #2376; #2376 exposed but did not introduce this bug.