8000 codecache: Remove cpp_prefix.h duplication per build, then precompile it by benjaminglass1 · Pull Request #144293 · pytorch/pytorch · GitHub
[go: up one dir, main page]

Skip to content

codecache: Remove cpp_prefix.h duplication per build, then precompile it #144293

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

Conversation

benjaminglass1
Copy link
Collaborator
@benjaminglass1 benjaminglass1 commented Jan 7, 2025

Stack from ghstack (oldest at bottom):

Prior to this PR, _inductor/codegen/cpp_prefix.h was copied into a new temporary directory on every inductor run utilizing the CPP backend (i.e. CPU-only), then included in the output source code. Instead, this PR puts it in an appropriate place in the torch includes, and includes it from there. This allows us to precompile it in cpp_wrapper and AOT inductor mode, saving significant compilation time.

Due to difficulties getting this to work in FBCode, the precompilation itself is only enabled in OSS PyTorch.

cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @yf225 @chenyang78 @kadeng @muchulee8 @ColinPeppler @amjames @desertfire @chauhang @aakhundov

Differential Revision: D69420620

[ghstack-poisoned]
Copy link
pytorch-bot bot commented Jan 7, 2025

🔗 Helpful Links

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

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

✅ No Failures

As of commit 1fb5e56 with merge base fa85434 (image):
💚 Looks good so far! There are no failures yet. 💚

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

benjaminglass1 added a commit that referenced this pull request Jan 7, 2025
Prior to this PR, `_inductor/codegen/cpp_prefix.h` was copied into a new temporary directory on every inductor run utilizing the CPP backend, then included in the output source code. Instead, this puts it in an appropriate place in the torch includes, and includes it from there. This allows us to precompile it in cpp_wrapper and AOT inductor mode, saving significant compilation time.

Note for reviewers: I believe I've traced down all the implications of this change for FBCode here on the OSS side, but someone will need to run this through tests on the FB side to be sure.

ghstack-source-id: 78acea9
Pull Request resolved: #144293
@benjaminglass1 benjaminglass1 added the topic: not user facing topic category label Jan 7, 2025
[ghstack-poisoned]
benjaminglass1 added a commit that referenced this pull request Jan 7, 2025
Prior to this PR, `_inductor/codegen/cpp_prefix.h` was copied into a new temporary directory on every inductor run utilizing the CPP backend, then included in the output source code. Instead, this puts it in an appropriate place in the torch includes, and includes it from there. This allows us to precompile it in cpp_wrapper and AOT inductor mode, saving significant compilation time.

Note for reviewers: I believe I've traced down all the implications of this change for FBCode here on the OSS side, but someone will need to run this through tests on the FB side to be sure.

ghstack-source-id: 91fa52d
Pull Request resolved: #144293
[ghstack-poisoned]
benjaminglass1 added a commit that referenced this pull request Jan 7, 2025
Prior to this PR, `_inductor/codegen/cpp_prefix.h` was copied into a new temporary directory on every inductor run utilizing the CPP backend, then included in the output source code. Instead, this puts it in an appropriate place in the torch includes, and includes it from there. This allows us to precompile it in cpp_wrapper and AOT inductor mode, saving significant compilation time.

Note for reviewers: I believe I've traced down all the implications of this change for FBCode here on the OSS side, but someone will need to run this through tests on the FB side to be sure.

ghstack-source-id: 754a728
Pull Request resolved: #144293
@benjaminglass1
Copy link
Collaborator Author

Additional note to reviewers: lintrunner insisted on reformatting cpp_prefix.h once I'd moved it. I apologize about the diff there; the only actual change is switching from #pragma once to include guards to avoid a warning when precompiling headers in GCC.

@benjaminglass1 benjaminglass1 self-assigned this Jan 7, 2025
@benjaminglass1 benjaminglass1 marked this pull request as ready for review January 7, 2025 16:26
@benjaminglass1 benjaminglass1 requested a review from a team as a code owner January 7, 2025 16:26
[ghstack-poisoned]
@benjaminglass1
Copy link
Collaborator Author

Additional note to reviewers: lintrunner insisted on reformatting cpp_prefix.h once I'd moved it. I apologize about the diff there; the only actual change is switching from #pragma once to include guards to avoid a warning when precompiling headers in GCC.

Per conversation in #143909, I'll be reverting this to #pragma once.

[ghstack-poisoned]
[ghst
8000
ack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
Divigroup-RAP pushed a commit to Divigroup-RAP/PYTORCH that referenced this pull request Apr 22, 2025
Prior to this PR, `_inductor/codegen/cpp_prefix.h` was copied into a new temporary directory on every inductor run utilizing the CPP backend, then included in the output source code. Instead, this puts it in an appropriate place in the torch includes, and includes it from there. This allows us to precompile it in cpp_wrapper and AOT inductor mode, saving significant compilation time.

Note for reviewers: I believe I've traced down all the implications of this change for FBCode here on the OSS side, but someone will need to run this through tests on the FB side to be sure.

ghstack-source-id: 4e417ce
Pull Request resolved: pytorch/pytorch#144293
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
@desertfire
Copy link
Contributor

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

[ghstack-poisoned]
[ghstack-poisoned]
@desertfire
Copy link
Contributor

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

[ghstack-poisoned]
[ghstack-poisoned]
@desertfire
Copy link
Contributor

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

1 similar comment
@desertfire
Copy link
Contributor

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

@desertfire
Copy link
Contributor

@pytorchbot merge

@pytorchmergebot
Copy link
Collaborator

Merge failed

Reason: This PR has internal changes and must be landed via Phabricator! Please try reimporting/rexporting the PR!

Details for Dev Infra team Raised by workflow job

@facebook-github-bot
Copy link
Contributor

@pytorchbot merge

(Initiating merge automatically since Phabricator Diff has merged)

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0