From 41ca68aa196d93e0ffecabb958ab4b8a4128fe3d Mon Sep 17 00:00:00 2001 From: Jake Stevens Date: Fri, 30 Oct 2026 06:47:08 -0700 Subject: [PATCH] Add OSS CI for the Native CPU engine (#23937) Summary: Add a CPU job to the Native Engines workflow that builds `run_classification_cpu` and runs `native_cpu_engine_test` with XNNPACK and optimized kernels enabled. Update dependency triggers, documentation, and xplat mirrors. Authored with OpenAI Codex. Reviewed By: digantdesai Differential Revision: D125722080 --- .ci/scripts/test-native.sh | 12 +++++++++++- .github/workflows/test-native.yml | 11 ++++++++++- backends/native/README.md | 16 +++++++++------- 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/.ci/scripts/test-native.sh b/.ci/scripts/test-native.sh index 2f08fc6dabf..6f3b4c21a01 100644 --- a/.ci/scripts/test-native.sh +++ b/.ci/scripts/test-native.sh @@ -7,7 +7,7 @@ set -euxo pipefail -component="${1:?Usage: test-native.sh [cmake options]}" +component="${1:?Usage: test-native.sh [cmake options]}" shift build_dir="cmake-out/native-${component}" build_jobs="${CMAKE_BUILD_PARALLEL_LEVEL:-$(nproc)}" @@ -19,6 +19,16 @@ case "${component}" in targets+=(native_runtime_test) test_regex='^native_runtime_test$' ;; + cpu) + cmake_args+=( + -DEXECUTORCH_BUILD_NATIVE_CPU=ON + -DEXECUTORCH_BUILD_XNNPACK=ON + -DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON + -DEXECUTORCH_BUILD_NATIVE_VISION_RUNNER=ON + ) + targets+=(native_cpu_engine_test run_classification_cpu) + test_regex='^native_cpu_engine_test$' + ;; ggml) cmake_args+=( -DEXECUTORCH_BUILD_NATIVE_GGML=ON diff --git a/.github/workflows/test-native.yml b/.github/workflows/test-native.yml index c5e0f0b7c76..c7a7aae2f0c 100644 --- a/.github/workflows/test-native.yml +++ b/.github/workflows/test-native.yml @@ -14,6 +14,8 @@ on: - install_requirements.sh - requirements-dev.txt - requirements-examples.txt + - backends/cpu/CMakeLists.txt + - backends/cpu/runtime/** - backends/native/** - backends/vulkan/CMakeLists.txt - backends/vulkan/cmake/** @@ -27,13 +29,20 @@ on: - backends/vulkan/third-party/volk - backends/vulkan_shared/CMakeLists.txt - backends/vulkan_shared/runtime/** + - backends/xnnpack/CMakeLists.txt + - backends/xnnpack/cmake/** - backends/xnnpack/third-party/FXdiv + - backends/xnnpack/third-party/XNNPACK - backends/xnnpack/third-party/cpuinfo - backends/xnnpack/third-party/pthreadpool - examples/models/llama/tokenizer/** - extension/llm/tokenizers - extension/llm/export/** - exir/** + - configurations/** + - extension/memory_allocator/** + - extension/threadpool/** + - kernels/** - runtime/** - third-party/** - tools/cmake/** @@ -67,7 +76,7 @@ jobs: strategy: fail-fast: false matrix: - component: [runtime, ggml, vulkan] + component: [runtime, cpu, ggml, vulkan] defaults: run: shell: bash diff --git a/backends/native/README.md b/backends/native/README.md index 5f156dad590..4fce4717128 100644 --- a/backends/native/README.md +++ b/backends/native/README.md @@ -202,16 +202,18 @@ target_link_libraries(my_app PRIVATE native_api native_vulkan_engine) ``` With `EXECUTORCH_BUILD_TESTS=ON`, `native_runtime_test` covers the shared runtime -and API. `native_vulkan_passes_test` covers the Vulkan graph rewrites without -requiring a GPU. When either runner below is enabled, -`native_runner_utils_test` covers their shared runner utilities. Run these with -`ctest --test-dir cmake-out -R native_`. +and API. `native_cpu_engine_test` covers the CPU engine when +`EXECUTORCH_BUILD_NATIVE_CPU` is enabled. `native_vulkan_passes_test` covers the +Vulkan graph rewrites without requiring a GPU. When either runner below is +enabled, `native_runner_utils_test` covers their shared runner utilities. Run these +with `ctest --test-dir cmake-out -R native_`. The `Test Native Engines` CI workflow has separate Linux jobs for the shared -runtime, GGML, and Vulkan, with each test suite run once. To reproduce with +runtime, CPU, GGML, and Vulkan, with each test suite run once. To reproduce with dependencies installed, run `bash .ci/scripts/test-native.sh runtime`, -`bash .ci/scripts/test-native.sh ggml`, or -`bash .ci/scripts/test-native.sh vulkan` from the OSS checkout. The GGML job +`bash .ci/scripts/test-native.sh cpu`, `bash .ci/scripts/test-native.sh ggml`, +or `bash .ci/scripts/test-native.sh vulkan` from the OSS checkout. The CPU job +runs `native_cpu_engine_test` and builds `run_classification_cpu`. The GGML job also runs `native_llm_runner_utils_test` and executes `run_hf_llm_ggml` on a tiny seeded Hugging Face Llama with a generated byte tokenizer. Its eight generated token IDs must match eager PyTorch, covering prefill and KV-cache decoding without