Skip to content

Commit deb78ad

Browse files
committed
up]
1 parent 909b304 commit deb78ad

File tree

2 files changed

+41
-18
lines changed

2 files changed

+41
-18
lines changed

.ci/scripts/test_model.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ test_model_with_qnn() {
233233
test_model_with_coreml() {
234234
local should_test="$1"
235235
local test_with_pybindings="$2"
236+
local dtype="$3"
236237

237238
if [[ "${BUILD_TOOL}" != "cmake" ]]; then
238239
echo "coreml only supports cmake."
@@ -245,7 +246,7 @@ test_model_with_coreml() {
245246
export RUN_WITH_PYBINDINGS="--run_with_pybindings"
246247
fi
247248

248-
"${PYTHON_EXECUTABLE}" -m examples.apple.coreml.scripts.export --model_name="${MODEL_NAME}" --compute_precision float16 --use_partitioner ${RUN_WITH_PYBINDINGS}
249+
"${PYTHON_EXECUTABLE}" -m examples.apple.coreml.scripts.export --model_name="${MODEL_NAME}" --compute_precision ${dtype} --use_partitioner ${RUN_WITH_PYBINDINGS}
249250
EXPORTED_MODEL=$(find "." -type f -name "${MODEL_NAME}*.pte" -print -quit)
250251

251252
if [ -n "$EXPORTED_MODEL" ]; then
@@ -309,7 +310,11 @@ elif [[ "${BACKEND}" == *"coreml"* ]]; then
309310
if [[ "${BACKEND}" == *"pybind"* ]]; then
310311
test_with_pybindings=true
311312
fi
312-
test_model_with_coreml "${should_test_coreml}" "${test_with_pybindings}"
313+
dtype=float16
314+
if [[ "${BACKEND}" == *"float32"* ]]; then
315+
dtype=float32
316+
fi
317+
test_model_with_coreml "${should_test_coreml}" "${test_with_pybindings}" "${dtype}"
313318
if [[ $? -eq 0 ]]; then
314319
prepare_artifacts_upload
315320
fi

.github/workflows/trunk.yml

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ concurrency:
1818
cancel-in-progress: true
1919

2020
jobs:
21-
test-models-macos:
22-
name: test-models-macos
21+
test-models-macos-cpu:
22+
name: test-models-macos-cpu
2323
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
2424
strategy:
2525
matrix:
@@ -568,10 +568,12 @@ jobs:
568568
PYTHON_EXECUTABLE=python bash .ci/scripts/build-qnn-sdk.sh
569569
PYTHON_EXECUTABLE=python bash .ci/scripts/test_model.sh ${{ matrix.model }} "cmake" "qnn"
570570
571-
test-apple-model:
572-
name: test-apple-model
571+
test-models-macos-coreml:
572+
name: test-models-macos-coreml
573573
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
574574
strategy:
575+
matrix:
576+
model: [dl3, edsr, efficient_sam, emformer_join, emformer_transcribe, ic3, ic4, mobilebert, mv2, mv3, resnet50, vit, w2l]
575577
fail-fast: false
576578
with:
577579
runner: macos-m1-stable
@@ -580,7 +582,16 @@ jobs:
580582
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
581583
timeout: 90
582584
script: |
585+
MODEL_NAME=${{ matrix.model }}
583586
BUILD_TOOL=cmake
587+
BACKEND="coreml-pybind"
588+
589+
590+
# Set model specific overrides
591+
if [[ "${MODEL_NAME}" == "mobilebert" ]]; then
592+
# mobilebert has nan output on FP16, and high MSE on fp32, so we disable runtime test now
593+
BACKEND="coreml-pybind-float32"
594+
fi
584595
585596
bash .ci/scripts/setup-conda.sh
586597
@@ -589,18 +600,25 @@ jobs:
589600
PYTHON_EXECUTABLE=python ${CONDA_RUN} bash backends/apple/coreml/scripts/install_requirements.sh
590601
echo "Finishing installing coreml."
591602
592-
# Build and test coreml model
593-
for MODEL_NAME in dl3 edsr emformer_join ic3 ic4 mobilebert mv2 mv3 resnet50 vit w2l; do
594-
echo "::group::Exporting coreml model: $MODEL_NAME"
595-
if [[ "${MODEL_NAME}" == "mobilebert" ]]; then
596-
# mobilebert has nan output on FP16
597-
BACKEND="coreml"
598-
else
599-
BACKEND="coreml-pybind"
600-
fi
601-
PYTHON_EXECUTABLE=python ${CONDA_RUN} bash .ci/scripts/test_model.sh "${MODEL_NAME}" "${BUILD_TOOL}" "${BACKEND}"
602-
echo "::endgroup::"
603-
done
603+
PYTHON_EXECUTABLE=python ${CONDA_RUN} bash .ci/scripts/test_model.sh "${MODEL_NAME}" "${BUILD_TOOL}" "${BACKEND}"
604+
605+
test-models-macos-mps:
606+
name: test-models-macos-mps
607+
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
608+
strategy:
609+
fail-fast: false
610+
with:
611+
runner: macos-m1-stable
612+
python-version: '3.11'
613+
submodules: 'recursive'
614+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
615+
timeout: 90
616+
script: |
617+
BUILD_TOOL=cmake
618+
bash .ci/scripts/setup-conda.sh
619+
620+
# Setup MacOS dependencies as there is no Docker support on MacOS atm
621+
PYTHON_EXECUTABLE=python ${CONDA_RUN} bash .ci/scripts/setup-macos.sh --build-tool "${BUILD_TOOL}"
604622
605623
# Build and test mps model
606624
for MODEL_NAME in mv3 ic4 resnet50 edsr mobilebert w2l; do

0 commit comments

Comments
 (0)