Skip to content

Commit f6037a4

Browse files
authored
Merge branch 'main' into pruning_example_ethos_U
2 parents 8119d6d + b91987e commit f6037a4

File tree

855 files changed

+33757
-21892
lines changed

Some content is hidden

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

855 files changed

+33757
-21892
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
467660923a5a25e4718e1d6697b93ff1bab4e807
1+
d03e90c2cd9048e6d9a75285c0355f033cd016fc
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
e6f766c7d750d40603eee3f66c5915bac606b3ea
1+
b31bad1b8f1331bf43d47f46602cf6141db56844

.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/requirements-ci.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ sphinx-reredirects==0.1.4
3030
matplotlib>=3.9.4
3131
sphinx-copybutton==0.5.2
3232
# PyTorch Theme
33-
-e git+https://github.com/pytorch/pytorch_sphinx_theme.git@pytorch_sphinx_theme2#egg=pytorch_sphinx_theme2
34-
33+
pytorch_sphinx_theme2==0.2.0
3534
# script unit test requirements
3635
yaspin==3.1.0

.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
Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
#!/bin/bash
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
# All rights reserved.
4+
#
5+
# This source code is licensed under the BSD-style license found in the
6+
# LICENSE file in the root directory of this source tree.
7+
8+
# Export model to CUDA/Metal format with optional quantization
9+
10+
show_help() {
11+
cat << EOF
12+
Usage: export_model_artifact.sh <device> <hf_model> [quant_name] [output_dir]
13+
14+
Export a HuggingFace model to CUDA/Metal format with optional quantization.
15+
16+
Arguments:
17+
device cuda or metal (required)
18+
19+
hf_model HuggingFace model ID (required)
20+
Supported models:
21+
- mistralai/Voxtral-Mini-3B-2507
22+
- openai/whisper series (whisper-{small, medium, large, large-v2, large-v3, large-v3-turbo})
23+
- google/gemma-3-4b-it
24+
25+
quant_name Quantization type (optional, default: non-quantized)
26+
Options:
27+
- non-quantized
28+
- quantized-int4-tile-packed
29+
- quantized-int4-weight-only
30+
31+
output_dir Output directory for artifacts (optional, default: current directory)
32+
33+
Examples:
34+
export_model_artifact.sh metal "openai/whisper-small"
35+
export_model_artifact.sh cuda "mistralai/Voxtral-Mini-3B-2507" "quantized-int4-tile-packed"
36+
export_model_artifact.sh cuda "google/gemma-3-4b-it" "non-quantized" "./output"
37+
EOF
38+
}
39+
40+
if [ "${1:-}" = "-h" ] || [ "${1:-}" = "--help" ]; then
41+
show_help
42+
exit 0
43+
fi
44+
45+
if [ -z "${1:-}" ]; then
46+
echo "Error: hf_model argument is required"
47+
echo "Run with -h or --help for usage information"
48+
exit 1
49+
fi
50+
51+
set -eux
52+
53+
DEVICE="$1"
54+
HF_MODEL="$2"
55+
QUANT_NAME="${3:-non-quantized}"
56+
OUTPUT_DIR="${4:-.}"
57+
58+
case "$DEVICE" in
59+
cuda)
60+
;;
61+
metal)
62+
;;
63+
*)
64+
echo "Error: Unsupported device '$DEVICE'"
65+
echo "Supported devices: cuda, metal"
66+
exit 1
67+
;;
68+
esac
69+
70+
# Determine model configuration based on HF model ID
71+
case "$HF_MODEL" in
72+
mistralai/Voxtral-Mini-3B-2507)
73+
MODEL_NAME="voxtral"
74+
TASK="multimodal-text-to-text"
75+
MAX_SEQ_LEN="1024"
76+
EXTRA_PIP="mistral-common librosa"
77+
PREPROCESSOR_FEATURE_SIZE="128"
78+
PREPROCESSOR_OUTPUT="voxtral_preprocessor.pte"
79+
;;
80+
openai/whisper-*)
81+
MODEL_NAME="whisper"
82+
TASK="automatic-speech-recognition"
83+
MAX_SEQ_LEN=""
84+
EXTRA_PIP="librosa"
85+
PREPROCESSOR_OUTPUT="whisper_preprocessor.pte"
86+
if [[ "$HF_MODEL" == *"large-v3"* ]]; then
87+
PREPROCESSOR_FEATURE_SIZE="128"
88+
else
89+
PREPROCESSOR_FEATURE_SIZE="80"
90+
fi
91+
;;
92+
google/gemma-3-4b-it)
93+
if [ "$DEVICE" = "metal" ]; then
94+
echo "Error: Export for device 'metal' is not yet tested for model '$HF_MODEL'"
95+
exit 1
96+
fi
97+
MODEL_NAME="gemma3"
98+
TASK="multimodal-text-to-text"
99+
MAX_SEQ_LEN="64"
100+
EXTRA_PIP=""
101+
PREPROCESSOR_FEATURE_SIZE=""
102+
PREPROCESSOR_OUTPUT=""
103+
;;
104+
*)
105+
echo "Error: Unsupported model '$HF_MODEL'"
106+
echo "Supported models: mistralai/Voxtral-Mini-3B-2507, openai/whisper-{small, medium, large, large-v2, large-v3, large-v3-turbo}, google/gemma-3-4b-it"
107+
exit 1
108+
;;
109+
esac
110+
111+
# Determine quantization args based on quant name
112+
case "$QUANT_NAME" in
113+
non-quantized)
114+
EXTRA_ARGS=""
115+
;;
116+
quantized-int4-tile-packed)
117+
if [ "$DEVICE" = "metal" ]; then
118+
echo "Error: Metal backend does not yet support quantization '$QUANT_NAME'"
119+
exit 1
120+
fi
121+
EXTRA_ARGS="--qlinear 4w --qlinear_encoder 4w --qlinear_packing_format tile_packed_to_4d --qlinear_encoder_packing_format tile_packed_to_4d"
122+
;;
123+
quantized-int4-weight-only)
124+
if [ "$DEVICE" = "metal" ]; then
125+
echo "Error: Metal backend does not yet support quantization '$QUANT_NAME'"
126+
exit 1
127+
fi
128+
EXTRA_ARGS="--qlinear_encoder 4w"
129+
;;
130+
*)
131+
echo "Error: Unsupported quantization '$QUANT_NAME'"
132+
echo "Supported quantizations: non-quantized, quantized-int4-tile-packed, quantized-int4-weight-only"
133+
exit 1
134+
;;
135+
esac
136+
137+
echo "::group::Export $MODEL_NAME"
138+
139+
if [ -n "$EXTRA_PIP" ]; then
140+
pip install $EXTRA_PIP
141+
fi
142+
pip list
143+
144+
MAX_SEQ_LEN_ARG=""
145+
if [ -n "$MAX_SEQ_LEN" ]; then
146+
MAX_SEQ_LEN_ARG="--max_seq_len $MAX_SEQ_LEN"
147+
fi
148+
149+
DEVICE_ARG=""
150+
if [ "$DEVICE" = "cuda" ]; then
151+
DEVICE_ARG="--device cuda"
152+
fi
153+
154+
optimum-cli export executorch \
155+
--model "$HF_MODEL" \
156+
--task "$TASK" \
157+
--recipe "$DEVICE" \
158+
--dtype bfloat16 \
159+
${DEVICE_ARG} \
160+
${MAX_SEQ_LEN_ARG} \
161+
${EXTRA_ARGS} \
162+
--output_dir ./
163+
164+
if [ -n "$PREPROCESSOR_OUTPUT" ]; then
165+
python -m executorch.extension.audio.mel_spectrogram \
166+
--feature_size $PREPROCESSOR_FEATURE_SIZE \
167+
--stack_output \
168+
--max_audio_len 300 \
169+
--output_file $PREPROCESSOR_OUTPUT
170+
fi
171+
172+
test -f model.pte
173+
test -f aoti_${DEVICE}_blob.ptd
174+
if [ -n "$PREPROCESSOR_OUTPUT" ]; then
175+
test -f $PREPROCESSOR_OUTPUT
176+
fi
177+
echo "::endgroup::"
178+
179+
echo "::group::Store $MODEL_NAME Artifacts"
180+
mkdir -p "${OUTPUT_DIR}"
181+
mv model.pte "${OUTPUT_DIR}/"
182+
mv aoti_${DEVICE}_blob.ptd "${OUTPUT_DIR}/"
183+
if [ -n "$PREPROCESSOR_OUTPUT" ]; then
184+
mv $PREPROCESSOR_OUTPUT "${OUTPUT_DIR}/"
185+
fi
186+
ls -al "${OUTPUT_DIR}"
187+
echo "::endgroup::"

.ci/scripts/test_backend.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,25 @@ if [[ "$FLOW" == *vulkan* ]]; then
5757
fi
5858

5959
if [[ "$FLOW" == *arm* ]]; then
60+
6061
# Setup ARM deps.
61-
.ci/scripts/setup-arm-baremetal-tools.sh
62+
if [[ "$FLOW" == *vgf* ]]; then
63+
.ci/scripts/setup-arm-baremetal-tools.sh --enable-mlsdk-deps --install-mlsdk-deps-with-pip
64+
else
65+
.ci/scripts/setup-arm-baremetal-tools.sh
66+
fi
6267
source examples/arm/ethos-u-scratch/setup_path.sh
6368

6469
if [[ "$FLOW" == *ethos_u* ]]; then
6570
# Prepare a test runner binary that can run on the Corstone-3x0 FVPs
6671
backends/arm/scripts/build_executorch.sh
6772
backends/arm/test/setup_testing.sh
6873
fi
74+
75+
if [[ "$FLOW" == *vgf* ]]; then
76+
# Prepare a test runner binary for VKML runtime
77+
backends/arm/test/setup_testing_vkml.sh
78+
fi
6979
fi
7080

7181
if [[ $IS_MACOS -eq 1 ]]; then

.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_llama_lora.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ source "$(dirname "${BASH_SOURCE[0]}")/utils.sh"
1212
cmake_install_executorch_libraries() {
1313
echo "Installing libexecutorch.a, libextension_module.so, libportable_ops_lib.a"
1414
rm -rf cmake-out
15-
retry cmake --preset llm \
16-
-DCMAKE_INSTALL_PREFIX=cmake-out \
17-
-DCMAKE_BUILD_TYPE=Release
18-
cmake --build cmake-out -j9 --target install --config Release
15+
cmake --workflow llm-release
1916
}
2017

2118
cmake_build_llama_runner() {

0 commit comments

Comments
 (0)