Skip to content

Commit bcf2426

Browse files
committed
Merge remote-tracking branch 'origin/main' into aoti-aot-windows
2 parents 18b9535 + 9a7882e commit bcf2426

File tree

833 files changed

+24302
-10223
lines changed

Some content is hidden

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

833 files changed

+24302
-10223
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
44d8d54e38c0258357d4e92e1fefe21e845947a3
1+
4361747abfc55e40e929396ed986efe775d745f9
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
e6f766c7d750d40603eee3f66c5915bac606b3ea
1+
b31bad1b8f1331bf43d47f46602cf6141db56844

.ci/docker/requirements-ci.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ sympy==1.12
66
timm==0.6.13
77
tomli==2.0.1
88
torchsr==1.0.4
9-
transformers==4.47.1
9+
transformers==4.56.1
1010
zstd==1.5.5.1
1111
pandas>=2.2.2; python_version >= '3.10'
1212
pytest==7.2.0
@@ -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/scripts/build-qnn-sdk.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ build_qnn_backend() {
1818
export EXECUTORCH_ROOT="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)"
1919

2020
parallelism=$(( $(nproc) - 1 ))
21-
bash backends/qualcomm/scripts/build.sh --skip_aarch64 --job_number ${parallelism} --release
21+
bash backends/qualcomm/scripts/build.sh --skip_linux_android --skip_linux_embedded --job_number ${parallelism} --release
2222
}
2323

2424
set_up_aot() {
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
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 format with optional quantization
9+
10+
show_help() {
11+
cat << EOF
12+
Usage: export_model_cuda_artifact.sh <hf_model> [quant_name] [output_dir]
13+
14+
Export a HuggingFace model to CUDA format with optional quantization.
15+
16+
Arguments:
17+
hf_model HuggingFace model ID (required)
18+
Supported models:
19+
- mistralai/Voxtral-Mini-3B-2507
20+
- openai/whisper-small
21+
- google/gemma-3-4b-it
22+
23+
quant_name Quantization type (optional, default: non-quantized)
24+
Options:
25+
- non-quantized
26+
- quantized-int4-tile-packed
27+
- quantized-int4-weight-only
28+
29+
output_dir Output directory for artifacts (optional, default: current directory)
30+
31+
Examples:
32+
export_model_cuda_artifact.sh "openai/whisper-small"
33+
export_model_cuda_artifact.sh "mistralai/Voxtral-Mini-3B-2507" "quantized-int4-tile-packed"
34+
export_model_cuda_artifact.sh "google/gemma-3-4b-it" "non-quantized" "./output"
35+
EOF
36+
}
37+
38+
if [ "${1:-}" = "-h" ] || [ "${1:-}" = "--help" ]; then
39+
show_help
40+
exit 0
41+
fi
42+
43+
if [ -z "${1:-}" ]; then
44+
echo "Error: hf_model argument is required"
45+
echo "Run with -h or --help for usage information"
46+
exit 1
47+
fi
48+
49+
set -eux
50+
51+
HF_MODEL="$1"
52+
QUANT_NAME="${2:-non-quantized}"
53+
OUTPUT_DIR="${3:-.}"
54+
55+
# Determine model configuration based on HF model ID
56+
case "$HF_MODEL" in
57+
mistralai/Voxtral-Mini-3B-2507)
58+
MODEL_NAME="voxtral"
59+
TASK="multimodal-text-to-text"
60+
MAX_SEQ_LEN="1024"
61+
EXTRA_PIP="mistral-common librosa"
62+
PREPROCESSOR_FEATURE_SIZE="128"
63+
PREPROCESSOR_OUTPUT="voxtral_preprocessor.pte"
64+
;;
65+
openai/whisper-small)
66+
MODEL_NAME="whisper"
67+
TASK="automatic-speech-recognition"
68+
MAX_SEQ_LEN=""
69+
EXTRA_PIP="librosa"
70+
PREPROCESSOR_FEATURE_SIZE="80"
71+
PREPROCESSOR_OUTPUT="whisper_preprocessor.pte"
72+
;;
73+
google/gemma-3-4b-it)
74+
MODEL_NAME="gemma3"
75+
TASK="multimodal-text-to-text"
76+
MAX_SEQ_LEN="64"
77+
EXTRA_PIP=""
78+
PREPROCESSOR_FEATURE_SIZE=""
79+
PREPROCESSOR_OUTPUT=""
80+
;;
81+
*)
82+
echo "Error: Unsupported model '$HF_MODEL'"
83+
echo "Supported models: mistralai/Voxtral-Mini-3B-2507, openai/whisper-small, google/gemma-3-4b-it"
84+
exit 1
85+
;;
86+
esac
87+
88+
# Determine quantization args based on quant name
89+
case "$QUANT_NAME" in
90+
non-quantized)
91+
EXTRA_ARGS=""
92+
;;
93+
quantized-int4-tile-packed)
94+
EXTRA_ARGS="--qlinear 4w --qlinear_encoder 4w --qlinear_packing_format tile_packed_to_4d --qlinear_encoder_packing_format tile_packed_to_4d"
95+
;;
96+
quantized-int4-weight-only)
97+
EXTRA_ARGS="--qlinear_encoder 4w"
98+
;;
99+
*)
100+
echo "Error: Unsupported quantization '$QUANT_NAME'"
101+
echo "Supported quantizations: non-quantized, quantized-int4-tile-packed, quantized-int4-weight-only"
102+
exit 1
103+
;;
104+
esac
105+
106+
echo "::group::Export $MODEL_NAME"
107+
108+
if [ -n "$EXTRA_PIP" ]; then
109+
pip install $EXTRA_PIP
110+
fi
111+
pip list
112+
113+
MAX_SEQ_LEN_ARG=""
114+
if [ -n "$MAX_SEQ_LEN" ]; then
115+
MAX_SEQ_LEN_ARG="--max_seq_len $MAX_SEQ_LEN"
116+
fi
117+
optimum-cli export executorch \
118+
--model "$HF_MODEL" \
119+
--task "$TASK" \
120+
--recipe "cuda" \
121+
--dtype bfloat16 \
122+
--device cuda \
123+
${MAX_SEQ_LEN_ARG} \
124+
${EXTRA_ARGS} \
125+
--output_dir ./
126+
127+
if [ -n "$PREPROCESSOR_OUTPUT" ]; then
128+
python -m executorch.extension.audio.mel_spectrogram \
129+
--feature_size $PREPROCESSOR_FEATURE_SIZE \
130+
--stack_output \
131+
--max_audio_len 300 \
132+
--output_file $PREPROCESSOR_OUTPUT
133+
fi
134+
135+
test -f model.pte
136+
test -f aoti_cuda_blob.ptd
137+
if [ -n "$PREPROCESSOR_OUTPUT" ]; then
138+
test -f $PREPROCESSOR_OUTPUT
139+
fi
140+
echo "::endgroup::"
141+
142+
echo "::group::Store $MODEL_NAME Artifacts"
143+
mkdir -p "${OUTPUT_DIR}"
144+
cp model.pte "${OUTPUT_DIR}/"
145+
cp aoti_cuda_blob.ptd "${OUTPUT_DIR}/"
146+
if [ -n "$PREPROCESSOR_OUTPUT" ]; then
147+
cp $PREPROCESSOR_OUTPUT "${OUTPUT_DIR}/"
148+
fi
149+
ls -al "${OUTPUT_DIR}"
150+
echo "::endgroup::"

.ci/scripts/setup-windows-msvc.ps1

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
conda create --yes --quiet -n et python=3.12
2+
conda activate et
3+
4+
# Install cmake
5+
conda install -y cmake
6+
7+
# Activate the VS environment - this is required for MSVC to work
8+
# There are a bunch of environment variables that it requires.
9+
# See https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line.
10+
& "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\Launch-VsDevShell.ps1" -Arch amd64
11+
12+
# Install CI requirements
13+
pip install -r .ci/docker/requirements-ci.txt
14+
15+
# Create build directory
16+
$buildDir = "cmake-out-msvc"
17+
if (Test-Path -Path $buildDir) {
18+
Remove-Item -Path $buildDir -Recurse -Force
19+
}
20+
New-Item -Path $buildDir -ItemType Directory
21+
22+
# Configure CMake with MSVC (not ClangCL) and disable custom/quantized ops
23+
cmake -S . -B $buildDir `
24+
-DCMAKE_BUILD_TYPE=Release `
25+
-DEXECUTORCH_BUILD_EXECUTOR_RUNNER=ON `
26+
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON `
27+
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON `
28+
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON `
29+
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON `
30+
-DEXECUTORCH_BUILD_EXTENSION_NAMED_DATA_MAP=ON `
31+
-DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON `
32+
-DEXECUTORCH_BUILD_KERNELS_CUSTOM=OFF `
33+
-DEXECUTORCH_BUILD_KERNELS_CUSTOM_AOT=OFF `
34+
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=OFF `
35+
-DEXECUTORCH_BUILD_XNNPACK=ON `
36+
-DEXECUTORCH_BUILD_EXTENSION_LLM=ON `
37+
-DEXECUTORCH_BUILD_EXTENSION_LLM_RUNNER=ON
38+
39+
if ($LASTEXITCODE -ne 0) {
40+
Write-Host "CMake configuration failed. Exit code: $LASTEXITCODE."
41+
exit $LASTEXITCODE
42+
}
43+
44+
# Build with MSVC
45+
cmake --build $buildDir --config Release -j16
46+
47+
if ($LASTEXITCODE -ne 0) {
48+
Write-Host "Build failed. Exit code: $LASTEXITCODE."
49+
exit $LASTEXITCODE
50+
}
51+
52+
Write-Host "MSVC build completed successfully!"

0 commit comments

Comments
 (0)