Skip to content

Add top-level CMake kernels target #12806

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

Merged
merged 35 commits into from
Jul 29, 2025
Merged

Add top-level CMake kernels target #12806

merged 35 commits into from
Jul 29, 2025

Conversation

GregoryComer
Copy link
Member

@GregoryComer GregoryComer commented Jul 24, 2025

Add a top level kernels CMake target, which includes all configured kernel libraries. I validate this change by building a simple runner using the executorch_kernels target and verifying that it was able to build and run MobileNet v2, with and without selective build. Once the changes land in ExecuTorch, this will be long-term validated in executorch-examples CI.

There are a few follow-ups needed, which I will handle shortly. I still need to add merging logic for the YAML files to generate a single selective library that includes quantized and LLM ops, when configured to build them.

This is done in the context of top-level CMake targets, tracked in #12293.

GregoryComer and others added 10 commits July 21, 2025 14:38
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
@GregoryComer
Copy link
Member Author

GregoryComer commented Jul 24, 2025

Copy link

pytorch-bot bot commented Jul 24, 2025

🔗 Helpful Links

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

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

❌ 1 New Failure

As of commit 42c53a6 with merge base ce9da63 (image):

NEW FAILURE - The following job has failed:

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 Jul 24, 2025
GregoryComer added a commit that referenced this pull request Jul 24, 2025
ghstack-source-id: d4f48bb
ghstack-comment-id: 3111912326
Pull-Request: #12806
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
Comment on lines +279 to +282
check_conflicting_options_on(
IF_ON EXECUTORCH_SELECT_OPS_YAML CONFLICTS_WITH
EXECUTORCH_SELECT_OPS_LIST EXECUTORCH_SELECT_OPS_MODEL
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean in the future it should be composable. I'm OK with having this for now.

Copy link
Contributor

Choose a reason for hiding this comment

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

@GregoryComer Should this also check for a conflict with the OPS_FROM_MODEL API?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I see it there, later down.

Comment on lines +743 to +746
if(NOT EXECUTORCH_SELECT_OPS_YAML STREQUAL ""
OR NOT EXECUTORCH_SELECT_OPS_LIST STREQUAL ""
OR NOT EXECUTORCH_SELECT_OPS_MODEL STREQUAL ""
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for adding this!

@larryliu0820
Copy link
Contributor

@GregoryComer can you remove these options: https://github.com/pytorch/executorch/blob/main/examples/selective_build/CMakeLists.txt#L55 and let it use the ones you added

LIB_NAME
"executorch_selected_kernels"
KERNEL_LIBS
"portable_kernels"
Copy link
Contributor

@lucylq lucylq Jul 24, 2025

Choose a reason for hiding this comment

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

Thanks for adding this to top-level cmake!

So, executorch_selected_kernels is a selective build library for portable_kernels only it seems? If a user wants to selectively build on optimized or custom kernel libs, they should either:

  1. Update here (for test purposes, I guess).
  2. Follow the current flow and create their own selective build lib.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, as a follow-up, I intend to enable optimized (and portable_optimized) kernels. To enable selective build for other libraries (quantized ops, llm ops, etc.), I should just be able to use the merge_yaml functionality to generate a combined op yaml, right?

For user's custom op libs, I think they'll probably need to define their own targets, as we can't access their targets from here (unless we re-wrote as a macro/function, but we can look at that separately).

Backend op libs are another case that needs more thinking through, as well. But hopefully this should be a good starting point.

[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
Base automatically changed from gh/GregoryComer/82/head to main July 29, 2025 00:43
[ghstack-poisoned]
@GregoryComer GregoryComer added the release notes: none Do not include this in the release notes label Jul 29, 2025
@GregoryComer GregoryComer merged commit a70b7a8 into main Jul 29, 2025
112 of 113 checks passed
@GregoryComer GregoryComer deleted the gh/GregoryComer/89/head branch July 29, 2025 06:10
@GregoryComer
Copy link
Member Author

@GregoryComer can you remove these options: https://github.com/pytorch/executorch/blob/main/examples/selective_build/CMakeLists.txt#L55 and let it use the ones you added

I've created a follow-up task to track this: #12948. Will do this shortly.

@GregoryComer GregoryComer added the release notes: build Changes related to build, including dependency upgrades, build flags, optimizations, etc. label Jul 29, 2025
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. release notes: build Changes related to build, including dependency upgrades, build flags, optimizations, etc. release notes: none Do not include this in the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants