Skip to content

Sync: host_build_graph early-dispatch up to current tensormap_and_ringbuffer#1335

Merged
ChaoWao merged 1 commit into
hw-native-sys:mainfrom
ChaoWao:sync-hbg-early-dispatch-1326-1328-1329
Jul 11, 2026
Merged

Sync: host_build_graph early-dispatch up to current tensormap_and_ringbuffer#1335
ChaoWao merged 1 commit into
hw-native-sys:mainfrom
ChaoWao:sync-hbg-early-dispatch-1326-1328-1329

Conversation

@ChaoWao

@ChaoWao ChaoWao commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #1327. tmr landed five more early-dispatch changes on the shared scheduler; this ports them into host_build_graph, preserving hbg's host-orchestration invariants.

Absorbed: #1304 (require_sync_start SPMD early-dispatch + drain_stage_cores), #1326 (defer early-dispatch until producer publication — race fix), #1328 (folded-gate src_payload perf/ABI + AICore-side arg fill), #1329 (exclusive doorbell — fix), #1331 (serialize block-range claims via claim_block_range — fix).

Preserved host-orch deltas: single-ring, no execution-time reclaim, flat runtime->workers, dropped pto2_dispatch_payload.h include, AICore FIN/record order + no ACK-gate, runtime_init_ready_ boot barrier.

Out of scope (follow-up): per-device scheduler timeout, PTO2_TENSOR_DATA_TIMEOUT MS (#1189), stall sub-classification (#1182), runtime scope_tasks_cap (#1188).

Testing

  • 8 runtime targets build -Werror
  • a2a3sim host_build_graph suite 10/10
  • a2a3 onboard host_build_graph suite 10 passed / 1 skipped
  • tensormap_and_ringbuffer + a5 untouched

…gbuffer

Follows PR hw-native-sys#1327 (which synced hbg's scheduler to tmr's hw-native-sys#1319 state). tmr then
landed five more early-dispatch changes on the same subsystem; this ports them
into host_build_graph's copies, preserving hbg's host-orchestration invariants
(single ring, no execution-time reclaim, flat Runtime, no ACK-gate, host-side
orchestrator).

Absorbed from tmr:
- hw-native-sys#1304 Add early-dispatch for require_sync_start SPMD cohorts, incl. the
  drain_stage_cores parallel-drain refactor (handle_drain_mode two-stage).
- hw-native-sys#1326 Defer early dispatch until producer publication (correctness/race):
  published_block_count + record_published_blocks; propagate_dispatch_fanin is
  gated on published_block_count >= logical_block_num; the published_list ledger
  in dispatch and the stage_consumer_blocks two-sided publication/release
  handshake.
- hw-native-sys#1328 Shrink dispatch cold-write cost via a folded-gate src_payload
  (PTO2DispatchPayload: not_ready -> volatile uint64_t src_payload, 0 = ready,
  non-zero = gated source PTO2TaskPayload address; global_context to the tail;
  the PTO2_TASKPAYLOAD_*_OFFSET constants + static_asserts). build_payload writes
  args on the ready path and only src_payload on the gated path; the idle AICore
  fills args[] from src_payload during its doorbell wait; init-time prefill of
  async_ctx slab pointers/capacity + context-ptr args; deferred_slab reset moved
  off the dispatch path; software-pipelined prefetch of the next block.
- hw-native-sys#1329 Make early-dispatch doorbell ownership exclusive (correctness).
- hw-native-sys#1331 Serialize block range claims (correctness): every block-range claim now
  goes through slot_state->claim_block_range(...) instead of an inline
  next_block_idx CAS.

Preserved host-orch divergences (not overwritten by tmr): PTO2_MAX_RING_DEPTH==1
with rings[]/ring_id removed; no advance_ring_pointers / reset_for_reuse /
check_and_handle_consumed (completion via completed_tasks_, consumer wait keys on
fanout_refcount); flat runtime->workers / runtime->func_id_to_addr_ (not
runtime->dev.*); pto_runtime2_types.h keeps its dropped pto2_dispatch_payload.h
include; hbg's AICore FIN-vs-swimlane-record ordering and its no-ACK-gate
completion path (drains via completion-before-dispatch + backstop flushes); no
device orchestrator (orchestrator_done_ absent, scheduler threads gate on
runtime_init_ready_).

Out of scope (unrelated tmr changes hbg still lacks, tracked for a follow-up):
per-device scheduler timeout (get_scheduler_timeout_ms), PTO2_TENSOR_DATA_TIMEOUT
MS-vs-cycles (hw-native-sys#1189), stall sub-classification (hw-native-sys#1182), runtime scope_tasks_cap
(hw-native-sys#1188).

Verified: all 8 runtime targets build -Werror; a2a3sim host_build_graph scene
suite 10/10; a2a3 onboard host_build_graph suite 10 passed / 1 skipped
(paged_attention exercises the new claim_block_range serialization, drain_stage_cores
drain, src_payload gated arg-fill, and published-block gating). tensormap_and_ringbuffer
and the a5 runtimes are untouched.
@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@ChaoWao, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 27 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 979b0119-1558-4a16-ac33-89b5901f18f7

📥 Commits

Reviewing files that changed from the base of the PR and between 19a7699 and aea5044.

📒 Files selected for processing (10)
  • src/a2a3/runtime/host_build_graph/aicore/aicore_executor.cpp
  • src/a2a3/runtime/host_build_graph/runtime/pto2_dispatch_payload.h
  • src/a2a3/runtime/host_build_graph/runtime/pto_runtime2_types.h
  • src/a2a3/runtime/host_build_graph/runtime/scheduler/pto_scheduler.h
  • src/a2a3/runtime/host_build_graph/runtime/scheduler/scheduler_cold_path.cpp
  • src/a2a3/runtime/host_build_graph/runtime/scheduler/scheduler_completion.cpp
  • src/a2a3/runtime/host_build_graph/runtime/scheduler/scheduler_context.h
  • src/a2a3/runtime/host_build_graph/runtime/scheduler/scheduler_dispatch.cpp
  • src/a2a3/runtime/host_build_graph/runtime/scheduler/scheduler_types.h
  • src/a2a3/runtime/host_build_graph/runtime/shared/pto_runtime2_init.cpp

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 optimizes the early-dispatch and sync-start paths in the runtime scheduler. Key changes include offloading argument vector materialization from the AICPU scheduler threads to the idle AICore when a task is gated, restructuring PTO2DispatchPayload to align hot writes to cache line 0, and prefilling constant fields once at initialization. Additionally, it introduces parallel staging in the sync-start drain mode to allow concurrent staging across scheduler threads, and implements a dedicated early_sync_start_queue with a rendezvous mechanism to ensure atomic launching of sync-start cohorts and prevent resource deadlocks. No review comments were provided, so there is no feedback to address.

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 56a6c9f into hw-native-sys:main Jul 11, 2026
15 checks passed
@ChaoWao ChaoWao deleted the sync-hbg-early-dispatch-1326-1328-1329 branch July 11, 2026 17:24
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