Skip to content

a5 host_build_graph: converge scheduler_dispatch + runtime_maker with a2a3 - #1789

Merged
ChaoZheng109 merged 1 commit into
hw-native-sys:mainfrom
ChaoZheng109:a5-hbg-converge-dispatch-runtime-maker
Aug 12, 2026
Merged

a5 host_build_graph: converge scheduler_dispatch + runtime_maker with a2a3#1789
ChaoZheng109 merged 1 commit into
hw-native-sys:mainfrom
ChaoZheng109:a5-hbg-converge-dispatch-runtime-maker

Conversation

@ChaoZheng109

Copy link
Copy Markdown
Collaborator

Summary

Converges the two remaining a5↔a2a3 host_build_graph code forks (the last real logic-divergent files after #1759 made the orchestrator core identical; PMU + SDMA cache are excluded as known arch items).

Changes

runtime/scheduler/scheduler_dispatch.cpp — now byte-identical to a2a3. The first dispatch loop:

  • calls handle_orchestrator_exit() at the loop top instead of an inlined error-only check (the helper also does completion detection + the orch/sched error shutdown — a5 already had and used it at a second site);
  • uses a plain completed_tasks_.fetch_add(resolved_this_pass) + continue for completion accounting instead of the inline new_total >= total_tasks_ check (the helper detects completion on the next iteration).

host/runtime_maker.cpprelocate_host_orch_image and the host-orchestration path aligned to a2a3: relocate-lambda naming, single-pass ring iteration (PTO2_MAX_RING_DEPTH == 1, so the for r loop was a no-op), entry_points/bind structure, LOG strings, and drops the unused rt parameter.

Retained: a5's richer inline comments and the A5-only simpler_aicpu_query_topology export (real arch difference — A5 needs the topology query before the first launch; a2a3 does not).

Residual a5↔a2a3 HBG diff after this

Header-guard style (#pragma once vs #ifndef), arch constants (RUNTIME_MAX_WORKER 72↔108, platform string), comment drift, the topology symbol, and the (separately tracked) PMU record API + SDMA cache-invalidation.

Verification

  • clang-tidy / cpplint / clang-format green; incremental rebuild succeeds.
  • a5sim golden set passes: graph_execution (×3) + paged_attention.

🤖 Generated with Claude Code

… a2a3

scheduler_dispatch.cpp's first dispatch loop now calls
handle_orchestrator_exit() at the loop top (it inlined an error-only
check) and uses a plain fetch_add + continue for completion accounting
(the helper detects completion next iteration) instead of the inline
new_total check. Behavior-preserving; the file is byte-identical to a2a3.

runtime_maker.cpp aligns relocate_host_orch_image and the host-orch path
with a2a3: relocate-lambda naming, single-pass ring iteration
(PTO2_MAX_RING_DEPTH == 1, so the depth loop was a no-op), entry_points/
bind structure, LOG strings, and drops the unused rt parameter. a5's
richer inline comments and the A5-only simpler_aicpu_query_topology
export are retained.

Verified: builds clean; a5sim golden set passes (graph_execution x3,
paged_attention).

Co-Authored-By: Claude <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Host orchestration now supports direct single-ring relocation and explicit runtime binding. Scheduler resolution delegates orchestrator exits, continues draining after completion updates, and uses a cached task total for stall detection.

Changes

Host orchestration and scheduler lifecycle

Layer / File(s) Summary
Single-ring image relocation
src/a5/runtime/host_build_graph/host/runtime_maker.cpp
The relocation helper removes its unused runtime parameter and processes the single ring directly. It relocates only task and payload pointers.
Explicit orchestration binding
src/a5/runtime/host_build_graph/host/runtime_maker.cpp
Host orchestration requires framework_bind_runtime, binds the orchestration runtime, invokes the entry point, and reads the submitted task count. Related include ordering and host-state logging were updated.
Scheduler resolution lifecycle
src/a5/runtime/host_build_graph/runtime/scheduler/scheduler_dispatch.cpp
Resolution delegates exit handling to handle_orchestrator_exit. Completion accounting continues draining, and stall detection uses a cached total_tasks_ value.

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

Sequence Diagram(s)

sequenceDiagram
  participant HostOrchestration
  participant framework_bind_runtime
  participant OrchestrationEntry
  HostOrchestration->>framework_bind_runtime: resolve binding entry point
  HostOrchestration->>framework_bind_runtime: bind orchestration runtime
  HostOrchestration->>OrchestrationEntry: invoke orchestration entry
  OrchestrationEntry-->>HostOrchestration: return submitted task count
Loading

Possibly related issues

Possibly related PRs

Poem

A rabbit hops through rings made small,
Binds the runtime, then calls them all.
Tasks resolve while errors flee,
The counter drains patiently.
Pointers find their proper place—
Clean paths run at rabbit pace.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the a5 host_build_graph convergence in scheduler_dispatch and runtime_maker with a2a3.
Description check ✅ Passed The description accurately explains the convergence changes, retained a5 differences, and verification results.
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.

@coderabbitai coderabbitai 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.

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 `@src/a5/runtime/host_build_graph/host/runtime_maker.cpp`:
- Around line 381-383: Update the relocation contract comment near relocate() to
state that null pointers pass through unchanged, while non-null pointers outside
both recognized regions cause relocation to fail; remove the claim that foreign
pointers pass through untouched.
🪄 Autofix

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: 5015712b-471f-4b65-97f7-6a2343ffd585

📥 Commits

Reviewing files that changed from the base of the PR and between c5a5874 and f1b37b7.

📒 Files selected for processing (2)
  • src/a5/runtime/host_build_graph/host/runtime_maker.cpp
  • src/a5/runtime/host_build_graph/runtime/scheduler/scheduler_dispatch.cpp

Comment on lines +381 to 383
// Rather than track which delta each field needs, relocate() classifies every
// pointer by the region it points INTO and applies that region's delta; foreign
// and null pointers pass through untouched. The fanout adjacency is wired inline

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Correct the relocation contract comment.

Lines 381-383 state that foreign pointers pass through unchanged. Lines 420-427 reject a non-null pointer outside both windows and make relocation fail. State that null pointers pass through unchanged and external pointers cause failure.

Proposed fix
-// pointer by the region it points INTO and applies that region's delta; foreign
-// and null pointers pass through untouched. The fanout adjacency is wired inline
+// pointer by the region it points INTO and applies that region's delta. Null
+// pointers pass through unchanged. External pointers cause relocation failure.
+// The fanout adjacency is wired inline
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Rather than track which delta each field needs, relocate() classifies every
// pointer by the region it points INTO and applies that region's delta; foreign
// and null pointers pass through untouched. The fanout adjacency is wired inline
// Rather than track which delta each field needs, relocate() classifies every
// pointer by the region it points INTO and applies that region's delta. Null
// pointers pass through unchanged. External pointers cause relocation failure.
// The fanout adjacency is wired inline
🤖 Prompt for 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.

In `@src/a5/runtime/host_build_graph/host/runtime_maker.cpp` around lines 381 -
383, Update the relocation contract comment near relocate() to state that null
pointers pass through unchanged, while non-null pointers outside both recognized
regions cause relocation to fail; remove the claim that foreign pointers pass
through untouched.

@ChaoZheng109
ChaoZheng109 merged commit 50c0660 into hw-native-sys:main Aug 12, 2026
18 checks passed
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