Skip to content

Let custom_ops_aot_lib use portable_lib #4024

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

Closed
wants to merge 1 commit into from
Closed

Conversation

larryliu0820
Copy link
Contributor

@larryliu0820 larryliu0820 commented Jun 20, 2024

Summary:

Currently on Mac we can't import portable_lib then import sdpa_with_kv_cache. The reason is that they both statically link executorch_no_prim_ops.a and when they are both dlopen'd in python they are holding 2 copies of the static variables in executorch_no_prim_ops.a such as initialized.
Test Plan:
On Mac, make sure the pybind custom ops is able to import.

from executorch.extension.pybindings import portable_lib
from executorch.examples.models.llama2.custom_ops import sdpa_with_kv_cache
portable_lib._get_operator_names()
> ...
> llama::sdpa_with_kv_cache.out

Reviewers:

Subscribers:

Tasks:

Tags:

Copy link

pytorch-bot bot commented Jun 20, 2024

🔗 Helpful Links

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

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

✅ No Failures

As of commit d9652f7 with merge base 5e22836 (image):
💚 Looks good so far! There are no failures yet. 💚

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

@facebook-github-bot facebook-github-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 Jun 20, 2024
@larryliu0820 larryliu0820 marked this pull request as draft June 20, 2024 22:09
@larryliu0820 larryliu0820 changed the title Let custom_ops use shared executorch lib Let custom_ops_aot_lib use portable_lib Jun 21, 2024
@larryliu0820 larryliu0820 marked this pull request as ready for review June 21, 2024 18:30
@larryliu0820 larryliu0820 requested a review from dbort June 21, 2024 18:30
@facebook-github-bot
Copy link
Contributor

@larryliu0820 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Copy link
Contributor

@dbort dbort left a comment

Choose a reason for hiding this comment

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

Wow this really simplifies things at the top level! I'm glad this works; looks great.

Summary:
Currently on Mac we can't import portable_lib then import sdpa_with_kv_cache. The reason is that they both statically link `executorch_no_prim_ops.a` and when they are both dlopen'd in python they are holding 2 copies of the static variables in  `executorch_no_prim_ops.a` such as [initialized](https://github.com/pytorch/executorch/blob/main/runtime/platform/default/posix.cpp#L70).


Test Plan:
On Mac, make sure the pybind custom ops is able to import.
```
from executorch.extension.pybindings import portable_lib
from executorch.examples.models.llama2.custom_ops import sdpa_with_kv_cache
portable_lib._get_operator_names()
> ...
> llama::sdpa_with_kv_cache.out
```

Reviewed By: dbort

Differential Revision: D58883985

Pulled By: larryliu0820
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D58883985

@facebook-github-bot
Copy link
Contributor

@larryliu0820 merged this pull request in 398ce66.

facebook-github-bot pushed a commit that referenced this pull request Aug 13, 2024
Summary:
After #4024, sdpa is no longer in portable_lib by default, import separately.


Differential Revision: D61163753
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants