From c22d5e8e8463af96ddce2a999c56bdabbe40e591 Mon Sep 17 00:00:00 2001 From: Chao Wang <26245345+ChaoWao@users.noreply.github.com> Date: Sat, 11 Jul 2026 10:46:13 +0000 Subject: [PATCH] Fix: compile host_build_graph orchestration with host g++ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit host_build_graph dlopens the orchestration .so on the x86_64 host, but compile_orchestration routed a2a3/a5 to the aarch64 cross-compiler unconditionally — that routing predates host_build_graph. The AArch64 orch .so could not be dlopened by the x86_64 host runtime, surfacing as "dlopen failed: ... No such file or directory" and failing every host_build_graph scene test on a2a3 onboard. Route the orch toolchain by runtime instead of only by platform: host_build_graph uses HOST_GXX (the host-dlopen path, onboard and sim); tensormap_and_ringbuffer keeps AARCH64_GXX onboard (AICPU dlopen) and HOST_GXX for sim. Unknown runtime_name now raises ValueError, matching the docstring's documented contract. Verified on a2a3 onboard (910B2C): host_build_graph vector_example and paged_attention now pass; tensormap alternating_matmul_add unchanged (regression guard). a5 host_build_graph takes the same path but has no a5 silicon here to onboard-verify. --- simpler_setup/kernel_compiler.py | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/simpler_setup/kernel_compiler.py b/simpler_setup/kernel_compiler.py index b2aff3b5a0..96cdf72598 100644 --- a/simpler_setup/kernel_compiler.py +++ b/simpler_setup/kernel_compiler.py @@ -419,15 +419,23 @@ def compile_orchestration( if orch_includes: include_dirs = include_dirs + orch_includes - # Resolve toolchain: HOST_GXX needs no runtime-specific extras - toolchain_type = self._get_toolchain( - { - "a2a3": ToolchainType.AARCH64_GXX, - "a2a3sim": ToolchainType.HOST_GXX, - "a5": ToolchainType.AARCH64_GXX, - "a5sim": ToolchainType.HOST_GXX, - }, - ) + # host_build_graph dlopens the orchestration .so on the host, so it + # compiles with the host g++ (x86_64) regardless of platform. + # tensormap_and_ringbuffer dlopens it on the aarch64 AICPU onboard, so + # it cross-compiles there and uses the host g++ only for sim. + if runtime_name == "host_build_graph": + toolchain_type = ToolchainType.HOST_GXX + elif runtime_name == "tensormap_and_ringbuffer": + toolchain_type = self._get_toolchain( + { + "a2a3": ToolchainType.AARCH64_GXX, + "a2a3sim": ToolchainType.HOST_GXX, + "a5": ToolchainType.AARCH64_GXX, + "a5sim": ToolchainType.HOST_GXX, + }, + ) + else: + raise ValueError(f"Unknown runtime_name: {runtime_name!r}") toolchain: Union[GxxToolchain, Aarch64GxxToolchain] if toolchain_type == ToolchainType.AARCH64_GXX: assert self.aarch64 is not None, "aarch64 toolchain is only available for hardware platforms" @@ -435,9 +443,7 @@ def compile_orchestration( else: toolchain = self.host_gxx - # HOST_GXX: simulation build (host execution) - # AARCH64_GXX: cross-compilation for supported runtimes - # Note: orchestration uses ops table via pto_orchestration_api.h (no extra runtime sources needed) + # Orchestration uses the ops table via pto_orchestration_api.h (no extra runtime sources needed). return self._compile_orchestration_shared_lib( source_path, toolchain,