Skip to content

Test: prove the sim runner publishes launch acceptance - #1649

Merged
ChaoWao merged 1 commit into
hw-native-sys:mainfrom
ChaoWao:strict-runtime-symbols
Aug 3, 2026
Merged

Test: prove the sim runner publishes launch acceptance#1649
ChaoWao merged 1 commit into
hw-native-sys:mainfrom
ChaoWao:strict-runtime-symbols

Conversation

@ChaoWao

@ChaoWao ChaoWao commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds the missing regression barrier for launch-acceptance publication on sim.

This PR started as the strict-symbol-loading refactor and has been narrowed to
the test.
#1587 merged as 2a650f2d while this was open and landed the whole
refactor independently — all four symbols strict, load_optional_symbol
deleted, the sim set_task_accepted_state_ctx export, the dead nullptr guards
removed, and the header docs updated. I verified main against my diff
line-by-line and it is equivalent throughout, so I dropped my src/ changes
wholesale on rebase rather than churn a mechanism that had already shipped.

The one difference in approach: for get_pipeline_contract — absent from a5's
runtime makers — I had put a weak depth-1 default in both platform
c_api_shared.cpp
, matching prewarm_config_impl; main instead added
strong definitions to a5's two runtime_maker.cpp. Both give a5 the
depth-1 contract, main's is explicit at the cost of the literal appearing in
two more places, and I checked a5's host_build_graph definition sits inside
extern "C" { so its linkage is right. Main's version stands.

What is left, and why it is worth landing

Nothing asserted the accepted word ever arrives. The two endpoint scene
tests that read it (worker_async_endpoint, worker_async_fifo) assert it is
still 0 before activation — the negative direction — and both are
a2a3-onboard-only, so the sim side of the binding had no coverage at all.

That gap hid a real defect until #1587. The sim c_api exported no
set_task_accepted_state_ctx, so ChipWorker's then-optional load produced
nullptr, both bind sites were skipped, and SimDeviceRunnerBase::publish_task_accepted
found a null target. A sim child therefore never published acceptance, and the
run-level fence — LocalMailboxEndpoint::read_task_acceptedon_accept
Orchestrator::mark_task_accepteddecrement_run_accepts — advanced only
once the run reached a terminal phase, because acceptance_ready() was
satisfied by its other disjunct. The launch fence silently degraded into a
completion fence on every sim run.

worker.py passes the accepted-word address on every platform (single-frame
run_from_blob and two-frame _launch_native_run, neither platform-gated), and
the sim runner does reach publish_task_accepted() at its launch boundary — so
this was never "sim doesn't use the accepted word", only an unexported symbol.

The test dispatches one ChipTask and asserts the word is set in whichever
mailbox frame carried it. That holds on both endpoint shapes because the parent
clears the word only when it publishes the next task into that frame, so it
survives completion.

Verified to actually catch the regression: against the pre-#1587 sim c_api
it fails with

E  AssertionError: the chip worker never published launch acceptance: [0, 0, 0]
E  assert 1 in [0, 0, 0]

Testing

At the rebased base (2a650f2d):

  • a2a3sim — this test: passed
  • a2a3 onboard via task-submit (task_20260803_010730_25475769728, 1 device) — this test: passed on real silicon
  • pre-commit on the changed file: all hooks passed

From the pre-rebase run of the full refactor (superseded by #1587, but the test
was present throughout): cpput 74/74 · pyut 1034 passed / 9 skipped · a2a3sim
sweep 63 PASS 0 FAIL · a5sim sweep 47 PASS 0 FAIL · a2a3 onboard sweep 62 PASS
0 FAIL before the run hit the 600 s --pto-session-timeout budget in its last
group on this shared box.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The change adds weak pipeline-contract providers, exposes simulated accepted-state publication, requires runtime symbols and valid contracts in ChipWorker, and adds an L3 acceptance test that verifies _TASK_ACCEPTED mailbox publication.

Changes

Pipeline Contract and Launch Acceptance

Layer / File(s) Summary
Runtime contract and acceptance APIs
src/common/platform/onboard/host/c_api_shared.cpp, src/common/platform/sim/host/c_api_shared.cpp, src/common/worker/pto_runtime_c_api.h
The hosts provide weak pipeline-contract defaults. The simulator exposes set_task_accepted_state_ctx. The header documents required pipeline exports and launch-boundary publication.
Mandatory worker runtime integration
src/common/worker/chip_worker.cpp
ChipWorker loads required symbols, validates the runtime pipeline contract, and binds accepted-state storage without optional-function checks.
L3 launch acceptance validation
tests/st/a2a3/tensormap_and_ringbuffer/test_l3_launch_acceptance.py
The scene test validates vector-kernel output and confirms _TASK_ACCEPTED publication in mailbox frames.

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

Sequence Diagram(s)

sequenceDiagram
  participant ChipWorker
  participant set_task_accepted_state_ctx
  participant SimDeviceRunnerBase
  participant MailboxFrames
  ChipWorker->>set_task_accepted_state_ctx: bind accepted-state pointer at launch
  set_task_accepted_state_ctx->>SimDeviceRunnerBase: publish accepted state
  SimDeviceRunnerBase->>MailboxFrames: publish sticky _TASK_ACCEPTED word
  MailboxFrames-->>ChipWorker: expose launch-acceptance frame
Loading

Possibly related PRs

Poem

A rabbit watched the launch bell ring,
Contracts guided every thing.
The worker bound acceptance bright,
Mailbox frames confirmed the flight.
“_TASK_ACCEPTED!” hopped the queue.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly describes the added simulation launch-acceptance test, which is a significant part of the changeset.
Description check ✅ Passed The description explains the launch-acceptance test, related runtime changes, regression cause, and verification results.

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 `@tests/st/a2a3/tensormap_and_ringbuffer/test_l3_launch_acceptance.py`:
- Around line 50-91: Import ClassVar and annotate the scene-test metadata fields
CALLABLE and CASES as ClassVar with their existing value types, preserving their
contents and class-level behavior.
🪄 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: 77d4ba1d-bb76-42cd-a3fb-914c8096c599

📥 Commits

Reviewing files that changed from the base of the PR and between 810fbcd and e7ddbab.

📒 Files selected for processing (5)
  • src/common/platform/onboard/host/c_api_shared.cpp
  • src/common/platform/sim/host/c_api_shared.cpp
  • src/common/worker/chip_worker.cpp
  • src/common/worker/pto_runtime_c_api.h
  • tests/st/a2a3/tensormap_and_ringbuffer/test_l3_launch_acceptance.py

Comment thread tests/st/a2a3/tensormap_and_ringbuffer/test_l3_launch_acceptance.py
A ChipTask's sticky acceptance word is written by the platform runner once
the run crosses its launch boundary, through the set_task_accepted_state_ctx
binding ChipWorker resolves at init. Nothing asserted that it arrives: the
two endpoint scene tests that read the word assert it is still 0 before
activation, and both are a2a3-onboard-only, so the sim side of the binding
had no coverage at all.

That gap hid a real defect until hw-native-sys#1587. The sim c_api exported no
set_task_accepted_state_ctx, so ChipWorker's then-optional load produced
nullptr, both bind sites were skipped, and SimDeviceRunnerBase's
publish_task_accepted stored through a null pointer target. A sim child
therefore never published acceptance, and the run-level fence
(decrement_run_accepts, reached via LocalMailboxEndpoint::read_task_accepted)
advanced only when the run reached a terminal phase — the launch fence
silently degraded into a completion fence.

The test dispatches one ChipTask and asserts the word is set in whichever
mailbox frame carried it, which holds on both endpoint shapes: the parent
clears the word only when it publishes the next task into that frame.
Verified to fail against the pre-hw-native-sys#1587 sim c_api with
"the chip worker never published launch acceptance: [0, 0, 0]".
@ChaoWao
ChaoWao force-pushed the strict-runtime-symbols branch from e7ddbab to 6cf7efe Compare August 3, 2026 08:07
@ChaoWao ChaoWao changed the title Refactor: load every uniformly-exported runtime symbol strictly Test: prove the sim runner publishes launch acceptance Aug 3, 2026
@ChaoWao

ChaoWao commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator Author

Narrowed after #1587 landed.

#1587 merged as 2a650f2d while this was open and independently landed the strict-symbol-loading refactor this PR opened with — all four symbols on load_symbol, load_optional_symbol deleted, the sim set_task_accepted_state_ctx export, the dead nullptr guards dropped, and the header docs updated. I diffed main against my version and it is equivalent throughout, so I took main's src/ wholesale on rebase instead of churning a mechanism that already shipped.

One approach difference, resolved in main's favour: for get_pipeline_contract I had a weak depth-1 default in both platform c_api_shared.cpp (mirroring prewarm_config_impl); main added strong definitions to a5's two runtime_maker.cpp. Same outcome for a5, and I checked a5's host_build_graph definition is inside extern "C" {, so its linkage is correct.

What is left is the test, which main has no equivalent of — the two endpoint tests that read the acceptance word assert it is still 0 before activation and are a2a3-onboard-only, so the sim binding had no coverage. It is verified to fail against the pre-#1587 sim c_api. Body updated with the full rationale.

@ChaoWao
ChaoWao merged commit c975b61 into hw-native-sys:main Aug 3, 2026
15 checks passed
@ChaoWao
ChaoWao deleted the strict-runtime-symbols branch August 3, 2026 08:26
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