Fix: align hbg docs/comments with the polling runtime model - #1655
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:
📝 WalkthroughWalkthroughThe PR updates host-build-graph documentation and runtime comments. It documents whole-graph task residency, task-window sizing, restricted scalar access, and completed-watermark consumer tracking. No executable behavior or public declarations change. ChangesHost Build Graph Documentation
Estimated code review effort: 1 (Trivial) | ~5 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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/a2a3/runtime/host_build_graph/docs/RUNTIME_LOGIC.md`:
- Around line 263-290: Update
src/a2a3/runtime/host_build_graph/docs/RUNTIME_LOGIC.md lines 263-290 to reflect
that allocation blocks on the 16th task with task_window=16 and cannot reach the
208-task example while last_alive remains 0; preserve the no-reclaim sizing
guidance. Update src/a2a3/runtime/host_build_graph/docs/RUNTIME_LOGIC.md line
352 to size TensorMap capacity using total_tasks × avg_outputs_per_task, and
remove the claim that smaller windows trigger frequent cleanup.
In `@src/a2a3/runtime/host_build_graph/docs/SCALAR_DATA_ACCESS.md`:
- Around line 5-10: Update Section 5’s scalar-access example to comply with the
host_build_graph restriction: remove the producing add_output tensor and
orchestration-side completion wait, or rewrite the example using a producer-less
external or initial-value tensor without submitting a producing task. If
retaining the producer-based example, move it to the tensormap_and_ringbuffer
documentation.
🪄 Autofix (Beta)
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: 66fd0777-70a1-4232-bd0c-6de18876df44
📒 Files selected for processing (6)
src/a2a3/runtime/host_build_graph/docs/RUNTIME_LOGIC.mdsrc/a2a3/runtime/host_build_graph/docs/SCALAR_DATA_ACCESS.mdsrc/a2a3/runtime/host_build_graph/orchestration/pto_orchestration_api.hsrc/a2a3/runtime/host_build_graph/runtime/orchestrator_core/pto_orchestrator.cppsrc/a2a3/runtime/host_build_graph/runtime/orchestrator_core/pto_runtime2.cppsrc/a2a3/runtime/host_build_graph/runtime/pto_runtime2_types.h
aba08a4 to
24eb6ff
Compare
Fixes hw-native-sys#1646 host_build_graph migrated its dependency model from the wiring/refcount model (fanout_refcount + scope refcount + CONSUMED-via-refcount) to the polling model (completion_flags + per-ring completed_watermark), and the runtime is whole-graph-resident (the orchestrator runs to completion on the host; last_task_alive is never advanced at runtime). Several docs and load-bearing comments still presented the removed model as current behavior. All changes are documentation/comment-only. - Retarget seven present-tense references from fanout_refcount/fanout_count to the actual consumer-retirement signal, the per-ring completed_watermark >= producer's last_consumer_local_id (SCALAR_DATA_ACCESS.md, RUNTIME_LOGIC state machine, pto_orchestration_api.h, pto_runtime2_types.h, pto_runtime2.cpp). Correct the prepare_task zeroed-fields list to the fields reset_for_reuse() actually clears. - Scope SCALAR_DATA_ACCESS.md §1 to what hbg supports: orchestration runs to completion on the host before any device task, so get/set_tensor_data are safe only on producer-less tensors; reading a produced result mid-graph is a tensormap_and_ringbuffer capability and times out here. Flag the §5 1-element-tensor example, which submits a producing task then reads it back, as that same hanging pattern — usable in hbg only in the producer-less direction. - Rewrite RUNTIME_LOGIC.md §4.5 to the current failure model: whole-graph residency means the window must hold the whole graph's task count, and a too-small window trips the 500 ms wall-clock backstop (report_deadlock); replace the stale FATAL/BLOCKED sample text no longer emitted by the code, with block-state numbers consistent with last_alive pinned at 0, and fix the task_window default (65536 -> 16384), matching §8.4. Correct the §5.5 TensorMap-capacity sentence: under no reclaim, entries grow to total_tasks × avg_outputs and are bounded by pool_size, not recycled.
Summary
host_build_graph's dependency model was migrated from the wiring/refcount model (fanout_refcount+ scope refcount +CONSUMED-via-refcount) to the polling model (completion_flags+ per-ringcompleted_watermark), and the runtime is whole-graph-resident (the orchestrator runs to completion on the host;last_task_aliveis never advanced at runtime). Several docs and load-bearing comments still described the removed model. Documentation/comment-only — no behavior change. All replacement facts were verified against the current source, not taken from the issue text.Three facets from #1646, all confined to
src/a2a3/runtime/host_build_graph/:fanout_refcount/fanout_countto the real consumer-retirement signal: per-ringcompleted_watermark >= producer's last_consumer_local_id(SCALAR_DATA_ACCESS.md§3.2/§4/§5,RUNTIME_LOGIC.mdstate machine,pto_orchestration_api.h,pto_runtime2_types.h,pto_runtime2.cpp). Correct theprepare_taskzeroed-fields comment to the fieldsreset_for_reuse()actually clears (wake_list_head/next_in_wake_list/any_subtask_deferred/completed_subtasks/next_block_idx). The correct historical/contrast notes are left intact.SCALAR_DATA_ACCESS.md§1 claimed a capability hbg lacks — scope it: the orchestrator finishes on the host before any device task runs, so a producer'stask_statecan never reachCOMPLETEDduring orchestration; get/set_tensor_data are safe only on producer-less tensors (external / initial-value), and reading a produced result mid-graph is atensormap_and_ringbuffercapability that times out here.RUNTIME_LOGIC.md§4.5 sizing guidance + default — rewrite the deadlock section to the current model: whole-graph residency means the window must hold the whole graph's task count (not the largest scope), and a too-small window trips the 500 ms wall-clock backstop (report_deadlock); replace the staleFlow Control DeadlockFATAL/BLOCKED sample text the code no longer emits, and fix thetask_windowdefault (65536→16384, matching#define PTO2_TASK_WINDOW_SIZE 16384). This aligns §4.5 with the already-correct §8.4.Scope
Per agreement on the issue, facet 3 fixes the sizing guidance and reconciles §4.5's stale root-cause/FATAL text (one coherent unit). §4.1–§4.4's broader
last_task_alivereclaim narrative (L209–259) is intentionally left for a follow-up, as is the residue outsidehost_build_graph(tensormap_and_ringbuffer, top-leveldocs/,a5) that #1646 did not sweep.Testing
Documentation and comment-only; no compiled behavior changes.
Fixes #1646