Skip to content

Commit 73ca1b8

Browse files
test
1 parent 1ef52fa commit 73ca1b8

File tree

1 file changed

+203
-163
lines changed

1 file changed

+203
-163
lines changed

.github/workflows/metal.yml

Lines changed: 203 additions & 163 deletions
Original file line numberDiff line numberDiff line change
@@ -14,174 +14,214 @@ concurrency:
1414
jobs:
1515
test-metal-builds:
1616
name: test-executorch-metal-build
17-
runs-on: macos-latest
18-
steps:
19-
- name: Checkout repository
20-
uses: actions/checkout@v3
21-
with:
22-
submodules: recursive
23-
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
24-
25-
- name: Setup Python
26-
uses: actions/setup-python@v4
27-
with:
28-
python-version: '3.10'
29-
30-
- name: Test ExecuTorch Metal build
31-
run: |
32-
set -eux
33-
34-
# Test ExecuTorch Metal build
35-
PYTHON_EXECUTABLE=python3 CMAKE_ARGS="-DEXECUTORCH_BUILD_METAL=ON" ./install_executorch.sh
17+
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
18+
with:
19+
runner: macos-m2-stable
20+
python-version: '3.11'
21+
submodules: 'recursive'
22+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
23+
timeout: 90
24+
script: |
25+
set -eux
26+
27+
# Print machine info
28+
uname -a
29+
if [ $(uname -s) == Darwin ]; then
30+
sw_vers
31+
# Print RAM in GB
32+
RAM_BYTES=$(sysctl -n hw.memsize)
33+
RAM_GB=$(echo "scale=2; $RAM_BYTES/1024/1024/1024" | bc)
34+
echo "Available RAM (GB): $RAM_GB"
35+
sysctl machdep.cpu.brand_string
36+
sysctl machdep.cpu.core_count
37+
# Print number of GPU cores (Apple Silicon)
38+
if command -v system_profiler &> /dev/null; then
39+
GPU_CORES=$(system_profiler SPDisplaysDataType | awk '/Total Number of Cores/ {print $5; exit}')
40+
if [ -z "$GPU_CORES" ]; then
41+
# Fallback: try to parse "Core Count" from Apple GPU section
42+
GPU_CORES=$(system_profiler SPDisplaysDataType | awk '/Core Count/ {print $3; exit}')
43+
fi
44+
echo "GPU Cores: ${GPU_CORES:-Unknown}"
45+
else
46+
echo "system_profiler not available, cannot determine GPU cores."
47+
fi
48+
fi
49+
50+
# Test ExecuTorch Metal build
51+
PYTHON_EXECUTABLE=python CMAKE_ARGS="-DEXECUTORCH_BUILD_METAL=ON" ${CONDA_RUN} --no-capture-output ./install_executorch.sh
3652
3753
export-voxtral-metal-artifact:
3854
name: export-voxtral-metal-artifact
39-
runs-on: macos-latest
40-
steps:
41-
- name: Checkout repository
42-
uses: actions/checkout@v3
43-
with:
44-
submodules: recursive
45-
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
46-
47-
- name: Setup Python
48-
uses: actions/setup-python@v4
49-
with:
50-
python-version: '3.10'
51-
52-
- name: Export Voxtral with Metal Backend
53-
env:
54-
EXECUTORCH_HF_TOKEN: ${{ secrets.EXECUTORCH_HF_TOKEN }}
55-
run: |
56-
set -eux
57-
58-
echo "::group::Setup ExecuTorch"
59-
PYTHON_EXECUTABLE=python3 ./install_executorch.sh
60-
echo "::endgroup::"
61-
62-
echo "::group::Setup Huggingface"
63-
pip3 install -U "huggingface_hub[cli]" accelerate
64-
huggingface-cli login --token $EXECUTORCH_HF_TOKEN
65-
OPTIMUM_ET_VERSION=$(cat .ci/docker/ci_commit_pins/optimum-executorch.txt)
66-
pip3 install git+https://github.com/huggingface/optimum-executorch.git@${OPTIMUM_ET_VERSION}
67-
pip3 install mistral-common librosa
68-
pip3 list
69-
echo "::endgroup::"
70-
71-
echo "::group::Export Voxtral"
72-
optimum-cli export executorch \
73-
--model "mistralai/Voxtral-Mini-3B-2507" \
74-
--task "multimodal-text-to-text" \
75-
--recipe "metal" \
76-
--dtype bfloat16 \
77-
--max_seq_len 1024 \
78-
--output_dir ./
79-
python3 -m executorch.extension.audio.mel_spectrogram \
80-
--feature_size 128 \
81-
--stack_output \
82-
--max_audio_len 300 \
83-
--output_file voxtral_preprocessor.pte
84-
85-
test -f model.pte
86-
test -f aoti_metal_blob.ptd
87-
test -f voxtral_preprocessor.pte
88-
echo "::endgroup::"
89-
90-
echo "::group::Store Voxtral Artifacts"
91-
mkdir -p artifacts
92-
cp model.pte artifacts/
93-
cp aoti_metal_blob.ptd artifacts/
94-
cp voxtral_preprocessor.pte artifacts/
95-
ls -al artifacts
96-
echo "::endgroup::"
97-
98-
- name: Upload artifacts
99-
uses: actions/upload-artifact@v4
100-
with:
101-
name: voxtral-metal-export
102-
path: artifacts/
55+
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
56+
secrets: inherit
57+
with:
58+
runner: macos-m2-stable
59+
python-version: '3.11'
60+
submodules: 'recursive'
61+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
62+
timeout: 90
63+
secrets-env: EXECUTORCH_HF_TOKEN
64+
upload-artifact: voxtral-metal-export
65+
script: |
66+
set -eux
67+
68+
# Print machine info
69+
uname -a
70+
if [ $(uname -s) == Darwin ]; then
71+
sw_vers
72+
# Print RAM in GB
73+
RAM_BYTES=$(sysctl -n hw.memsize)
74+
RAM_GB=$(echo "scale=2; $RAM_BYTES/1024/1024/1024" | bc)
75+
echo "Available RAM (GB): $RAM_GB"
76+
sysctl machdep.cpu.brand_string
77+
sysctl machdep.cpu.core_count
78+
# Print number of GPU cores (Apple Silicon)
79+
if command -v system_profiler &> /dev/null; then
80+
GPU_CORES=$(system_profiler SPDisplaysDataType | awk '/Total Number of Cores/ {print $5; exit}')
81+
if [ -z "$GPU_CORES" ]; then
82+
# Fallback: try to parse "Core Count" from Apple GPU section
83+
GPU_CORES=$(system_profiler SPDisplaysDataType | awk '/Core Count/ {print $3; exit}')
84+
fi
85+
echo "GPU Cores: ${GPU_CORES:-Unknown}"
86+
else
87+
echo "system_profiler not available, cannot determine GPU cores."
88+
fi
89+
fi
90+
91+
OPTIMUM_ET_VERSION=$(cat .ci/docker/ci_commit_pins/optimum-executorch.txt)
92+
echo "Using optimum-executorch version: ${OPTIMUM_ET_VERSION}"
93+
94+
echo "::group::Setup ExecuTorch"
95+
PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output ./install_executorch.sh
96+
echo "::endgroup::"
97+
98+
echo "::group::Setup Huggingface"
99+
pip install -U "huggingface_hub[cli]" accelerate
100+
huggingface-cli login --token $SECRET_EXECUTORCH_HF_TOKEN
101+
pip install git+https://github.com/huggingface/optimum-executorch.git@${OPTIMUM_ET_VERSION}
102+
pip install mistral-common librosa
103+
pip list
104+
echo "::endgroup::"
105+
106+
echo "::group::Export Voxtral"
107+
optimum-cli export executorch \
108+
--model "mistralai/Voxtral-Mini-3B-2507" \
109+
--task "multimodal-text-to-text" \
110+
--recipe "metal" \
111+
--dtype bfloat16 \
112+
--max_seq_len 1024 \
113+
--output_dir ./
114+
python -m executorch.extension.audio.mel_spectrogram \
115+
--feature_size 128 \
116+
--stack_output \
117+
--max_audio_len 300 \
118+
--output_file voxtral_preprocessor.pte
119+
120+
test -f model.pte
121+
test -f aoti_metal_blob.ptd
122+
test -f voxtral_preprocessor.pte
123+
echo "::endgroup::"
124+
125+
echo "::group::Store Voxtral Artifacts"
126+
mkdir -p "${RUNNER_ARTIFACT_DIR}"
127+
cp model.pte "${RUNNER_ARTIFACT_DIR}/"
128+
cp aoti_metal_blob.ptd "${RUNNER_ARTIFACT_DIR}/"
129+
cp voxtral_preprocessor.pte "${RUNNER_ARTIFACT_DIR}/"
130+
ls -al "${RUNNER_ARTIFACT_DIR}"
131+
echo "::endgroup::"
103132
104133
test-voxtral-metal-e2e:
105134
name: test-voxtral-metal-e2e
106135
needs: export-voxtral-metal-artifact
107-
runs-on: macos-latest
108-
steps:
109-
- name: Checkout repository
110-
uses: actions/checkout@v3
111-
with:
112-
submodules: recursive
113-
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
114-
115-
- name: Setup Python
116-
uses: actions/setup-python@v4
117-
with:
118-
python-version: '3.10'
119-
120-
- name: Download artifacts
121-
uses: actions/download-artifact@v4
122-
with:
123-
name: voxtral-metal-export
124-
path: artifacts/
125-
126-
- name: Test Voxtral Metal E2E
127-
run: |
128-
set -eux
129-
130-
echo "::group::Setup ExecuTorch Requirements"
131-
CMAKE_ARGS="-DEXECUTORCH_BUILD_METAL=ON" ./install_requirements.sh
132-
pip3 list
133-
echo "::endgroup::"
134-
135-
echo "::group::Prepare Voxtral Artifacts"
136-
cp artifacts/model.pte .
137-
cp artifacts/aoti_metal_blob.ptd .
138-
cp artifacts/voxtral_preprocessor.pte .
139-
TOKENIZER_URL="https://huggingface.co/mistralai/Voxtral-Mini-3B-2507/resolve/main/tekken.json"
140-
curl -L $TOKENIZER_URL -o tekken.json
141-
ls -al model.pte aoti_metal_blob.ptd voxtral_preprocessor.pte tekken.json
142-
echo "::endgroup::"
143-
144-
echo "::group::Create Test Audio File"
145-
say -o call_samantha_hall.aiff "Call Samantha Hall"
146-
afconvert -f WAVE -d LEI16 call_samantha_hall.aiff call_samantha_hall.wav
147-
echo "::endgroup::"
148-
149-
echo "::group::Build Voxtral Runner"
150-
cmake --preset llm \
151-
-DEXECUTORCH_BUILD_METAL=ON \
152-
-DCMAKE_INSTALL_PREFIX=cmake-out \
153-
-DCMAKE_BUILD_TYPE=Release \
154-
-Bcmake-out -S.
155-
cmake --build cmake-out -j$(( $(sysctl -n hw.ncpu) - 1 )) --target install --config Release
156-
157-
cmake -DEXECUTORCH_BUILD_METAL=ON \
158-
-DCMAKE_BUILD_TYPE=Release \
159-
-Sexamples/models/voxtral \
160-
-Bcmake-out/examples/models/voxtral/
161-
cmake --build cmake-out/examples/models/voxtral --target voxtral_runner --config Release
162-
echo "::endgroup::"
163-
164-
echo "::group::Run Voxtral Runner"
165-
set +e
166-
OUTPUT=$(cmake-out/examples/models/voxtral/voxtral_runner \
167-
--model_path model.pte \
168-
--data_path aoti_metal_blob.ptd \
169-
--tokenizer_path tekken.json \
170-
--audio_path call_samantha_hall.wav \
171-
--processor_path voxtral_preprocessor.pte \
172-
--temperature 0 2>&1)
173-
EXIT_CODE=$?
174-
set -e
175-
176-
echo "$OUTPUT"
177-
178-
if ! echo "$OUTPUT" | grep -iq "Samantha"; then
179-
echo "Expected output 'Samantha' not found in output"
180-
exit 1
181-
fi
182-
183-
if [ $EXIT_CODE -ne 0 ]; then
184-
echo "Unexpected exit code: $EXIT_CODE"
185-
exit $EXIT_CODE
136+
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
137+
with:
138+
runner: macos-m2-stable
139+
python-version: '3.11'
140+
submodules: 'recursive'
141+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
142+
timeout: 90
143+
download-artifact: voxtral-metal-export
144+
script: |
145+
set -eux
146+
147+
# Print machine info
148+
uname -a
149+
if [ $(uname -s) == Darwin ]; then
150+
sw_vers
151+
# Print RAM in GB
152+
RAM_BYTES=$(sysctl -n hw.memsize)
153+
RAM_GB=$(echo "scale=2; $RAM_BYTES/1024/1024/1024" | bc)
154+
echo "Available RAM (GB): $RAM_GB"
155+
sysctl machdep.cpu.brand_string
156+
sysctl machdep.cpu.core_count
157+
# Print number of GPU cores (Apple Silicon)
158+
if command -v system_profiler &> /dev/null; then
159+
GPU_CORES=$(system_profiler SPDisplaysDataType | awk '/Total Number of Cores/ {print $5; exit}')
160+
if [ -z "$GPU_CORES" ]; then
161+
# Fallback: try to parse "Core Count" from Apple GPU section
162+
GPU_CORES=$(system_profiler SPDisplaysDataType | awk '/Core Count/ {print $3; exit}')
163+
fi
164+
echo "GPU Cores: ${GPU_CORES:-Unknown}"
165+
else
166+
echo "system_profiler not available, cannot determine GPU cores."
186167
fi
187-
echo "::endgroup::"
168+
fi
169+
170+
echo "::group::Setup ExecuTorch Requirements"
171+
CMAKE_ARGS="-DEXECUTORCH_BUILD_METAL=ON" ${CONDA_RUN} --no-capture-output ./install_requirements.sh
172+
pip list
173+
echo "::endgroup::"
174+
175+
echo "::group::Prepare Voxtral Artifacts"
176+
cp "${RUNNER_ARTIFACT_DIR}/model.pte" .
177+
cp "${RUNNER_ARTIFACT_DIR}/aoti_metal_blob.ptd" .
178+
cp "${RUNNER_ARTIFACT_DIR}/voxtral_preprocessor.pte" .
179+
TOKENIZER_URL="https://huggingface.co/mistralai/Voxtral-Mini-3B-2507/resolve/main/tekken.json"
180+
curl -L $TOKENIZER_URL -o tekken.json
181+
ls -al model.pte aoti_metal_blob.ptd voxtral_preprocessor.pte tekken.json
182+
echo "::endgroup::"
183+
184+
echo "::group::Create Test Audio File"
185+
say -o call_samantha_hall.aiff "Call Samantha Hall"
186+
afconvert -f WAVE -d LEI16 call_samantha_hall.aiff call_samantha_hall.wav
187+
echo "::endgroup::"
188+
189+
echo "::group::Build Voxtral Runner"
190+
cmake --preset llm \
191+
-DEXECUTORCH_BUILD_METAL=ON \
192+
-DCMAKE_INSTALL_PREFIX=cmake-out \
193+
-DCMAKE_BUILD_TYPE=Release \
194+
-Bcmake-out -S.
195+
cmake --build cmake-out -j$(( $(sysctl -n hw.ncpu) - 1 )) --target install --config Release
196+
197+
cmake -DEXECUTORCH_BUILD_METAL=ON \
198+
-DCMAKE_BUILD_TYPE=Release \
199+
-Sexamples/models/voxtral \
200+
-Bcmake-out/examples/models/voxtral/
201+
cmake --build cmake-out/examples/models/voxtral --target voxtral_runner --config Release
202+
echo "::endgroup::"
203+
204+
echo "::group::Run Voxtral Runner"
205+
set +e
206+
OUTPUT=$(cmake-out/examples/models/voxtral/voxtral_runner \
207+
--model_path model.pte \
208+
--data_path aoti_metal_blob.ptd \
209+
--tokenizer_path tekken.json \
210+
--audio_path call_samantha_hall.wav \
211+
--processor_path voxtral_preprocessor.pte \
212+
--temperature 0 2>&1)
213+
EXIT_CODE=$?
214+
set -e
215+
216+
echo "$OUTPUT"
217+
218+
if ! echo "$OUTPUT" | grep -iq "Samantha"; then
219+
echo "Expected output 'Samantha' not found in output"
220+
exit 1
221+
fi
222+
223+
if [ $EXIT_CODE -ne 0 ]; then
224+
echo "Unexpected exit code: $EXIT_CODE"
225+
exit $EXIT_CODE
226+
fi
227+
echo "::endgroup::"

0 commit comments

Comments
 (0)