Skip to content

Fix: preserve early dispatch for late-wired consumers - #1405

Merged
ChaoWao merged 1 commit into
hw-native-sys:mainfrom
ChaoWao:fix/early-dispatch-late-wiring
Jul 20, 2026
Merged

Fix: preserve early dispatch for late-wired consumers#1405
ChaoWao merged 1 commit into
hw-native-sys:mainfrom
ChaoWao:fix/early-dispatch-late-wiring

Conversation

@ChaoWao

@ChaoWao ChaoWao commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Serialize the dispatch-propagation claim with the producer fanout snapshot so consumer wiring can distinguish included edges from late edges.
  • Seed fully published producers wired after one-shot propagation, and enqueue whichever contribution completes dispatch fanin.
  • Add sequential and forced-interleaving regression coverage and document the lock-order invariant.
  • Validate 34 wiring tests, 60 non-hardware C++ tests, and the A2A3 sync-start early-dispatch scene on simulator and device.

Related Issues

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9f4f2cad-808d-4fa6-857c-b290db2ce68e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Early-dispatch fanin propagation now accounts for producers that already propagated dispatch state. Wiring seeds late consumers accordingly, scheduler enrollment is centralized and serialized, and tests cover late-wiring and concurrent-propagation cases.

Changes

Early dispatch fanin

Layer / File(s) Summary
Serialize propagation and centralize candidate enrollment
src/a2a3/runtime/tensormap_and_ringbuffer/runtime/scheduler/pto_scheduler.h, src/a2a3/runtime/tensormap_and_ringbuffer/docs/RUNTIME_LOGIC.md
Propagation claims and fanout snapshots are serialized under fanout_lock; eligible consumers are staged once and routed to the appropriate early-dispatch queue.
Seed fanin during wiring
src/a2a3/runtime/tensormap_and_ringbuffer/runtime/pto_orchestrator.cpp, src/a2a3/runtime/tensormap_and_ringbuffer/docs/RUNTIME_LOGIC.md
Wiring counts completed and already-propagated producers, updates dispatch_fanin, and enqueues consumers when early fanin is complete.
Validate late and concurrent wiring
tests/ut/cpp/a2a3/test_wiring.cpp, src/a2a3/runtime/tensormap_and_ringbuffer/runtime/scheduler/scheduler_dispatch.cpp
Tests cover late wiring and concurrent propagation; the early-dispatch comment is updated to match gated pending-slot behavior.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Producer
  participant PTO2OrchestratorState
  participant PTO2SchedulerState
  participant EarlyDispatchQueue
  Producer->>PTO2SchedulerState: Propagate published dispatch fanin
  PTO2SchedulerState->>PTO2SchedulerState: Claim propagation and snapshot fanout
  PTO2OrchestratorState->>PTO2OrchestratorState: Wire consumer and count early producers
  PTO2OrchestratorState->>PTO2SchedulerState: Enqueue eligible consumer when fanin is complete
  PTO2SchedulerState->>EarlyDispatchQueue: Stage consumer once
Loading

Possibly related PRs

Poem

I’m a bunny with dispatch in my toes,
Counting fanin wherever it goes.
Late wires join the queue with care,
Locked fanouts keep counts fair.
Propagate once—then hop away! 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: preserving early dispatch for consumers wired after producer propagation.
Description check ✅ Passed The description is directly related to the code changes, tests, and documentation updates in this pull request.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors and improves the early-dispatch scheduling logic by ensuring that late-wired consumers are correctly enqueued when their producers are already fully published. It introduces a helper function try_enqueue_early_dispatch_candidate to centralize the enqueuing logic, optimizes lock contention with an unlocked precheck on dispatch_propagated, and updates the documentation and unit tests accordingly. There are no review comments, so I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@ChaoWao
ChaoWao force-pushed the fix/early-dispatch-late-wiring branch from 01d6849 to 9635827 Compare July 20, 2026 09:18
Serialize the dispatch-propagation claim with its fanout snapshot so wiring can distinguish included edges from late edges.

Seed late fully-published producers during wiring, enqueue whichever contribution completes dispatch fanin, and cover both serialized and concurrent orderings.
@ChaoWao
ChaoWao merged commit b6b898d into hw-native-sys:main Jul 20, 2026
28 of 29 checks passed
@ChaoWao
ChaoWao deleted the fix/early-dispatch-late-wiring branch July 20, 2026 10:31
yanghaoran29 added a commit to yanghaoran29/simpler that referenced this pull request Jul 21, 2026
Bring a5 tensormap_and_ringbuffer in line with a2a3 early-dispatch
(hw-native-sys#989/hw-native-sys#1079/hw-native-sys#1285/hw-native-sys#1288/hw-native-sys#1297/hw-native-sys#1304/hw-native-sys#1326/hw-native-sys#1329/hw-native-sys#1336/hw-native-sys#1405/hw-native-sys#1340):
prepare/publish, src_payload gate + DMB high32 doorbell (sim uses
__atomic_load_n ACQUIRE), direct-only eligibility, spare-slot Phase 4b,
sync_start early rendezvous, and dep_gen early_dispatch truth. Document
the a5 model in RUNTIME_LOGIC §8.6.

Add a5 STs: plain early_dispatch plus sync_start early_dispatch and
mix_spill ports (EarlyOn/Off) for board validation.
ChaoWao pushed a commit that referenced this pull request Jul 21, 2026
)

* feat(a5/tmr): port allow_early_resolve / early-dispatch from a2a3

Bring a5 tensormap_and_ringbuffer in line with a2a3 early-dispatch
(#989/#1079/#1285/#1288/#1297/#1304/#1326/#1329/#1336/#1405/#1340):
prepare/publish, src_payload gate + DMB high32 doorbell (sim uses
__atomic_load_n ACQUIRE), direct-only eligibility, spare-slot Phase 4b,
sync_start early rendezvous, and dep_gen early_dispatch truth. Document
the a5 model in RUNTIME_LOGIC §8.6.

Add a5 STs: plain early_dispatch plus sync_start early_dispatch and
mix_spill ports (EarlyOn/Off) for board validation.

* test(a5): drop local early-dispatch ST ports from this PR

Remove the a5-only early_dispatch / sync_start early ST scenes added for
board experiments; keep the runtime port focused for CI.

* chore(a5): drop unrelated files that broke pre-commit on the PR

Remove accidental local helpers, migrate patches, and the acc_c2v
example that were committed with the UT payload-pool fix. Keep the
early-dispatch runtime port, a2a3-ported sync_start STs, and a5 UT
payload/task pool binding.
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.

1 participant