executorch icon indicating copy to clipboard operation
executorch copied to clipboard

Support CoreML export on Linux

Open jathu opened this issue 8 months ago • 3 comments

Allow exporting to CoreML backends on Linux. Running the model on Linux is not an expectation. More context: https://github.com/pytorch/executorch/issues/9019

cc @larryliu0820 @lucylq @mergennachin @byjlw

jathu avatar Apr 01 '25 15:04 jathu

Here's the use case I'm thinking of:

Model developers want to export a model and create .pte file with coreml delegate embedded using directly on colab notebook and/or on their linux laptop.

And give the .pte model file to iOS application developers, so that they can just take it and embed as part of their app

mergennachin avatar Apr 01 '25 15:04 mergennachin

As far as prioritizing this appropriately, I thought I'd mention that coremltools can produce pre-compiled models when run from Mac, but not when run from Linux. Using pre-compiled models can mean faster first-time inference, and if this is important using linux to produce a CoreML PTE vs. Mac may be undesirable.

In more details, the CoreML PTE file can either have an uncompiled coreml model inside of it, or a compiled coreml model inside of it. If it has an uncompiled model inside of it, the compilation must happen on device (the phone). The resulting model is cached, but it can make first inference slow.

The determination of whether a CoreML PTE file has a compiled or uncompiled model is a partitioner option, but on linux the compiled option could not be supported.

metascroy avatar Apr 25 '25 20:04 metascroy

The required work for OSS is probably creating a cmake target similar to this buck one: https://github.com/pytorch/executorch/blob/bf272de13f936628c895d4723d07f3296ace0366/backends/apple/coreml/TARGETS#L61

metascroy avatar Apr 28 '25 16:04 metascroy

The required work for OSS is probably creating a cmake target similar to this buck one:

executorch/backends/apple/coreml/TARGETS

Line 61 in bf272de

runtime.cxx_python_extension(

Thanks for the pointer. Yeah this should be feasible, we have pybind working properly on Mac.

larryliu0820 avatar Apr 29 '25 20:04 larryliu0820