diff --git a/.github/workflows/export-models.yml b/.github/workflows/export-models.yml index 11570ca785..baa8e77132 100644 --- a/.github/workflows/export-models.yml +++ b/.github/workflows/export-models.yml @@ -36,7 +36,6 @@ jobs: output: | mv3/python/mv3.pte mv3/python/mv3_coreml_all.pte - mv3/python/mv3_mps_float16.pte mv3/python/mv3_xnnpack_fp32.pte name: Export ${{ matrix.name }} diff --git a/llm/apple/README.md b/llm/apple/README.md index 65fbc6b762..7091263185 100644 --- a/llm/apple/README.md +++ b/llm/apple/README.md @@ -38,7 +38,7 @@ Get hands-on with running LLMs — exported via ExecuTorch — natively on your ​​​ ## Models ​​​ -Download already exported LLMs along with tokenizers from [HuggingFace](https://huggingface.co/executorch-community) or export your own empowered by XNNPACK, Core ML or MPS backends. +Download already exported LLMs along with tokenizers from [HuggingFace](https://huggingface.co/executorch-community) or export your own empowered by XNNPACK or Core ML backends. ​​​ ## Build and Run diff --git a/llm/apple/etLLM.xcodeproj/project.pbxproj b/llm/apple/etLLM.xcodeproj/project.pbxproj index ed2298db0b..2528976e5f 100644 --- a/llm/apple/etLLM.xcodeproj/project.pbxproj +++ b/llm/apple/etLLM.xcodeproj/project.pbxproj @@ -18,7 +18,6 @@ 0324D6932BAACB6900DEF36F /* ResourceMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0324D6882BAACB6900DEF36F /* ResourceMonitor.swift */; }; 0324D6962BAACB7000DEF36F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0324D6942BAACB7000DEF36F /* Assets.xcassets */; }; 03F546242E70906E0040AE84 /* backend_coreml in Frameworks */ = {isa = PBXBuildFile; productRef = 03F546232E70906E0040AE84 /* backend_coreml */; }; - 03F546262E70906E0040AE84 /* backend_mps in Frameworks */ = {isa = PBXBuildFile; productRef = 03F546252E70906E0040AE84 /* backend_mps */; }; 03F546282E70906E0040AE84 /* backend_xnnpack in Frameworks */ = {isa = PBXBuildFile; productRef = 03F546272E70906E0040AE84 /* backend_xnnpack */; }; 03F5462A2E70906E0040AE84 /* executorch_debug in Frameworks */ = {isa = PBXBuildFile; productRef = 03F546292E70906E0040AE84 /* executorch_debug */; }; 03F5462C2E70906E0040AE84 /* executorch_llm_debug in Frameworks */ = {isa = PBXBuildFile; productRef = 03F5462B2E70906E0040AE84 /* executorch_llm_debug */; }; @@ -42,7 +41,6 @@ MAC0001002E8000000000000B /* ImagePicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26A6A4272C8A3769005A761E /* ImagePicker.swift */; }; MAC0001002E8000000000000C /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3072D5222DC3EA280083FC83 /* Constants.swift */; }; MAC0001002E8000000000000D /* backend_coreml in Frameworks */ = {isa = PBXBuildFile; productRef = MAC0001002E80000000000020 /* backend_coreml */; }; - MAC0001002E8000000000000E /* backend_mps in Frameworks */ = {isa = PBXBuildFile; productRef = MAC0001002E80000000000021 /* backend_mps */; }; MAC0001002E8000000000000F /* backend_xnnpack in Frameworks */ = {isa = PBXBuildFile; productRef = MAC0001002E80000000000022 /* backend_xnnpack */; }; MAC0001002E80000000000010 /* executorch_debug in Frameworks */ = {isa = PBXBuildFile; productRef = MAC0001002E80000000000023 /* executorch_debug */; }; MAC0001002E80000000000011 /* executorch_llm_debug in Frameworks */ = {isa = PBXBuildFile; productRef = MAC0001002E80000000000024 /* executorch_llm_debug */; }; @@ -83,7 +81,6 @@ 03F546322E70906E0040AE84 /* kernels_quantized in Frameworks */, 03F5462E2E70906E0040AE84 /* kernels_llm in Frameworks */, 03F5462A2E70906E0040AE84 /* executorch_debug in Frameworks */, - 03F546262E70906E0040AE84 /* backend_mps in Frameworks */, 03F546242E70906E0040AE84 /* backend_coreml in Frameworks */, 03F546302E70906E0040AE84 /* kernels_optimized in Frameworks */, 03F546282E70906E0040AE84 /* backend_xnnpack in Frameworks */, @@ -99,7 +96,6 @@ MAC0001002E80000000000014 /* kernels_quantized in Frameworks */, MAC0001002E80000000000012 /* kernels_llm in Frameworks */, MAC0001002E80000000000010 /* executorch_debug in Frameworks */, - MAC0001002E8000000000000E /* backend_mps in Frameworks */, MAC0001002E8000000000000D /* backend_coreml in Frameworks */, MAC0001002E80000000000013 /* kernels_optimized in Frameworks */, MAC0001002E8000000000000F /* backend_xnnpack in Frameworks */, @@ -191,7 +187,6 @@ name = etLLM; packageProductDependencies = ( 03F546232E70906E0040AE84 /* backend_coreml */, - 03F546252E70906E0040AE84 /* backend_mps */, 03F546272E70906E0040AE84 /* backend_xnnpack */, 03F546292E70906E0040AE84 /* executorch_debug */, 03F5462B2E70906E0040AE84 /* executorch_llm_debug */, @@ -219,7 +214,6 @@ name = "etLLM-macOS"; packageProductDependencies = ( MAC0001002E80000000000020 /* backend_coreml */, - MAC0001002E80000000000021 /* backend_mps */, MAC0001002E80000000000022 /* backend_xnnpack */, MAC0001002E80000000000023 /* executorch_debug */, MAC0001002E80000000000024 /* executorch_llm_debug */, @@ -638,11 +632,6 @@ package = 03CF43942CEC5CEC00C7113B /* XCRemoteSwiftPackageReference "executorch" */; productName = backend_coreml; }; - 03F546252E70906E0040AE84 /* backend_mps */ = { - isa = XCSwiftPackageProductDependency; - package = 03CF43942CEC5CEC00C7113B /* XCRemoteSwiftPackageReference "executorch" */; - productName = backend_mps; - }; 03F546272E70906E0040AE84 /* backend_xnnpack */ = { isa = XCSwiftPackageProductDependency; package = 03CF43942CEC5CEC00C7113B /* XCRemoteSwiftPackageReference "executorch" */; @@ -684,11 +673,6 @@ package = 03CF43942CEC5CEC00C7113B /* XCRemoteSwiftPackageReference "executorch" */; productName = backend_coreml; }; - MAC0001002E80000000000021 /* backend_mps */ = { - isa = XCSwiftPackageProductDependency; - package = 03CF43942CEC5CEC00C7113B /* XCRemoteSwiftPackageReference "executorch" */; - productName = backend_mps; - }; MAC0001002E80000000000022 /* backend_xnnpack */ = { isa = XCSwiftPackageProductDependency; package = 03CF43942CEC5CEC00C7113B /* XCRemoteSwiftPackageReference "executorch" */; diff --git a/mv3/apple/ExecuTorchDemo/ExecuTorchDemo.xcodeproj/project.pbxproj b/mv3/apple/ExecuTorchDemo/ExecuTorchDemo.xcodeproj/project.pbxproj index 98506092ff..324f4eb832 100644 --- a/mv3/apple/ExecuTorchDemo/ExecuTorchDemo.xcodeproj/project.pbxproj +++ b/mv3/apple/ExecuTorchDemo/ExecuTorchDemo.xcodeproj/project.pbxproj @@ -7,7 +7,6 @@ objects = { /* Begin PBXBuildFile section */ - 031B92F72ACF2A5400D4EBE0 /* mv3_mps_float16.pte in Resources */ = {isa = PBXBuildFile; fileRef = 031B92F62ACF2A5400D4EBE0 /* mv3_mps_float16.pte */; }; 032C01A52AC22B16002955E1 /* App.swift in Sources */ = {isa = PBXBuildFile; fileRef = 032C018B2AC22B16002955E1 /* App.swift */; }; 032C01A72AC22B16002955E1 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 032C018D2AC22B16002955E1 /* ContentView.swift */; }; 032C01B72AC329B6002955E1 /* CustomViews.swift in Sources */ = {isa = PBXBuildFile; fileRef = 032C01B62AC329B6002955E1 /* CustomViews.swift */; }; @@ -16,11 +15,9 @@ 032C02032AC47CFB002955E1 /* mv3_xnnpack_fp32.pte in Resources */ = {isa = PBXBuildFile; fileRef = 032C01FC2AC47CFB002955E1 /* mv3_xnnpack_fp32.pte */; }; 032C02082AC47CFB002955E1 /* imagenet_classes.txt in Resources */ = {isa = PBXBuildFile; fileRef = 032C02012AC47CFB002955E1 /* imagenet_classes.txt */; }; 03672A662DE1226100147123 /* backend_coreml in Frameworks */ = {isa = PBXBuildFile; productRef = 03672A652DE1226100147123 /* backend_coreml */; }; - 03672A682DE1226100147123 /* backend_mps in Frameworks */ = {isa = PBXBuildFile; productRef = 03672A672DE1226100147123 /* backend_mps */; }; 03672A6A2DE1226100147123 /* backend_xnnpack in Frameworks */ = {isa = PBXBuildFile; productRef = 03672A692DE1226100147123 /* backend_xnnpack */; }; 03672A752DE144CF00147123 /* executorch_debug in Frameworks */ = {isa = PBXBuildFile; productRef = 03672A742DE144CF00147123 /* executorch_debug */; }; 03672A772DE1457900147123 /* backend_coreml in Frameworks */ = {isa = PBXBuildFile; productRef = 03672A762DE1457900147123 /* backend_coreml */; }; - 03672A792DE1457900147123 /* backend_mps in Frameworks */ = {isa = PBXBuildFile; productRef = 03672A782DE1457900147123 /* backend_mps */; }; 03672A7B2DE1457900147123 /* backend_xnnpack in Frameworks */ = {isa = PBXBuildFile; productRef = 03672A7A2DE1457900147123 /* backend_xnnpack */; }; 036834D52ACB710D00BA100F /* mv3.pte in Resources */ = {isa = PBXBuildFile; fileRef = 036834D42ACB710D00BA100F /* mv3.pte */; }; 036834D62ACB710D00BA100F /* mv3.pte in Resources */ = {isa = PBXBuildFile; fileRef = 036834D42ACB710D00BA100F /* mv3.pte */; }; @@ -40,7 +37,6 @@ 03C818482AC7BF470084CC29 /* imagenet_classes.txt in Resources */ = {isa = PBXBuildFile; fileRef = 032C02012AC47CFB002955E1 /* imagenet_classes.txt */; }; 03C8184A2AC7BF470084CC29 /* mv3_xnnpack_fp32.pte in Resources */ = {isa = PBXBuildFile; fileRef = 032C01FC2AC47CFB002955E1 /* mv3_xnnpack_fp32.pte */; }; 03C8DC7C2AE2533C0064384A /* mv3_coreml_all.pte in Resources */ = {isa = PBXBuildFile; fileRef = 036834D72ACB893700BA100F /* mv3_coreml_all.pte */; }; - 03D494E22B5B7AE900FCF524 /* mv3_mps_float16.pte in Resources */ = {isa = PBXBuildFile; fileRef = 031B92F62ACF2A5400D4EBE0 /* mv3_mps_float16.pte */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -89,7 +85,6 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ - 031B92F62ACF2A5400D4EBE0 /* mv3_mps_float16.pte */ = {isa = PBXFileReference; lastKnownFileType = file; path = mv3_mps_float16.pte; sourceTree = ""; }; 032C016F2AC228E6002955E1 /* ExecuTorchDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ExecuTorchDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 032C018A2AC22B16002955E1 /* MobileNetClassifier.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MobileNetClassifier.swift; sourceTree = ""; }; 032C018B2AC22B16002955E1 /* App.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = App.swift; sourceTree = ""; }; @@ -120,7 +115,6 @@ 032C01EC2AC34CAC002955E1 /* libMobileNetClassifier.a in Frameworks */, 03672A6A2DE1226100147123 /* backend_xnnpack in Frameworks */, 03B184962E1FA1E400246294 /* kernels_optimized in Frameworks */, - 03672A682DE1226100147123 /* backend_mps in Frameworks */, 03672A662DE1226100147123 /* backend_coreml in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -141,7 +135,6 @@ 03C818282AC760650084CC29 /* libMobileNetClassifier.a in Frameworks */, 03672A7B2DE1457900147123 /* backend_xnnpack in Frameworks */, 03B184982E1FA1F400246294 /* kernels_optimized in Frameworks */, - 03672A792DE1457900147123 /* backend_mps in Frameworks */, 03672A772DE1457900147123 /* backend_coreml in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -239,7 +232,6 @@ children = ( 032C02012AC47CFB002955E1 /* imagenet_classes.txt */, 036834D72ACB893700BA100F /* mv3_coreml_all.pte */, - 031B92F62ACF2A5400D4EBE0 /* mv3_mps_float16.pte */, 032C01FC2AC47CFB002955E1 /* mv3_xnnpack_fp32.pte */, 036834D42ACB710D00BA100F /* mv3.pte */, ); @@ -298,7 +290,6 @@ name = App; packageProductDependencies = ( 03672A652DE1226100147123 /* backend_coreml */, - 03672A672DE1226100147123 /* backend_mps */, 03672A692DE1226100147123 /* backend_xnnpack */, 03B184952E1FA1E400246294 /* kernels_optimized */, ); @@ -343,7 +334,6 @@ name = MobileNetClassifierTest; packageProductDependencies = ( 03672A762DE1457900147123 /* backend_coreml */, - 03672A782DE1457900147123 /* backend_mps */, 03672A7A2DE1457900147123 /* backend_xnnpack */, 03B184972E1FA1F400246294 /* kernels_optimized */, ); @@ -420,7 +410,6 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 031B92F72ACF2A5400D4EBE0 /* mv3_mps_float16.pte in Resources */, 036834D82ACB893700BA100F /* mv3_coreml_all.pte in Resources */, 036834D52ACB710D00BA100F /* mv3.pte in Resources */, 032C02082AC47CFB002955E1 /* imagenet_classes.txt in Resources */, @@ -439,7 +428,6 @@ 03C818192AC671980084CC29 /* Samoyed.jpg in Resources */, 03C8181F2AC69DFF0084CC29 /* hot pot.jpg in Resources */, 03C8DC7C2AE2533C0064384A /* mv3_coreml_all.pte in Resources */, - 03D494E22B5B7AE900FCF524 /* mv3_mps_float16.pte in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -810,11 +798,6 @@ package = 03672A642DE1226100147123 /* XCRemoteSwiftPackageReference "executorch" */; productName = backend_coreml; }; - 03672A672DE1226100147123 /* backend_mps */ = { - isa = XCSwiftPackageProductDependency; - package = 03672A642DE1226100147123 /* XCRemoteSwiftPackageReference "executorch" */; - productName = backend_mps; - }; 03672A692DE1226100147123 /* backend_xnnpack */ = { isa = XCSwiftPackageProductDependency; package = 03672A642DE1226100147123 /* XCRemoteSwiftPackageReference "executorch" */; @@ -830,11 +813,6 @@ package = 03672A642DE1226100147123 /* XCRemoteSwiftPackageReference "executorch" */; productName = backend_coreml; }; - 03672A782DE1457900147123 /* backend_mps */ = { - isa = XCSwiftPackageProductDependency; - package = 03672A642DE1226100147123 /* XCRemoteSwiftPackageReference "executorch" */; - productName = backend_mps; - }; 03672A7A2DE1457900147123 /* backend_xnnpack */ = { isa = XCSwiftPackageProductDependency; package = 03672A642DE1226100147123 /* XCRemoteSwiftPackageReference "executorch" */; diff --git a/mv3/apple/ExecuTorchDemo/ExecuTorchDemo/Sources/App/ClassificationController.swift b/mv3/apple/ExecuTorchDemo/ExecuTorchDemo/Sources/App/ClassificationController.swift index 5a50da9c22..5b0b7894ac 100644 --- a/mv3/apple/ExecuTorchDemo/ExecuTorchDemo/Sources/App/ClassificationController.swift +++ b/mv3/apple/ExecuTorchDemo/ExecuTorchDemo/Sources/App/ClassificationController.swift @@ -13,7 +13,6 @@ import SwiftUI enum Mode: String, CaseIterable { case xnnpack = "XNNPACK" case coreML = "Core ML" - case mps = "MPS" } class ClassificationController: ObservableObject { @@ -63,8 +62,6 @@ class ClassificationController: ObservableObject { switch mode { case .coreML: modelFileName = "mv3_coreml_all" - case .mps: - modelFileName = "mv3_mps_float16" case .xnnpack: modelFileName = "mv3_xnnpack_fp32" } diff --git a/mv3/apple/ExecuTorchDemo/README.md b/mv3/apple/ExecuTorchDemo/README.md index 0397ebd116..9ddba7818b 100644 --- a/mv3/apple/ExecuTorchDemo/README.md +++ b/mv3/apple/ExecuTorchDemo/README.md @@ -4,10 +4,9 @@ Welcome to the tutorial on setting up the ExecuTorch iOS Demo App! This app uses the [MobileNet v3](https://pytorch.org/vision/main/models/mobilenetv3.html) model to -process live camera images leveraging three different backends: -[XNNPACK](https://github.com/google/XNNPACK), -[Core ML](https://developer.apple.com/documentation/coreml) and -[Metal Performance Shaders (MPS)](https://developer.apple.com/documentation/metalperformanceshaders) +process live camera images leveraging two different backends: +[XNNPACK](https://github.com/google/XNNPACK) and +[Core ML](https://developer.apple.com/documentation/coreml) (Xcode 15+ and iOS 17+ only).

@@ -70,7 +69,7 @@ Now, let's move on to exporting and bundling the MobileNet v3 model. ### 1. Export Model -Export the MobileNet v3 model using the command line with Core ML, MPS and XNNPACK backends +Export the MobileNet v3 model using the command line with Core ML and XNNPACK backends ```bash python3 mv3/python/export.py diff --git a/mv3/python/export.py b/mv3/python/export.py index c3dcaa5871..a9258e9ccc 100644 --- a/mv3/python/export.py +++ b/mv3/python/export.py @@ -27,23 +27,6 @@ def main() -> None: compile_config=EdgeCompileConfig(_skip_dim_order=True), ).to_executorch() - # MPS backend doesn't work yet with pip install today. - # Currently, it is just falling back to portable ops instead. - # - # Please install ExecuTorch from source if you want to run to MPS backend: - # - # https://pytorch.org/executorch/main/using-executorch-building-from-source.html#environment-setup - # ./install_executorch.sh --pybind mps coreml xnnpack - # ./backends/apple/mps/install_requirements.sh - # - # et_program_mps = to_edge_transform_and_lower( - # torch.export.export(model, sample_inputs), - # partitioner=[MPSPartitioner([CompileSpec("use_fp16", bytes([True]))])], - # ).to_executorch() - et_program_mps = to_edge( - torch.export.export(model, sample_inputs), - ).to_executorch() - et_program_xnnpack = to_edge_transform_and_lower( torch.export.export(model, sample_inputs), partitioner=[XnnpackPartitioner()], @@ -53,8 +36,6 @@ def main() -> None: et_program_portable.write_to_file(file) with open("mv3_coreml_all.pte", "wb") as file: et_program_coreml.write_to_file(file) - with open("mv3_mps_float16.pte", "wb") as file: - et_program_mps.write_to_file(file) with open("mv3_xnnpack_fp32.pte", "wb") as file: et_program_xnnpack.write_to_file(file)