Repository navigation
Fix: bind runner TLS during arena prewarm - #1401
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the simpler_init function in both src/common/platform/onboard/host/c_api_shared.cpp and src/common/platform/sim/host/c_api_shared.cpp to establish a thread-local binding for the device runner (g_runner_key) using pthread_setspecific. It also introduces an RAII scope guard to ensure the thread-specific data is cleared upon exiting the function. There are no review comments to address, and I have no additional feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
📝 WalkthroughWalkthroughInitialization now scopes the provided device runner in thread-local storage for HostApi callbacks on onboard and simulator paths. A regression test covers L2 worker initialization with ChangesPrewarm runner binding
Estimated code review effort: 2 (Simple) | ~10 minutes 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 |
0492e7a to
1d91afd
Compare
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
Suggest adding an in-repo regression test. This is a bugfix, but validation currently rests entirely on downstream pypto#2085 — simpler's own CI stays green because nothing in-repo passes The repro is small (~20–40 lines, no golden/args boilerplate needed) since L2 trb prewarm runs synchronously inside
If it can't land in this PR, worth filing an issue to track it. |
HostApi callbacks recover the active DeviceRunner through thread-local storage. Bind and clear that runner for the full simpler_init call so eager arena prewarming cannot dereference a null runner on sim or onboard. Add an a2a3sim TRB regression test that initializes a fresh L2 Worker with non-default ring sizing so this path remains covered in-repo.
1d91afd to
7f7082c
Compare
|
Added in |
|
CI is green except |
## Summary - preserve YunjiQin's `4e352b26` prebuilt runtime-arena prewarm commit from #2068 unchanged - advance the runtime submodule to the merged Simpler fix from hw-native-sys/simpler#1401 - rely on Simpler's public `Worker.init()` to perform eager L3+ startup instead of invoking the private startup hook twice - clarify the prewarm/dispatch config relationship in both language versions of the docs ## Root cause The eager prewarm path calls context-free `HostApi` callbacks during `simpler_init`. Those callbacks recover the active runner through `current_runner()`, but the runner TLS was not bound during initialization. A non-null `prewarm_config` therefore dereferenced a null runner. Merged Simpler also makes `Worker.init()` eagerly initialize the full L3+ hierarchy. PyPTO must not call `_start_hierarchical()` again after `init()`; doing so attempts to register workers after the scheduler is initialized. ## Commit structure 1. `4e352b26` — original #2068 commit by YunjiQin 2. `0fb2dfe4` — merged Simpler integration, eager-init compatibility, and review-driven documentation clarification ## Testing - [x] `git diff --check` - [x] Simpler #1401 added an in-repo a2a3sim TRB regression test and was merged as `8cdb306c` - [x] the previous PyPTO runtime-fix revision passed the complete CI matrix, including all five system jobs that failed on #2068 - [x] PyPTO full CI passed against the official merged Simpler commit, including distributed, device, simulator, and model integration jobs Local pytest/build was not run because the 16 GB development host had only 0.89 GB available RAM; PR CI provides the required build and simulator/device coverage. ## Related PRs - Merged Simpler runtime fix: hw-native-sys/simpler#1401 - Built on #2068 --------- Co-authored-by: YunjiQin <a1339924773@gmail.com> Co-authored-by: ChenShenAi <chenshenai@huawei.com>
Summary
DeviceRunnerin thread-local storage for the fullsimpler_init()callRAIIScopeGuardWorker.init(prewarm_config=...)Root cause
HostApicallbacks recover the current runner through thread-local storage. The eager prewarm path runs duringsimpler_init(), before the existing register/run entry points establish that binding.Validation
git diff --checkclang-format --dry-run --Werroron both modified C++ filestest_prewarm_config.pyA full local runtime rebuild was not run because the development host had only 3.07 GB available RAM; PR CI provides the runtime build and simulator execution.
Related