Skip to content

Refactor: drop _prepared_ prefix from internal DeviceRunner callable methods#911

Merged
ChaoWao merged 1 commit into
hw-native-sys:mainfrom
hw-native-sys-bot:rename-drop-prepared-prefix
May 30, 2026
Merged

Refactor: drop _prepared_ prefix from internal DeviceRunner callable methods#911
ChaoWao merged 1 commit into
hw-native-sys:mainfrom
hw-native-sys-bot:rename-drop-prepared-prefix

Conversation

@hw-native-sys-bot

Copy link
Copy Markdown
Collaborator

Summary

Pure rename PR. Drops the meaningless _prepared_ infix from internal DeviceRunner methods and supporting types. With only one registration path remaining today, the prefix is dead naming and creates an awkward asymmetry with the public C API (prepare_callable / unregister_callable / run_prepared).

Renames

Old New
DeviceRunner::register_prepared_callable[_host_orch] register_callable[_host_orch]
DeviceRunner::has_prepared_callable has_callable
DeviceRunner::unregister_prepared_callable unregister_callable (matches c_api)
DeviceRunner::bind_prepared_callable_to_runtime bind_callable_to_runtime
prepared_callables_ (map) callables_
PreparedCallableState (struct) CallableState
BindPreparedCallableResult (struct) BindCallableResult
PreparedCallableArtifacts (struct) CallableArtifacts
bind_prepared_to_runtime_impl (free fn) bind_callable_to_runtime_impl

What's unchanged

Public API surface keeps its original names because the verb "prepared" carries real meaning there:

  • prepare_callable (public Python + c_api — "prepare this callable")
  • run_prepared (public Python + c_api — "run something previously prepared")
  • aicpu_dlopen_count / host_dlopen_count (public diagnostics)
  • unregister_callable (public c_api — already had this name, now method matches)

Verification

  • Both arches built clean (onboard + sim, both runtimes).
  • a2a3 local smoke (dummy_task + full prepared_callable suite) — 7/7 passed in 11s.

Test plan

  • CI st-sim-a2a3 / st-sim-a5
  • CI st-onboard-a2a3 / st-onboard-a5
  • CI ut-a2a3 / ut-a5

… methods

Internal DeviceRunner methods carried a `_prepared_` infix that historically
distinguished "register-via-the-prepare_callable-path" from a now-removed
eager-register path. With only one path remaining, the prefix is dead
naming and creates an asymmetry with the public C API
(`prepare_callable` / `unregister_callable` / `run_prepared`).

Renames (pure mechanical, no behavior change):
- `DeviceRunner::register_prepared_callable[_host_orch]` → `register_callable[_host_orch]`
- `DeviceRunner::has_prepared_callable` → `has_callable`
- `DeviceRunner::unregister_prepared_callable` → `unregister_callable`
- `DeviceRunner::bind_prepared_callable_to_runtime` → `bind_callable_to_runtime`
- `prepared_callables_` → `callables_`
- `PreparedCallableState` → `CallableState`
- `BindPreparedCallableResult` → `BindCallableResult`
- `PreparedCallableArtifacts` → `CallableArtifacts`
- `bind_prepared_to_runtime_impl` → `bind_callable_to_runtime_impl` (runtime_maker)

Public Python / c_api entry points (`prepare_callable`, `run_prepared`,
`aicpu_dlopen_count`, `host_dlopen_count`) and the public
`unregister_callable` free function are unchanged — those names have real
semantic meaning ("prepare the callable", "run something previously
prepared").

Both arches built clean (onboard + sim, both runtimes). a2a3 local smoke
(dummy_task, prepared_callable suite) 7/7 passed in 11s.
@coderabbitai

coderabbitai Bot commented May 30, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR systematically renames the callable-registration and binding APIs from "prepared_callable" to "callable" terminology across all DeviceRunner platform implementations (a2a3 onboard, a2a3 simulation, a5 onboard, a5 simulation), updating type names, method signatures, internal state storage, runtime-binding implementations, and documentation.

Changes

Callable API Rename

Layer / File(s) Summary
Common artifact and result type renames
src/common/task_interface/prepare_callable_common.h
PreparedCallableArtifactsCallableArtifacts and BindPreparedCallableResultBindCallableResult with updated docstrings describing artifact lifecycle and binding semantics for hbg and tensormap-ringbuffer paths.
DeviceRunner public method signatures (all four platforms)
src/a2a3/platform/onboard/host/device_runner.h, src/a2a3/platform/sim/host/device_runner.h, src/a5/platform/onboard/host/device_runner.h, src/a5/platform/sim/host/device_runner.h
All platform variants rename register_prepared_callable*, unregister_prepared_callable, has_prepared_callable, and bind_prepared_callable_to_runtime methods; internal state renamed from PreparedCallableState/prepared_callables_ to CallableState/callables_; docstrings updated to match new naming.
Runtime binding implementations
src/a2a3/runtime/host_build_graph/host/runtime_maker.cpp, src/a2a3/runtime/tensormap_and_ringbuffer/host/runtime_maker.cpp, src/a5/runtime/host_build_graph/host/runtime_maker.cpp, src/a5/runtime/tensormap_and_ringbuffer/host/runtime_maker.cpp
prepare_callable_impl() outputs CallableArtifacts; per-run binding entry point renamed from bind_prepared_to_runtime_impl to bind_callable_to_runtime_impl across both subsystems and both platforms, with updated error messages and documentation.
a2a3 onboard DeviceRunner implementation and C API wiring
src/a2a3/platform/onboard/host/device_runner.cpp, src/a2a3/platform/onboard/host/pto_runtime_c_api.cpp
prepare_orch_so() resolves from callables_ map; register_callable() validates and deduplicates orch SO; host-orch registration and unregistration manage dlopen handles; binding replays kernel addresses and returns orchestration metadata. C API wiring updated to use new DeviceRunner methods and CallableArtifacts.
a2a3 simulation DeviceRunner implementation and C API wiring
src/a2a3/platform/sim/host/device_runner.cpp, src/a2a3/platform/sim/host/pto_runtime_c_api.cpp
Same callable API contract as onboard: state resolution from callables_, deduplication and validation in registration, host-orch management, kernel address replay in binding. C API updated to use callable variants and CallableArtifacts.
a5 onboard DeviceRunner implementation and C API wiring
src/a5/platform/onboard/host/device_runner.cpp, src/a5/platform/onboard/host/pto_runtime_c_api.cpp
Validates bounds, computes ELF build-id hash for orch SO deduplication via orch_so_dedup_ refcounted map, stores device addresses and metadata in CallableState, implements host-orch registration with dlopen counter and unregistration with refcount cleanup. C API wiring updated for callable variants.
a5 simulation DeviceRunner implementation and C API wiring
src/a5/platform/sim/host/device_runner.cpp, src/a5/platform/sim/host/pto_runtime_c_api.cpp
Validates and deduplicates orch SO via orch_so_dedup_ hash map with refcounting, stores metadata in CallableState, manages host dlopen handles with increment/decrement on register/unregister, implements kernel address replay during binding. C API wiring updated to call renamed DeviceRunner methods.
Runtime documentation and comment updates
src/a2a3/runtime/host_build_graph/runtime/runtime.h, src/a2a3/runtime/tensormap_and_ringbuffer/runtime/runtime.h, src/a5/runtime/tensormap_and_ringbuffer/runtime/runtime.h, python/simpler/worker.py, src/a2a3/runtime/tensormap_and_ringbuffer/aicpu/aicpu_executor.cpp, src/common/task_interface/callable_protocol.h, tests/st/a2a3/host_build_graph/prepared_callable/test_prepared_callable.py, tests/ut/py/test_worker/test_host_worker.py
Updated inline comments and documentation in runtime.h files to reference bind_callable_to_runtime and bind_callable_to_runtime_impl instead of prepared-callable variants. Updated comments in worker code, AICPU executor, callable protocol, and test files referencing the renamed APIs.

🎯 4 (Complex) | ⏱️ ~60 minutes

🐰 A hop, skip, and jump across the codebase—
From onboard to sim, from a2a3 to a5 so fine,
"Prepared" is gone, now "callable" takes the place,
Types, methods, and comments all in line! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 30.19% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main refactoring: dropping the 'prepared' prefix from internal DeviceRunner callable methods, which aligns with the changeset.
Description check ✅ Passed The description is detailed and directly related to the changeset, explaining the rationale, listing all renames, clarifying what remains unchanged, and providing verification details.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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 and usage tips.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request performs a comprehensive refactoring across the codebase to simplify terminology by renaming 'prepared callable' references to simply 'callable'. This includes renaming classes (e.g., PreparedCallableState to CallableState, PreparedCallableArtifacts to CallableArtifacts), functions (e.g., register_prepared_callable to register_callable, bind_prepared_callable_to_runtime to bind_callable_to_runtime), member variables, and associated comments across Python, C++, and test files. No review comments were provided, so there is no additional feedback to address.

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/a2a3/runtime/tensormap_and_ringbuffer/host/runtime_maker.cpp (1)

97-109: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Remove the stale @param runtime entry from this docblock.

prepare_callable_impl no longer takes a Runtime *, so this comment now documents a nonexistent parameter.

🤖 Prompt for 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.

In `@src/a2a3/runtime/tensormap_and_ringbuffer/host/runtime_maker.cpp` around
lines 97 - 109, Remove the stale "`@param` runtime" line from the docblock above
prepare_callable_impl since the function signature no longer accepts a Runtime
pointer; update the comment to only document the current parameters (callable,
upload_fn, out) and return value so the docblock matches the
prepare_callable_impl declaration and related symbols like CallableArtifacts and
ChipCallable.
src/a5/runtime/tensormap_and_ringbuffer/host/runtime_maker.cpp (1)

97-109: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Drop the stale @param runtime line here too.

The comment still documents a Runtime * parameter that is no longer part of prepare_callable_impl.

🤖 Prompt for 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.

In `@src/a5/runtime/tensormap_and_ringbuffer/host/runtime_maker.cpp` around lines
97 - 109, The function comment above prepare_callable_impl still documents a
removed Runtime* parameter; update the docblock for prepare_callable_impl by
removing the stale "`@param` runtime" line (and any accompanying description) so
the comment accurately reflects the current signature
(prepare_callable_impl(const ChipCallable*, uint64_t (*upload_fn)(const void *),
CallableArtifacts*)). Ensure remaining `@param` entries match the actual
parameters (callable, upload_fn, out) and keep the rest of the explanatory text
unchanged.
🧹 Nitpick comments (1)
src/a5/runtime/tensormap_and_ringbuffer/runtime/runtime.h (1)

300-303: ⚡ Quick win

Finish the terminology rename in this comment.

After switching the API reference to bind_callable_to_runtime, "prepared kernel binaries" is now the odd term out in the same sentence. Consider renaming it to "callable kernel binaries" for consistency.

🤖 Prompt for 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.

In `@src/a5/runtime/tensormap_and_ringbuffer/runtime/runtime.h` around lines 300 -
303, Update the comment in runtime.h to use consistent terminology: replace
"prepared kernel binaries" with "callable kernel binaries" in the comment that
documents replaying a previously-uploaded kernel address onto a fresh Runtime
(the block referencing bind_callable_to_runtime, registered_kernel_func_ids_,
and validate_runtime_impl) so the phrasing matches the API rename to
bind_callable_to_runtime.
🤖 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.

Outside diff comments:
In `@src/a2a3/runtime/tensormap_and_ringbuffer/host/runtime_maker.cpp`:
- Around line 97-109: Remove the stale "`@param` runtime" line from the docblock
above prepare_callable_impl since the function signature no longer accepts a
Runtime pointer; update the comment to only document the current parameters
(callable, upload_fn, out) and return value so the docblock matches the
prepare_callable_impl declaration and related symbols like CallableArtifacts and
ChipCallable.

In `@src/a5/runtime/tensormap_and_ringbuffer/host/runtime_maker.cpp`:
- Around line 97-109: The function comment above prepare_callable_impl still
documents a removed Runtime* parameter; update the docblock for
prepare_callable_impl by removing the stale "`@param` runtime" line (and any
accompanying description) so the comment accurately reflects the current
signature (prepare_callable_impl(const ChipCallable*, uint64_t
(*upload_fn)(const void *), CallableArtifacts*)). Ensure remaining `@param`
entries match the actual parameters (callable, upload_fn, out) and keep the rest
of the explanatory text unchanged.

---

Nitpick comments:
In `@src/a5/runtime/tensormap_and_ringbuffer/runtime/runtime.h`:
- Around line 300-303: Update the comment in runtime.h to use consistent
terminology: replace "prepared kernel binaries" with "callable kernel binaries"
in the comment that documents replaying a previously-uploaded kernel address
onto a fresh Runtime (the block referencing bind_callable_to_runtime,
registered_kernel_func_ids_, and validate_runtime_impl) so the phrasing matches
the API rename to bind_callable_to_runtime.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0e2c7584-1e2e-4643-9112-34c944aef3d1

📥 Commits

Reviewing files that changed from the base of the PR and between eadc0ee and b58965a.

📒 Files selected for processing (26)
  • python/simpler/worker.py
  • src/a2a3/platform/onboard/host/device_runner.cpp
  • src/a2a3/platform/onboard/host/device_runner.h
  • src/a2a3/platform/onboard/host/pto_runtime_c_api.cpp
  • src/a2a3/platform/sim/host/device_runner.cpp
  • src/a2a3/platform/sim/host/device_runner.h
  • src/a2a3/platform/sim/host/pto_runtime_c_api.cpp
  • src/a2a3/runtime/host_build_graph/host/runtime_maker.cpp
  • src/a2a3/runtime/host_build_graph/runtime/runtime.h
  • src/a2a3/runtime/tensormap_and_ringbuffer/aicpu/aicpu_executor.cpp
  • src/a2a3/runtime/tensormap_and_ringbuffer/host/runtime_maker.cpp
  • src/a2a3/runtime/tensormap_and_ringbuffer/runtime/runtime.h
  • src/a5/platform/onboard/host/device_runner.cpp
  • src/a5/platform/onboard/host/device_runner.h
  • src/a5/platform/onboard/host/pto_runtime_c_api.cpp
  • src/a5/platform/sim/host/device_runner.cpp
  • src/a5/platform/sim/host/device_runner.h
  • src/a5/platform/sim/host/pto_runtime_c_api.cpp
  • src/a5/runtime/host_build_graph/host/runtime_maker.cpp
  • src/a5/runtime/tensormap_and_ringbuffer/aicpu/aicpu_executor.cpp
  • src/a5/runtime/tensormap_and_ringbuffer/host/runtime_maker.cpp
  • src/a5/runtime/tensormap_and_ringbuffer/runtime/runtime.h
  • src/common/task_interface/callable_protocol.h
  • src/common/task_interface/prepare_callable_common.h
  • tests/st/a2a3/host_build_graph/prepared_callable/test_prepared_callable.py
  • tests/ut/py/test_worker/test_host_worker.py

@ChaoWao ChaoWao merged commit 1469d79 into hw-native-sys:main May 30, 2026
16 checks passed
@ChaoWao ChaoWao deleted the rename-drop-prepared-prefix branch May 30, 2026 07:47
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.

2 participants