Skip to content

Commit 2d4c061

Browse files
authored
Merge branch 'main' into dev1/danny/per_layer_quant
2 parents 03278ad + c02fdfc commit 2d4c061

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2065
-493
lines changed

.ci/docker/common/install_arm.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
# All rights reserved.
4+
# Copyright 2025 Arm Limited and/or its affiliates.
5+
#
6+
# This source code is licensed under the BSD-style license found in the
7+
# LICENSE file in the root directory of this source tree.
8+
9+
set -ex
10+
11+
install_arm_prerequiresites() {
12+
apt-get update -y
13+
apt-get install -y --no-install-recommends \
14+
mesa-vulkan-drivers libvulkan1
15+
rm -rf /var/lib/apt/lists/*
16+
}
17+
18+
install_arm_prerequiresites

.ci/docker/ubuntu/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ RUN if [ -n "${ANDROID_NDK_VERSION}" ]; then bash ./install_android.sh; fi
8383
RUN rm install_android.sh
8484

8585
ARG ARM_SDK
86+
COPY ./common/install_arm.sh install_arm.sh
87+
RUN if [ -n "${ARM_SDK}" ]; then bash ./install_arm.sh; fi
88+
RUN rm install_arm.sh
8689

8790
ARG ZEPHYR_SDK
8891
COPY ./common/install_zephyr.sh install_zephyr.sh

.ci/scripts/test_llama.sh

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -171,15 +171,14 @@ cmake_build_llama_runner() {
171171
git submodule update --init
172172
popd
173173
dir="examples/models/llama"
174-
retry cmake \
175-
-DEXECUTORCH_BUILD_TESTS=ON \
176-
-DBUILD_TESTING=OFF \
177-
-DCMAKE_INSTALL_PREFIX=cmake-out \
178-
-DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE" \
179-
-Bcmake-out/${dir} \
180-
${dir}
181-
cmake --build cmake-out/${dir} -j9 --config "$CMAKE_BUILD_TYPE"
182-
174+
if [[ "$CMAKE_BUILD_TYPE" == "Debug" ]]; then
175+
PRESET="llama-debug"
176+
else
177+
PRESET="llama-release"
178+
fi
179+
pushd "${dir}"
180+
cmake --workflow --preset "${PRESET}"
181+
popd
183182
}
184183

185184
cleanup_files() {

.ci/scripts/test_model_e2e.sh

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -156,24 +156,13 @@ echo "::endgroup::"
156156

157157
echo "::group::Build $MODEL_NAME Runner"
158158

159-
if [ "$DEVICE" = "cuda" ]; then
160-
WORKFLOW="llm-release-cuda"
161-
BUILD_BACKEND="EXECUTORCH_BUILD_CUDA"
162-
elif [ "$DEVICE" = "metal" ]; then
163-
WORKFLOW="llm-release-metal"
164-
BUILD_BACKEND="EXECUTORCH_BUILD_METAL"
165-
else
159+
if [ "$DEVICE" != "cuda" ] && [ "$DEVICE" != "metal" ]; then
166160
echo "Error: Unsupported device '$DEVICE'. Must be 'cuda' or 'metal'."
167161
exit 1
168162
fi
169163

170-
cmake --workflow $WORKFLOW
171-
172-
cmake -D${BUILD_BACKEND}=ON \
173-
-DCMAKE_BUILD_TYPE=Release \
174-
-Sexamples/models/$RUNNER_PATH \
175-
-Bcmake-out/examples/models/$RUNNER_PATH/
176-
cmake --build cmake-out/examples/models/$RUNNER_PATH --target $RUNNER_TARGET --config Release
164+
MAKE_TARGET="${RUNNER_PATH}-${DEVICE}"
165+
make "${MAKE_TARGET}"
177166
echo "::endgroup::"
178167

179168
echo "::group::Run $MODEL_NAME Runner"

Makefile

Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
# ==============================================================================
2+
# ExecuTorch Targets Makefile
3+
# ==============================================================================
4+
#
5+
# This Makefile provides convenient targets for building ExecuTorch model runners
6+
# with different backend configurations (CPU, CUDA, Metal), as well as other
7+
# binary targets.
8+
#
9+
# WHAT THIS BUILDS:
10+
# -----------------
11+
# Each target builds:
12+
# 1. ExecuTorch core libraries with the specified backend (CPU, CUDA, or Metal)
13+
# 2. The model-specific runner executable in cmake-out/examples/models/<model>/
14+
#
15+
# SUPPORTED MODELS:
16+
# -----------------
17+
# - voxtral: Multimodal voice + text model (CPU, CUDA, Metal)
18+
# - whisper: Speech recognition model (CPU, CUDA, Metal)
19+
# - llama: Text generation model (CPU)
20+
# - llava: Vision + language model (CPU)
21+
# - gemma3: Text generation model (CPU, CUDA)
22+
#
23+
# USAGE:
24+
# ------
25+
# make <model>-<backend> # Build a specific model with a backend
26+
# make help # Show all available targets
27+
# make clean # Remove all build artifacts
28+
#
29+
# Examples:
30+
# make voxtral-cuda # Build Voxtral with CUDA backend
31+
# make llama-cpu # Build Llama with CPU backend
32+
# make whisper-metal # Build Whisper with Metal backend (macOS)
33+
#
34+
# HOW TO ADD A NEW MODEL:
35+
# -----------------------
36+
# To add a new model (e.g., "mymodel"), follow these steps:
37+
#
38+
# 1. Create a CMakePresets.json in examples/models/mymodel/:
39+
# - Define configurePresets for each backend (base, cpu, cuda, metal)
40+
# - Define buildPresets with the target name from CMakeLists.txt
41+
# - Define workflowPresets that combine configure + build steps
42+
# - See examples/models/voxtral/CMakePresets.json for multi-backend reference
43+
# - Or see examples/models/llama/CMakePresets.json for simple single-preset reference
44+
#
45+
# 2. Add targets to this Makefile:
46+
# a) Add to .PHONY declaration: mymodel-cuda mymodel-cpu mymodel-metal
47+
# b) Add help text in the help target
48+
# c) Add target implementations following this pattern:
49+
#
50+
# mymodel-cuda:
51+
# @echo "==> Building and installing ExecuTorch with CUDA..."
52+
# cmake --workflow --preset llm-release-cuda
53+
# @echo "==> Building MyModel runner with CUDA..."
54+
# cd examples/models/mymodel && cmake --workflow --preset mymodel-cuda
55+
# @echo ""
56+
# @echo "✓ Build complete!"
57+
# @echo " Binary: cmake-out/examples/models/mymodel/mymodel_runner"
58+
#
59+
# mymodel-cpu:
60+
# @echo "==> Building and installing ExecuTorch..."
61+
# cmake --workflow --preset llm-release
62+
# @echo "==> Building MyModel runner (CPU)..."
63+
# cd examples/models/mymodel && cmake --workflow --preset mymodel-cpu
64+
# @echo ""
65+
# @echo "✓ Build complete!"
66+
# @echo " Binary: cmake-out/examples/models/mymodel/mymodel_runner"
67+
#
68+
# mymodel-metal:
69+
# @echo "==> Building and installing ExecuTorch with Metal..."
70+
# cmake --workflow --preset llm-release-metal
71+
# @echo "==> Building MyModel runner with Metal..."
72+
# cd examples/models/mymodel && cmake --workflow --preset mymodel-metal
73+
# @echo ""
74+
# @echo "✓ Build complete!"
75+
# @echo " Binary: cmake-out/examples/models/mymodel/mymodel_runner"
76+
#
77+
# 3. Test your new targets:
78+
# make mymodel-cpu # or mymodel-cuda, mymodel-metal
79+
#
80+
# NOTES:
81+
# ------
82+
# - CUDA backend is only available on Linux systems
83+
# - Metal backend is only available on macOS (Darwin) systems
84+
# - Some models may not support all backends (check model documentation)
85+
# - Binary outputs are located in cmake-out/examples/models/<model>/
86+
# - The preset names in CMakePresets.json must match the names used in Makefile
87+
#
88+
# ==============================================================================
89+
90+
.PHONY: voxtral-cuda voxtral-cpu voxtral-metal whisper-cuda whisper-cpu whisper-metal llama-cpu llava-cpu gemma3-cuda gemma3-cpu clean help
91+
92+
help:
93+
@echo "This Makefile adds targets to build runners for various models on various backends. Run using `make <target>`. Available targets:"
94+
@echo " voxtral-cuda - Build Voxtral runner with CUDA backend"
95+
@echo " voxtral-cpu - Build Voxtral runner with CPU backend"
96+
@echo " voxtral-metal - Build Voxtral runner with Metal backend (macOS only)"
97+
@echo " whisper-cuda - Build Whisper runner with CUDA backend"
98+
@echo " whisper-cpu - Build Whisper runner with CPU backend"
99+
@echo " whisper-metal - Build Whisper runner with Metal backend (macOS only)"
100+
@echo " llama-cpu - Build Llama runner with CPU backend"
101+
@echo " llava-cpu - Build Llava runner with CPU backend"
102+
@echo " gemma3-cuda - Build Gemma3 runner with CUDA backend"
103+
@echo " gemma3-cpu - Build Gemma3 runner with CPU backend"
104+
@echo " clean - Clean build artifacts"
105+
106+
voxtral-cuda:
107+
@echo "==> Building and installing ExecuTorch with CUDA..."
108+
cmake --workflow --preset llm-release-cuda
109+
@echo "==> Building Voxtral runner with CUDA..."
110+
cd examples/models/voxtral && cmake --workflow --preset voxtral-cuda
111+
@echo ""
112+
@echo "✓ Build complete!"
113+
@echo " Binary: cmake-out/examples/models/voxtral/voxtral_runner"
114+
115+
voxtral-cpu:
116+
@echo "==> Building and installing ExecuTorch..."
117+
cmake --workflow --preset llm-release
118+
@echo "==> Building Voxtral runner (CPU)..."
119+
cd examples/models/voxtral && cmake --workflow --preset voxtral-cpu
120+
@echo ""
121+
@echo "✓ Build complete!"
122+
@echo " Binary: cmake-out/examples/models/voxtral/voxtral_runner"
123+
124+
voxtral-metal:
125+
@echo "==> Building and installing ExecuTorch with Metal..."
126+
cmake --workflow --preset llm-release-metal
127+
@echo "==> Building Voxtral runner with Metal..."
128+
cd examples/models/voxtral && cmake --workflow --preset voxtral-metal
129+
@echo ""
130+
@echo "✓ Build complete!"
131+
@echo " Binary: cmake-out/examples/models/voxtral/voxtral_runner"
132+
133+
whisper-cuda:
134+
@echo "==> Building and installing ExecuTorch with CUDA..."
135+
cmake --workflow --preset llm-release-cuda
136+
@echo "==> Building Whisper runner with CUDA..."
137+
cd examples/models/whisper && cmake --workflow --preset whisper-cuda
138+
@echo ""
139+
@echo "✓ Build complete!"
140+
@echo " Binary: cmake-out/examples/models/whisper/whisper_runner"
141+
142+
whisper-cpu:
143+
@echo "==> Building and installing ExecuTorch..."
144+
cmake --workflow --preset llm-release
145+
@echo "==> Building Whisper runner (CPU)..."
146+
cd examples/models/whisper && cmake --workflow --preset whisper-cpu
147+
@echo ""
148+
@echo "✓ Build complete!"
149+
@echo " Binary: cmake-out/examples/models/whisper/whisper_runner"
150+
151+
whisper-metal:
152+
@echo "==> Building and installing ExecuTorch with Metal..."
153+
cmake --workflow --preset llm-release-metal
154+
@echo "==> Building Whisper runner with Metal..."
155+
cd examples/models/whisper && cmake --workflow --preset whisper-metal
156+
@echo ""
157+
@echo "✓ Build complete!"
158+
@echo " Binary: cmake-out/examples/models/whisper/whisper_runner"
159+
160+
llama-cpu:
161+
@echo "==> Building and installing ExecuTorch..."
162+
cmake --workflow --preset llm-release
163+
@echo "==> Building Llama runner (CPU)..."
164+
cd examples/models/llama && cmake --workflow --preset llama-release
165+
@echo ""
166+
@echo "✓ Build complete!"
167+
@echo " Binary: cmake-out/examples/models/llama/llama_main"
168+
169+
llava-cpu:
170+
@echo "==> Building and installing ExecuTorch..."
171+
cmake --workflow --preset llm-release
172+
@echo "==> Building Llava runner (CPU)..."
173+
cd examples/models/llava && cmake --workflow --preset llava
174+
@echo ""
175+
@echo "✓ Build complete!"
176+
@echo " Binary: cmake-out/examples/models/llava/llava_main"
177+
178+
gemma3-cuda:
179+
@echo "==> Building and installing ExecuTorch with CUDA..."
180+
cmake --workflow --preset llm-release-cuda
181+
@echo "==> Building Gemma3 runner with CUDA..."
182+
cd examples/models/gemma3 && cmake --workflow --preset gemma3-cuda
183+
@echo ""
184+
@echo "✓ Build complete!"
185+
@echo " Binary: cmake-out/examples/models/gemma3/gemma3_e2e_runner"
186+
187+
gemma3-cpu:
188+
@echo "==> Building and installing ExecuTorch..."
189+
cmake --workflow --preset llm-release
190+
@echo "==> Building Gemma3 runner (CPU)..."
191+
cd examples/models/gemma3 && cmake --workflow --preset gemma3-cpu
192+
@echo ""
193+
@echo "✓ Build complete!"
194+
@echo " Binary: cmake-out/examples/models/gemma3/gemma3_e2e_runner"
195+
196+
clean:
197+
rm -rf cmake-out

docs/source/android-arm-vgf.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
```{include} backends-arm-vgf.md
1+
```{include} backends/arm-vgf/arm-vgf-overview.md

0 commit comments

Comments
 (0)