Skip to content

Fix: state the post-B4 runner geometry, stream, and TLS contracts - #1653

Merged
ChaoWao merged 1 commit into
hw-native-sys:mainfrom
ChaoWao:fix-b4-postmerge-hardening
Aug 3, 2026
Merged

Fix: state the post-B4 runner geometry, stream, and TLS contracts#1653
ChaoWao merged 1 commit into
hw-native-sys:mainfrom
ChaoWao:fix-b4-postmerge-hardening

Conversation

@ChaoWao

@ChaoWao ChaoWao commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #1587. It moved three contracts without moving the text that described them, and left one failure mode expressed as a noexcept violation.

Geometry. resolve_block_dim() and prepare_launch_shape() no longer write block_dim_ / worker_count_; activate_launch_shape() latches both on the executor thread immediately before run(). Both onboard run() bodies still carried a comment and a LOG_ERROR naming prepare_launch_shape, so the one diagnostic a future reader greps pointed at a function that latches nothing. #1521 later edited the line directly below that comment and left it standing.

The simulation runners are deliberately untouched: SimDeviceRunnerBase::prepare_launch_shape does still assign block_dim_, so their wording is correct. The two remaining references — call_config.h and the HBG runtime_maker.cpp — are also correct, since prepare_launch_shape still publishes worker_count onto the Runtime.

Streams. RunStreamSlots became a two-thread class when native prepare started provisioning the successor's slot while the executor retires the predecessor's. Per-slot handles are safe — admission gives each slot one owner — but created_count_ is shared across owners and is also read from an unrelated thread through get_run_stream_set_create_count (and asserted by run_stream_reuse). It is now std::atomic<size_t>, and the ownership rule is stated on the class.

Thread selection. restore_native_run_thread_selection was noexcept while run_selection() could throw: on a thread created by create_thread the per-thread block does not exist yet, so installation allocates. Split out a non-throwing try_run_selection() and let restore abort with a message on the unrecoverable path. Returning instead would leave the thread on the default slot and bank, addressing storage another lease owns, and a freshly started thread has no channel to report the failure through.

Symbol loading. Since every required pipeline symbol became a strict load in #1587, the dominant cause of a dlsym failure is a host runtime out of sync with the tree that consumes it. The error now says so instead of reporting only the missing name.

Two readability items alongside: occupied != 0 && occupied != 1 becomes occupied > 1 (the loop above it has already rejected every predecessor that may not carry a successor), and the simulation set_native_run_identity_ctx records that it discards identity by design.

No behavior change outside the abort path. B6c in the pipeline plan removes the TLS mechanism outright; until then the failure is diagnosable rather than a bare terminate.

Testing

  • pre-commit on every changed file — all hooks pass (clang-format, clang-tidy, cpplint, headers, English-only)
  • Editable rebuild: all 2 arch x 2 platform x 2 runtime host DSOs
  • C++ unit tests: 74/74 passed
  • Python unit tests: 1050 passed, 13 skipped
  • a2a3sim tests/st/a2a3: HBG 17 passed / 4 skipped, TMR 38 passed, L3 resource phase all PASS
  • a2a3 onboard via task-submit, devices 3+5: 7 passed across worker_async_fifo, worker_async_endpoint, native_run_lifecycle, and run_stream_reuse — the last is the direct consumer of created_count
  • a5 onboard — covered by CI st-onboard-a5 (the local a5 pool was unavailable); the a5 change is a comment and a log string in a path a5 shares with a2a3

@coderabbitai

coderabbitai Bot commented Aug 3, 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: 41 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 Plus

Run ID: e4fa7c38-8944-4abe-af64-61d1e2844a5e

📥 Commits

Reviewing files that changed from the base of the PR and between c975b61 and 90fb9e5.

📒 Files selected for processing (7)
  • src/a2a3/platform/onboard/host/device_runner.cpp
  • src/a5/platform/onboard/host/device_runner.cpp
  • src/common/platform/include/host/run_stream_slots.h
  • src/common/platform/onboard/host/device_runner_base.cpp
  • src/common/platform/onboard/host/device_runner_base.h
  • src/common/platform/sim/host/c_api_shared.cpp
  • src/common/worker/chip_worker.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.

hw-native-sys#1587 moved three contracts without moving the text that described them, and
left one failure mode expressed as a noexcept violation.

Geometry. resolve_block_dim() and prepare_launch_shape() no longer write
block_dim_ or worker_count_; activate_launch_shape() latches both on the
executor thread immediately before run(). The comment and the LOG_ERROR in
each onboard run() still named prepare_launch_shape, so the one diagnostic a
future reader greps pointed at a function that latches nothing. hw-native-sys#1521 later
edited the line directly below that comment and left it standing, which is
how a stale comment survives. The simulation runners keep their wording:
SimDeviceRunnerBase::prepare_launch_shape does still assign block_dim_.

Streams. RunStreamSlots became a two-thread class when native prepare started
provisioning the successor's slot while the executor retires the
predecessor's. Per-slot handles are safe — admission gives each slot one
owner — but created_count_ is shared across owners and is also read from an
unrelated thread through get_run_stream_set_create_count, so it is now
atomic and the ownership rule is stated on the class.

Thread selection. restore_native_run_thread_selection was noexcept while
run_selection() could throw: on a thread created by create_thread the
per-thread block does not exist yet, so installation allocates. Split out a
non-throwing try_run_selection() and let restore abort with a message on the
unrecoverable path. Returning instead would leave the thread on the default
slot and bank, addressing storage another lease owns, and a freshly started
thread has no channel to report the failure through. B6c removes the
mechanism outright; until then the failure is diagnosable rather than a bare
terminate.

Symbol loading. Since every required pipeline symbol became a strict load,
the dominant cause of a dlsym failure is a host runtime out of sync with the
tree that consumes it. Say so in the error, which otherwise reports only the
missing name.

Also spell the successor-already-staged test as occupied > 1, since the loop
above it has already rejected every predecessor that may not carry one, and
record that simulation discards native-run identity by design.
@ChaoWao
ChaoWao force-pushed the fix-b4-postmerge-hardening branch from 098e55c to 90fb9e5 Compare August 3, 2026 09:07
@ChaoWao
ChaoWao merged commit 673aece into hw-native-sys:main Aug 3, 2026
18 checks passed
@ChaoWao
ChaoWao deleted the fix-b4-postmerge-hardening branch August 3, 2026 10:41
Crane-Liu added a commit to Crane-Liu/simpler that referenced this pull request Aug 3, 2026
Rebase the common active-plus-prepared ownership on current main without weakening the uniform pipeline ABI from hw-native-sys#1587 or the runner geometry, stream, and TLS contracts from hw-native-sys#1653. Add generation-bound direct L2 RunHandles, bounded two-slot admission, launch-only acceptance waiting, and deterministic depth-one fallback while preserving HBG inactive-bank preparation. Remove timing-dependent endpoint assertions and keep RequestSession absent.
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