Skip to content

fix(a2a3/tensormap): propagate early-dispatch from the sync_start drain path#1296

Merged
ChaoWao merged 1 commit into
hw-native-sys:mainfrom
ChaoWao:fix/sync-start-drain-early-dispatch-propagate
Jul 8, 2026
Merged

fix(a2a3/tensormap): propagate early-dispatch from the sync_start drain path#1296
ChaoWao merged 1 commit into
hw-native-sys:mainfrom
ChaoWao:fix/sync-start-drain-early-dispatch-propagate

Conversation

@ChaoWao

@ChaoWao ChaoWao commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

propagate_dispatch_fanin — the event that turns a flagged producer's
dispatch
into early-dispatch candidacy for its consumers — was only called on
the normal ready-pop dispatch path (scheduler_dispatch.cpp:457). A
sync_start task dispatches through the separate drain path
(handle_drain_modedrain_worker_dispatch in scheduler_completion.cpp),
which never propagated.

Consequence: any consumer whose only flagged producer is a sync_start
(drain-dispatched) task
never became an early-dispatch candidate — it wasn't
gated and it had spare (idle/pending) cores to stage onto; the candidate-enqueue
event itself
was simply missing.

Fix

After drain_worker_dispatch publishes all of the drained producer's blocks
(the producer is now dispatched), call propagate_dispatch_fanin once —
mirroring the normal path's post-publish propagate.

  • Idempotent via propagate's dispatch_propagated once-guard.
  • The internal gate no-ops for an unflagged producer, so calling it
    unconditionally is cheap (same as the normal path).
  • Scoped exactly to the gap: only sync_start tasks reach the drain path
    (scheduler_dispatch.cpp re-queues a non-sync_start task that doesn't fit, so
    it propagates via the normal path on eventual dispatch).

Testing

  • a2a3 hardware — qwen3-14B decode_fwd (2-layer) early-dispatched-task
    count 35 → 83 with the fix. The +48 are exactly the 24 out_proj
    tiles/layer whose sole producer is the sync_start fa_fused — previously
    stuck out of early-dispatch, now pre-staged onto pending slots while fa_fused
    runs.
  • spmd_sync_start / _aiv / _edge / _stress scene tests pass (no drain
    regression).
  • cpput WiringTest 19/19 pass.

Testing checklist

  • Simulation / cpput tests pass
  • Hardware (a2a3) tests pass

…in path

propagate_dispatch_fanin — the event that turns a flagged producer's dispatch
into early-dispatch candidacy for its consumers — was only called on the normal
ready-pop dispatch path (scheduler_dispatch.cpp). A sync_start task dispatches
through the separate drain path (handle_drain_mode/drain_worker_dispatch in
scheduler_completion.cpp), which never propagated. So any consumer whose only
flagged producer is a sync_start (drain-dispatched) task never became an
early-dispatch candidate.

Mirror the normal path: after drain_worker_dispatch publishes all of the drained
producer's blocks, call propagate_dispatch_fanin once. Idempotent via the
dispatch_propagated once-guard; the internal gate no-ops for an unflagged
producer, so recording unconditionally is cheap. Only sync_start producers reach
the drain path (a non-sync_start task that doesn't fit is re-queued and
propagates via the normal path on eventual dispatch), so the fix is scoped to
exactly the gap.

Verified on a2a3: qwen3-14B decode_fwd (2-layer) early-dispatched-task count
35 -> 83 with the fix (+48 = the 24 out_proj tiles/layer whose sole producer is
the sync_start fa_fused). sync_start scene tests (spmd_sync_start*) pass and
cpput WiringTest 19/19 pass unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 227c916c-e017-49ba-b682-50703666eaf1

📥 Commits

Reviewing files that changed from the base of the PR and between a5895d8 and b5d3f3f.

📒 Files selected for processing (1)
  • src/a2a3/runtime/tensormap_and_ringbuffer/runtime/scheduler/scheduler_completion.cpp

📝 Walkthrough

Walkthrough

This change adds a call to propagate_dispatch_fanin within SchedulerContext::drain_worker_dispatch during sync_start dispatch, so consumer dispatch_fanin state updates consistently, matching behavior already present in the normal scheduler dispatch path.

Changes

Drain Dispatch Fanin Propagation

Layer / File(s) Summary
Propagate dispatch_fanin on sync_start drain
src/a2a3/runtime/tensormap_and_ringbuffer/runtime/scheduler/scheduler_completion.cpp
Adds explicit sched_->propagate_dispatch_fanin(*slot_state) call during sync_start drain dispatch so consumers' dispatch_fanin is updated as in the normal dispatch path.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

  • hw-native-sys/simpler#1285: Both PRs add/ensure propagate_dispatch_fanin calls for flagged producers to update early-dispatch eligibility.
  • hw-native-sys/simpler#1292: Both PRs address correctness of consumers' dispatch-fanin state in the early-dispatch code path.

Poem

A drain, a hop, a fanin cheer,
Consumers now know producers are near!
Sync_start whispers down the line,
"Your turn is coming, right on time!" 🐇
Thump-thump, the scheduler's clear.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the fix to propagate early-dispatch from the sync_start drain path.
Description check ✅ Passed The description accurately explains the same fix and related validation.
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 updates the drain_worker_dispatch function in scheduler_completion.cpp to call sched_->propagate_dispatch_fanin(*slot_state). This ensures that the drain path correctly increments its consumers' dispatch fan-in, allowing consumers whose only flagged producer is a sync_start task to become early-dispatch candidates. 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 merged commit ea87130 into hw-native-sys:main Jul 8, 2026
15 checks passed
@ChaoWao ChaoWao deleted the fix/sync-start-drain-early-dispatch-propagate branch July 8, 2026 09:05
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