Skip to content
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

Optionally move setup.py/pip cmake-out to repo_root/cmake-out #7720

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

swolchok
Copy link
Contributor

Our setup.py/pip runs currently do CMake builds under the setup.py build_temp directory, which results in the build directory pip-out/temp.something/cmake-out. This does not share built artifacts with any of the other things that might do a CMake build, such as CI scripts, developers focused on C++, or users following the directions for an example or backend. I am not aware of any particular cost to just using the same cmake-out directory as everything else (please chime in if you are aware!) and there's a clear benefit, so let's try this?

[ghstack-poisoned]
@swolchok
Copy link
Contributor Author

swolchok commented Jan 17, 2025

Stack from ghstack (oldest at bottom):

Copy link

pytorch-bot bot commented Jan 17, 2025

🔗 Helpful Links

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

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

❌ 1 New Failure

As of commit 1071d8e with merge base 57a09f4 (image):

NEW FAILURE - The following job has failed:

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

swolchok added a commit that referenced this pull request Jan 17, 2025
Our setup.py/pip runs currently do CMake builds under the setup.py build_temp directory, which results in the build directory pip-out/temp.something/cmake-out. This does not share built artifacts with any of the other things that might do a CMake build, such as CI scripts, developers focused on C++, or users following the directions for an example or backend. I am not aware of any particular cost to just using the same cmake-out directory as everything else (please chime in if you are aware!) and there's a clear benefit, so let's try this?

ghstack-source-id: 5a46e016a9f420fa3c9dd455c4342d6ed0a41285
ghstack-comment-id: 2597548020
Pull Request resolved: #7720
@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 Jan 17, 2025
@zingo zingo requested review from Erik-Lundell and removed request for Erik-Lundell January 17, 2025 10:39
@zingo
Copy link
Collaborator

zingo commented Jan 17, 2025

Note: CI seems bad, No PULL jobs had been running
https://hud.pytorch.org/pr/pytorch/executorch/7720

@swolchok swolchok added the release notes: build Changes related to build, including dependency upgrades, build flags, optimizations, etc. label Jan 17, 2025
@swolchok
Copy link
Contributor Author

Note: CI seems bad, No PULL jobs had been running https://hud.pytorch.org/pr/pytorch/executorch/7720

looks like they quit running yesterday: https://hud.pytorch.org/hud/pytorch/executorch/main/1?per_page=50&name_filter=pull&mergeLF=true

[ghstack-poisoned]
swolchok added a commit that referenced this pull request Jan 17, 2025
Our setup.py/pip runs currently do CMake builds under the setup.py build_temp directory, which results in the build directory pip-out/temp.something/cmake-out. This does not share built artifacts with any of the other things that might do a CMake build, such as CI scripts, developers focused on C++, or users following the directions for an example or backend. I am not aware of any particular cost to just using the same cmake-out directory as everything else (please chime in if you are aware!) and there's a clear benefit, so let's try this?

ghstack-source-id: b5a35882ec38cc6512e68947beb5c6a5d9395c15
ghstack-comment-id: 2597548020
Pull Request resolved: #7720
@swolchok swolchok requested review from dbort, larryliu0820 and mergennachin and removed request for dbort January 17, 2025 20:30
@swolchok
Copy link
Contributor Author

test-llava-runner-linux finished in 50 minutes on this PR, whereas typical times in main are around 1-1.1 hours. Promising, though we should confirm on main once this ships.

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.

I separated these intentionally to keep the pip build hermetic. setup.py sets specific build flags to create the prebuilt artifacts that go into the wheel. Users might significantly change the set of cmake flags for their core cmake-out build, including doing cross-compilation or disabling things like pybindings (which would break assumptions in the pip artifacts).

I could see some cases where it might be helpful to share these two directories, but I see a bunch of cases where they really shouldn't be shared.

@swolchok
Copy link
Contributor Author

setup.py sets specific build flags to create the prebuilt artifacts that go into the wheel. Users might significantly change the set of cmake flags for their core cmake-out build, including doing cross-compilation or disabling things like pybindings (which would break assumptions in the pip artifacts).

setup.py deletes the CMake cache and reruns CMake always. I don't see how the user doing other stuff in that directory could cause problems given that behavior. @dbort can you elaborate?

@swolchok swolchok requested a review from dbort January 21, 2025 17:17
@dbort
Copy link
Contributor

dbort commented Jan 22, 2025

Partly it's out of paranoia, knowing how hard it is to keep make-based systems coherent. Even though the cache file is deleted, I think it might re-use artifacts between builds? And if that's true, then it might try to re-use a cross-compiled artifact.

If you've played around with this new setup and it seems bulletproof to you then go for it. But I was trading off time-to-rebuild as a worthwhile cost for avoiding painful debugging sessions when accidentally using incorrect artifacts.

@swolchok
Copy link
Contributor Author

make-based systems

I'll try switching back and forth between Android and host while letting CMake default to make. FWIW I recommend -G Ninja.

@dbort
Copy link
Contributor

dbort commented Jan 22, 2025

Ninja is great but we currently still need to support make; at least, all of our docs tell people to use make.

@swolchok
Copy link
Contributor Author

we should change the docs :)

@swolchok swolchok changed the title Move setup.py/pip cmake-out to repo_root/cmake-out Optionally move setup.py/pip cmake-out to repo_root/cmake-out Jan 28, 2025
@swolchok
Copy link
Contributor Author

swolchok commented Jan 28, 2025

changing this to be optional, so that only people (and CI jobs, where the pip build happens first!) that have opted in take the risk of painful debugging sessions.

@swolchok
Copy link
Contributor Author

changing this to be optional, so that only people (and CI jobs,

hmm, affected CI jobs just shouldn't be double-building ExecuTorch. need to think about this more.

@swolchok swolchok marked this pull request as draft January 28, 2025 22:47
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants