Skip to content

Add deprecation warning for to_edge + to_backend workflow in CoreMLPa…#17082

Merged
metascroy merged 7 commits into
pytorch:mainfrom
mohammed-saalim:coreml-deprecation-warning
Feb 6, 2026
Merged

Add deprecation warning for to_edge + to_backend workflow in CoreMLPa…#17082
metascroy merged 7 commits into
pytorch:mainfrom
mohammed-saalim:coreml-deprecation-warning

Conversation

@mohammed-saalim
Copy link
Copy Markdown
Contributor

@mohammed-saalim mohammed-saalim commented Feb 2, 2026

Fixes #15960
This PR adds a deprecation warning in the CoreMLPartitioner to guide users away from the deprecated to_edge() + to_backend() workflow and toward the recommended to_edge_transform_and_lower() flow.

Changes

  • Added _check_if_called_from_to_backend() method to detect deprecated workflow
  • Modified partition() to log warning when deprecated flow is detected
  • Added two unit tests to verify warning behavior

Pattern

Following the same pattern as #13209 (XNNPACK).

Related

This picks up the abandoned PR #15963.

cc @kimishpatel @YifanShenSZ @cymbalrush @metascroy

…rtitioner

Signed-off-by: mohammed-saalim <mohammed.saalim.k@gmail.com>
Copilot AI review requested due to automatic review settings February 2, 2026 00:53
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented Feb 2, 2026

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/17082

Note: Links to docs will display an error until the docs builds have been completed.

❌ 3 New Failures

As of commit adfe544 with merge base 62d6dc1 (image):

NEW FAILURES - The following jobs have failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla
Copy link
Copy Markdown

meta-cla Bot commented Feb 2, 2026

Hi @mohammed-saalim!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

Copy link
Copy Markdown
Contributor

Copilot AI left a 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 a deprecation warning in the CoreML partitioner to steer users away from the older to_edge() + to_backend() workflow toward to_edge_transform_and_lower(), matching the pattern already used for XNNPACK and adding tests to validate the behavior.

Changes:

  • Added _check_if_called_from_to_backend() to CoreMLPartitioner to detect when partition() is invoked via the deprecated to_backend path.
  • Updated CoreMLPartitioner.partition() to log a deprecation warning when the deprecated flow is detected, including context on performance implications and a docs link.
  • Added two unit tests that verify the warning is emitted for to_edge() + to_backend() and not emitted when using to_edge_transform_and_lower(), and wired them into the file’s __main__ block.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
backends/apple/coreml/partition/coreml_partitioner.py Adds stack-based detection of deprecated to_backend usage and emits a CoreML-specific deprecation warning while preserving existing partitioning behavior.
backends/apple/coreml/test/test_coreml_partitioner.py Introduces tests that capture the CoreML partitioner logger output to assert that the deprecation warning appears only for to_edge() + to_backend() and extends the manual test runner to invoke these tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread backends/apple/coreml/partition/coreml_partitioner.py Outdated
@mohammed-saalim
Copy link
Copy Markdown
Contributor Author

@pytorchbot label "release notes: none"

@pytorch-bot pytorch-bot Bot added the release notes: none Do not include this in the release notes label Feb 2, 2026
@meta-cla
Copy link
Copy Markdown

meta-cla Bot commented Feb 2, 2026

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 2, 2026
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 2, 2026 14:50
Copy link
Copy Markdown
Contributor

Copilot AI left a 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 2 out of 2 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@manuelcandales manuelcandales added the module: coreml Issues related to Apple's Core ML delegation and code under backends/apple/coreml/ label Feb 2, 2026
@mohammed-saalim
Copy link
Copy Markdown
Contributor Author

is there any update? @manuelcandales @metascroy

Copy link
Copy Markdown
Contributor

@metascroy metascroy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Let's see what CI says

Copilot AI review requested due to automatic review settings February 4, 2026 22:23
@pytorch-bot pytorch-bot Bot removed the ciflow/trunk label Feb 4, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a 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 2 out of 2 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mohammed-saalim
Copy link
Copy Markdown
Contributor Author

I fixed the linting issue @metascroy
Lemme know if something needs to be changed.

@metascroy
Copy link
Copy Markdown
Contributor

rerunning CI

@mohammed-saalim
Copy link
Copy Markdown
Contributor Author

can u pls re-run it. @metascroy
Thanks!

Copilot AI review requested due to automatic review settings February 5, 2026 15:06
Copy link
Copy Markdown
Contributor

Copilot AI left a 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 2 out of 2 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mohammed-saalim
Copy link
Copy Markdown
Contributor Author

Hi @metascroy,

The linting issues have been resolved with the latest commits:

  • Fixed trailing newline
  • Fixed UFMT formatting

The failing Samsung test jobs (test-samsung-models-linux and test-samsung-quantmodels-linux) are due to a missing SAMSUNG_AI_LITECORE_KEY secret in the CI configuration, which is unrelated to this PR.

The CoreML-related changes and tests are ready for review. Thanks!

@metascroy
Copy link
Copy Markdown
Contributor

Looks great! Just running some trunk jobs, and then I'll merge.

Thanks for the contribution!

@metascroy metascroy merged commit 6150522 into pytorch:main Feb 6, 2026
325 of 328 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. module: coreml Issues related to Apple's Core ML delegation and code under backends/apple/coreml/ release notes: none Do not include this in the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add warning when users use to_edge instead of to_edge_transform_and_lower with CoreML

5 participants