Skip to content

TorchAO kernels ship on macOS arm64 only, not Linux aarch64 #22299

Description

@shoumikhin

What

The wheel ships libexecutorch_kernels_torchao on macOS arm64 only. Linux aarch64 has the NEON
hardware these kernels target and does not get them.

Verified against the published nightly 1.5.0.dev20260828, cp310, manylinux_2_28_aarch64:

libexecutorch.so
libexecutorch_backend_openvino.so
libexecutorch_backend_xnnpack.so
libexecutorch_etdump.so
libexecutorch_kernels_optimized.so
libexecutorch_kernels_quantized.so
libexecutorch_threadpool.so

No torchao kernels. The macOS arm64 wheel has libexecutorch_kernels_torchao.dylib.

Why it happens

EXECUTORCH_BUILD_KERNELS_TORCHAO is only turned on for Apple:

  • tools/cmake/preset/apple_common.cmake:36 sets it ON
  • tools/cmake/preset/llm.cmake:24 sets it ON only under Darwin and arm64
  • tools/cmake/preset/pybind.cmake, which is the preset the wheel build uses, never sets it, and
    its Linux branch is an empty stub

So the exclusion is a preset decision rather than a technical limit at the ExecuTorch level:
torchao_ops_executorch in third-party/ao/torchao/csrc/cpu/CMakeLists.txt is declared outside any
architecture guard, and TORCHAO_BUILD_CPU_AARCH64 only adds an extra
target_link_libraries(torchao_kernels_aarch64).

Worth knowing before anyone "fixes" this by enabling it everywhere

It should not simply be turned on for x86. In
shared_kernels/linear_8bit_act_xbit_weight/kernel_selector.h, every return PackedWeightsFormat
is behind #if defined(TORCHAO_ENABLE_ARM_NEON_DOT) or TORCHAO_ENABLE_KLEIDI:

'return PackedWeightsFormat' inside ARM guards  : 4
'return PackedWeightsFormat' outside (portable) : 0

With no NEON define, select_packed_weights_format and select_packed_weights_with_lut_format
have no reachable return and fall through to
throw std::runtime_error("No packed_weights_format was selected"). The kernel registration table
similarly ends in "ukernel_config did not register". The torch_free_kernels/fallback directory is
header-only; its CMakeLists.txt only adds tests.

So enabling it on x86 would build and then throw on every torchao op, which is worse than omitting
it. Linux aarch64 is the case that looks genuinely worth enabling, since it satisfies the NEON
guards.

Ask

Is the Linux aarch64 omission intentional, or an oversight from the preset only ever being wired up
for Apple? If it is worth enabling, it needs a linux-aarch64 build plus a real lowbit export/run to
validate, which I could not do here: PR wheel runs publish x86_64 only, and aarch64 builds on the
nightly cron.

Found while auditing wheel contents across platforms (#22267, #22269, #22272 and related).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions