Add: generation-safe two-frame local endpoint - #1583
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 change adds generation-safe pipeline leases, whole-run FIFO admission, prepared endpoint activation, and two-frame local mailbox execution. Run-aware scheduling, Python bindings, chip startup wiring, mailbox layouts, and unit/end-to-end tests are updated accordingly. ChangesPipeline admission and prepared execution
Estimated code review effort: 5 (Critical) | ~120 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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: 8
🤖 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/common/hierarchical/orchestrator.h`:
- Around line 132-134: Integrate can_dispatch_run into the production
run-admission/dispatch path so every run is checked against the documented
lease-ownership gate before being dispatched. Locate the scheduler method that
admits or starts runs and invoke can_dispatch_run with the candidate run_id,
rejecting or deferring runs that fail the check; leave active_run_id and
preparable_run_id unchanged.
In `@src/common/hierarchical/worker_manager.cpp`:
- Around line 305-315: Prevent failed dispatches from leaving an unretiable
publish sequence. In the dispatch preparation flow, validate the endpoint,
prepared slot, and activation capability before calling
WorkerThread::enqueue_dispatch; for failures that can still occur after ID
allocation in dispatch_process or run_prepared_with_activation, add and invoke a
WorkerThread sequence-cancellation/poisoning hook so the allocated ID advances
or is retired and subsequent dispatches do not block.
- Around line 328-338: Update WorkerThread::stop and the activation-wait path to
synchronize shutdown_ with activation_mu_, the mutex used by the activation_cv_
predicate. Set or publish shutdown_ while holding activation_mu_ before calling
activation_cv_.notify_all(), and ensure the waiter reads it under that same lock
so shutdown cannot be missed and stop() can join all threads.
In
`@tests/st/a2a3/host_build_graph/worker_async_endpoint/test_worker_async_endpoint.py`:
- Around line 129-133: Drop the loop-variable tensor references before freeing
host buffers in both cleanup blocks: update
tests/st/a2a3/host_build_graph/worker_async_endpoint/test_worker_async_endpoint.py
lines 129-133 and
tests/st/a2a3/host_build_graph/worker_async_fifo/test_worker_async_fifo.py lines
178-182 to clear the respective buffer/tensor loop bindings alongside the named
locals, then run the existing free_host_buffer sweep.
- Around line 115-119: Add a short sleep inside the polling loop around the
state reads in the worker async endpoint test, after each unsuccessful poll, so
the loop yields the GIL while retaining the existing deadline and
state-detection behavior.
In `@tests/ut/cpp/hierarchical/test_scheduler.cpp`:
- Around line 684-697: Replace the unbounded orchestrator.wait_run calls after
the readiness assertions with the bounded wait_run_for variant, applying the
existing test timeout convention to both first_run and second_run. Preserve the
release_normal cleanup and ensure the test reports a failure rather than hanging
when readiness was not achieved.
- Around line 575-587: Add steady-clock deadlines to both simulated-child
polling loops in the thread lambda, covering waits for PREPARE_READY and
ACTIVATE; exit or fail cleanly when either deadline expires. Also bound the
caller’s wait for completion so child.join() and caller.join() cannot hang when
readiness or done never occurs, while preserving the existing state transitions
and assertions.
In `@tests/ut/py/test_worker/test_host_worker.py`:
- Around line 1620-1625: Update the test’s finally block to join the submitter
thread before closing or unlinking shared resources, matching the cleanup
pattern in test_submit_close_race_accepts_and_drains_admitted_run. Ensure the
join occurs even when the test body fails, so submitter has exited before
hw.close(), state_shm.close(), and state_shm.unlink().
🪄 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: 1b1a4a18-1617-45e9-bef5-e2d973cedbfd
📒 Files selected for processing (24)
docs/task-flow.mdpython/bindings/task_interface.cpppython/bindings/worker_bind.hpython/simpler/task_interface.pypython/simpler/worker.pysrc/common/hierarchical/orchestrator.cppsrc/common/hierarchical/orchestrator.hsrc/common/hierarchical/scheduler.cppsrc/common/hierarchical/scheduler.hsrc/common/hierarchical/types.cppsrc/common/hierarchical/types.hsrc/common/hierarchical/worker.cppsrc/common/hierarchical/worker.hsrc/common/hierarchical/worker_manager.cppsrc/common/hierarchical/worker_manager.hsrc/common/worker/pipeline_slot_pool.htests/st/a2a3/host_build_graph/worker_async_endpoint/kernels/orchestration/long_vector_orch.cpptests/st/a2a3/host_build_graph/worker_async_endpoint/test_worker_async_endpoint.pytests/st/a2a3/host_build_graph/worker_async_fifo/test_worker_async_fifo.pytests/ut/cpp/hierarchical/test_orchestrator.cpptests/ut/cpp/hierarchical/test_pipeline_contract.cpptests/ut/cpp/hierarchical/test_scheduler.cpptests/ut/py/test_callable_identity.pytests/ut/py/test_worker/test_host_worker.py
a264f8e to
b3b81b7
Compare
944c47e to
e7bec67
Compare
- Stage one successor frame behind an active native run without crossing the prepare or launch fence before FIFO promotion and finalization - Drive active and staged lanes from one bounded progress owner with per-frame generation, dispatch identity, acceptance, and completion - Terminalize both lanes when native reuse or child quiescence is uncertain while retaining the single-frame compatibility path - Harden deterministic publication-failure coverage and HCCL destroy handoff so timing cannot race endpoint capacity or reuse stale filesystem generations - Cover scheduling, controls, frame reuse, poison, shutdown, and A2/A3 onboard overlap with deterministic regression tests Co-authored-by: Crane-Liu <c.wliu@outlook.com>
Summary
successor frame B
finalization fence, preserving the one-unfinished-native-run invariant
run, slot, generation, and dispatch identity before reuse
registry controls remain coherent with active and staged frame ownership
simulation, A5, and depth-one local chip endpoints
Scope boundary
FRAME_STAGED means the child validated and owns an immutable mailbox payload;
it is not HBG/TMR native preparation. Runtime-specific preparation overlap and
resource banking remain follow-up B4/B5 work.
The production two-frame path is enabled only for direct A2/A3 onboard chip
children that advertise pipeline depth >= 2. HBG and TMR share the common
endpoint contract while continuing to serialize their native run lifecycles.
CI robustness follow-ups
publication-failure regression on the recorded successor failure, removing
the macOS test data/timing race
per-follower release handoff on A2/A3 and A5, preventing a fast rank-0 cleanup
from stranding a slower peer or splitting sequential rootinfo generations
Validation
markdownlint, Ruff, and pyright
pytest pass
two-frame scene and TMR L3 dependency smoke passed
communicator lifecycle and two-rank TMR allreduce both passed