Skip to content

Add: OrchestrationRuntime vtable for host_build_graph, decouple orch from runtime.h#449

Merged
ChaoWao merged 1 commit intohw-native-sys:mainfrom
hw-native-sys-bot:feat/hbg-platform
Apr 3, 2026
Merged

Add: OrchestrationRuntime vtable for host_build_graph, decouple orch from runtime.h#449
ChaoWao merged 1 commit intohw-native-sys:mainfrom
hw-native-sys-bot:feat/hbg-platform

Conversation

@hw-native-sys-bot
Copy link
Copy Markdown
Collaborator

@hw-native-sys-bot hw-native-sys-bot commented Apr 3, 2026

Summary

Introduce an opaque OrchestrationRuntime + function-pointer table (orchestration_api.h) so host_build_graph orchestration SOs no longer include runtime.h. Orchestration sources now include only orchestration_api.h and interact with the runtime through stable free-function wrappers.

  • orchestration_api.h (a2a3 + a5): C-compatible vtable with static inline helpers — add_task, add_successor, record_tensor_pair, device_malloc, device_free, copy_to_device, get_task_count, print_runtime
  • runtime_maker.cpp (a2a3 + a5): wraps Runtime* in OrchestrationRuntimeImpl, calls orchestration function as OrchestrationFunc(OrchestrationRuntime*, orch_args); SO loading delegated to platform via extern "C" load_orch_so (sim: mkstemp; onboard: getpid path), implemented in pto_runtime_c_api.cpp
  • build_config.py (a2a3 + a5): add orchestration compile target so kernel_compiler resolves orchestration_api.h
  • Example orchestration sources migrated (bgemm, matmul, paged_attention, vector_example for a2a3 + a5)
  • tests/st host_build_graph paged_attention orchestration migrated
  • Docs updated (INCORE_ORCHESTRATION_GUIDE, RUNTIME_LOGIC, scripts/README, code_runner.py)

Testing

  • python ci.py -p a2a3sim -c 6622890 -t 600 --build-runtime — 15/15 PASS

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

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 refactors the loading of orchestration shared objects across the a2a3 and a5 platforms by introducing a platform-specific load_orch_so function. The changes unify temporary file creation and loading logic, ensuring files are unlinked immediately after use. Feedback includes suggestions to improve the robustness of the onboard implementation by using mkstemp and a complete write loop, restoring dlerror() in error logs for better observability, and removing now-redundant member variables and cleanup logic related to the SO file path.

@hw-native-sys-bot hw-native-sys-bot changed the title Refactor: encapsulate orchestration SO file I/O in platform layer Add: OrchestrationRuntime vtable for host_build_graph, decouple orch from runtime.h Apr 3, 2026
…from runtime.h

Introduce an opaque OrchestrationRuntime + function-pointer table
(orchestration_api.h) so host_build_graph orchestration SOs no longer
include runtime.h.  Orchestration sources include only orchestration_api.h
and interact with the runtime through free-function wrappers.

- orchestration_api.h (a2a3 + a5): C-compatible vtable with inline helpers
  add_task, add_successor, record_tensor_pair, device_malloc, device_free,
  copy_to_device, get_task_count, print_runtime
- runtime_maker.cpp: wraps Runtime* in OrchestrationRuntimeImpl, calls orch
  function as OrchestrationFunc(OrchestrationRuntime*, orch_args); SO loading
  delegated to platform via extern-C load_orch_so (sim: mkstemp,
  onboard: getpid path) implemented in pto_runtime_c_api.cpp
- build_config.py (a2a3 + a5): add orchestration compile target with
  include_dirs so kernel_compiler resolves orchestration_api.h
- All host_build_graph example orchestration sources (bgemm, matmul,
  paged_attention, vector_example for a2a3 + a5) migrated to new API
- tests/st host_build_graph paged_attention orchestration migrated
- Docs updated (INCORE_ORCHESTRATION_GUIDE.md, RUNTIME_LOGIC.md,
  scripts/README.md, code_runner.py)

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@ChaoWao ChaoWao merged commit 6912849 into hw-native-sys:main Apr 3, 2026
10 checks passed
@ChaoWao ChaoWao deleted the feat/hbg-platform branch April 3, 2026 11:51
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