Skip to content

Commit 20222d4

Browse files
author
pytorchbot
committed
2025-11-08 nightly release (c6308a9)
1 parent c9b721f commit 20222d4

File tree

297 files changed

+10059
-4054
lines changed

Some content is hidden

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

297 files changed

+10059
-4054
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/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
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::"

0 commit comments

Comments
 (0)