-
Notifications
You must be signed in to change notification settings - Fork 753
Add ability to specify CoreML pipeline passes #16118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add ability to specify CoreML pipeline passes #16118
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/16118
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New Failure, 1 Unrelated FailureAs of commit d9174e4 with merge base 9193566 ( NEW FAILURE - The following job has failed:
BROKEN TRUNK - The following job failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds the ability to specify a custom CoreML pass pipeline through the CompileSpec system, enabling users to customize the model compilation process beyond the default pipeline.
Key Changes:
- Added
PASS_PIPELINEkey to the compile spec enumeration - Implemented methods to serialize/deserialize pass pipeline configurations
- Integrated custom pass pipeline into the CoreML conversion process
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@pytorchbot label "release notes: none" |
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Thanks! Can we also have a new CI test added for this? @cymbalrush @YifanShenSZ can you also have a look? |
Sure, what kind of test are you envisioning? Can you point me towards an example? |
Basically I'm looking to automate the test you describe in this PR: "Converted a model and made sure it worked with a custom pipeline. Also ensured via print statements that the passes were translated correctly." You can see examples of CoreML tests for compile-spec based features:
There's usually an AOT portion to the test (making sure graph looks as expected), and a runtime component of the test. |
I do think those tests are a little different, as they are mostly testing the partitioner. I can add a test for translating a list of strings into a CompileSpec and back again if you want, but as far as what happens under the hood of |
I understand that the pass applies on the MLModel, but how do you know the pass you provide to the compile spec is actually being applied? Do you see a way to test this? Once simple test might be to grep the output of the to_edge_lower_and_transform and look for something like "Applying user passes" if Core ML logs something like that. Another possibility is to extract the mlmodel from the pte and inspect it has been transformed as you expect from the pass. Perhaps you could tell me more about the custom pass you're applying and what it does to help brainstorm test ideas? |
One way to tell is that coremltools will output the following log when specifying a user pipeline: but inspecting the mlmodel to make sure that e.g. op fusion was not performed is a whole other can of worms. The pipeline I tested with is: The reason that I am using this pipeline is that models exported with the default pipeline produce wildly different results on iPhone 13s vs iPhone 15s. |
Sounds good. I guess this PR is OK. If possible, let's have @YifanShenSZ from Apple weigh in. |
Summary
Adds the ability to specify a set of CoreML passes as a CompileSpec, allowing additional customization of the model compilation.
Test plan
Converted a model and made sure it worked with a custom pipeline. Also ensured via print statements that the passes were translated correctly.