Skip to content

Commit 28ac0e9

Browse files
committed
Enable MPS AOT for macOS by default
1 parent 28cbc2b commit 28ac0e9

File tree

6 files changed

+19
-5
lines changed

6 files changed

+19
-5
lines changed

.ci/scripts/test_model.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,17 @@ test_model_with_coreml() {
244244
}
245245

246246
test_model_with_mps() {
247-
"${PYTHON_EXECUTABLE}" -m examples.apple.mps.scripts.mps_example --model_name="${MODEL_NAME}" --use_fp16
247+
"${PYTHON_EXECUTABLE}" -m examples.apple.mps.scripts.mps_example --model_name="${MODEL_NAME}" --use_fp16 --bundled
248248
EXPORTED_MODEL=$(find "." -type f -name "${MODEL_NAME}*.pte" -print -quit)
249+
250+
if [ -z "${EXPORTED_MODEL}" ]; then
251+
echo "[error] failed to export model: no .pte file found"
252+
exit 1
253+
fi
254+
255+
echo "Testing exported model with mps_executor_runner..."
256+
./examples/apple/mps/scripts/build_mps_executor_runner.sh
257+
./cmake-out/examples/apple/mps/mps_executor_runner -bundled_program=True -model_path="${EXPORTED_MODEL}"
249258
}
250259

251260
if [[ "${BACKEND}" == "portable" ]]; then

.ci/scripts/wheel/test_macos.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,9 @@
1919
model=Model.Mv3,
2020
backend=Backend.CoreMlExportAndTest,
2121
),
22+
test_base.ModelTest(
23+
model=Model.Mv3,
24+
backend=Backend.AppleMPS,
25+
),
2226
]
2327
)

etdump.etdp

576 Bytes
Binary file not shown.

examples/apple/mps/scripts/build_mps_executor_runner.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,18 @@ cmake -DBUCK2="$BUCK" \
4444
-DEXECUTORCH_BUILD_DEVTOOLS=ON \
4545
-DEXECUTORCH_ENABLE_EVENT_TRACER=ON \
4646
-DEXECUTORCH_BUILD_MPS=ON \
47-
-DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" \
47+
-DEXECUTORCH_ENABLE_LOGGING=ON \
4848
-Bcmake-out .
49-
cmake --build cmake-out -j9 --target install --config "$MODE"
49+
cmake --build cmake-out -j$(sysctl -n hw.ncpu) --target install --config "$MODE"
5050
CMAKE_PREFIX_PATH="${PWD}/cmake-out/lib/cmake/ExecuTorch;${PWD}/cmake-out/third-party/gflags"
5151
# build mps_executor_runner
5252
rm -rf cmake-out/examples/apple/mps
5353
cmake \
5454
-DCMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH" \
5555
-DCMAKE_BUILD_TYPE="$MODE" \
56-
-DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" \
5756
-Bcmake-out/examples/apple/mps \
5857
examples/apple/mps
5958

60-
cmake --build cmake-out/examples/apple/mps -j9 --config "$MODE"
59+
cmake --build cmake-out/examples/apple/mps -j$(sysctl -n hw.ncpu) --config "$MODE"
6160

6261
echo "Build succeeded!"

examples/models/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class Backend(str, Enum):
4646
XnnpackQuantizationDelegation = "xnnpack-quantization-delegation"
4747
CoreMlExportOnly = "coreml"
4848
CoreMlExportAndTest = "coreml-test" # AOT export + test with runner
49+
AppleMPS = "mps"
4950

5051
def __str__(self) -> str:
5152
return self.value

tools/cmake/preset/pybind.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ set_overridable_option(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR ON)
2222

2323
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
2424
set_overridable_option(EXECUTORCH_BUILD_COREML ON)
25+
set_overridable_option(EXECUTORCH_BUILD_MPS ON)
2526
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
2627
set_overridable_option(EXECUTORCH_BUILD_COREML ON)
2728
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows" OR CMAKE_SYSTEM_NAME STREQUAL "WIN32")

0 commit comments

Comments
 (0)