Skip to content

[Inductor max autotune] Multithreaded Precompilation - #119386

Closed
kadeng wants to merge 2 commits into
gh/kadeng/26/basefrom
gh/kadeng/26/head
Closed

kadeng wants to merge 2 commits into
gh/kadeng/26/basefrom
gh/kadeng/26/head

Conversation

@kadeng

@kadeng kadeng commented Feb 7, 2024 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

When using the Cutlass backend, the compilation
of CUDA source files can totally dominate the runtime required for the benchmarking done
as part of Autotuning.

This change adds a multithreaded precompilation phase, which serves to pre-populate the compilation cache ( both in-memory, and a
possible on-disk sccache ).

Also it ensures that no unneccessary compilation
and benchmarking steps are performed, which was peviously the case.

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

When using the Cutlass backend, the compilation
of CUDA source files can totally dominate the runtime required for the benchmarking done
as part of Autotuning.

This change adds a multithreaded precompilation phase, which serves to pre-populate the compilation cache ( both in-memory, and a
possible on-disk sccache ).

Also it ensures that no unneccessary compilation
and benchmarking steps are performed, which was peviously the case.

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Feb 7, 2024 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ No Failures

As of commit b97e0ef with merge base 064610d (image):
💚 Looks good so far! There are no failures yet. 💚

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

@kadeng

kadeng commented Feb 7, 2024

Copy link
Copy Markdown
Contributor Author

This is a recreated already accepted PR #119003

@kadeng

kadeng commented Feb 7, 2024

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge

@pytorch-bot

pytorch-bot Bot commented Feb 7, 2024

Copy link
Copy Markdown

This PR needs to be approved by an authorized maintainer before merge.

@kadeng

kadeng commented Feb 7, 2024

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge

@pytorch-bot pytorch-bot Bot added the ciflow/trunk Trigger trunk jobs on your pull request label Feb 7, 2024
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge failed

Reason: This PR needs a release notes: label
If your changes are user facing and intended to be a part of release notes, please use a label starting with release notes:.

If not, please add the topic: not user facing label.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "topic: not user facing"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

Details for Dev Infra team Raised by workflow job

Comment thread torch/_inductor/autotune_process.py Outdated
def precompile(self):
# Prepopulate CUDACodeCache
# may happen in separate Threadpool
log.debug("Precompiling %s", str(self))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
log.debug("Precompiling %s", str(self))
log.debug("Precompiling %s", self)

should call str o self I think?

Comment thread torch/_inductor/autotune_process.py Outdated
# may happen in separate Threadpool
log.debug("Precompiling %s", str(self))
CUDACodeCache.load(self.source_code, "so")
log.debug("Done precompiling %s", str(self))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
log.debug("Done precompiling %s", str(self))
log.debug("Done precompiling %s", self)

Comment thread torch/_inductor/codecache.py Outdated
compile the graph and save it to the cache.
"""
from filelock import FileLock
from filelock import FileLock # type: ignore[import-not-found]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We just need to add types-filelock to our lintrunner install.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Opened a PR: #119390

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

thanks for the comments, I made some small corresponding changes..

@kadeng kadeng added the topic: not user facing topic category label Feb 7, 2024
pytorchmergebot pushed a commit that referenced this pull request Feb 7, 2024
pytorch-bot Bot pushed a commit that referenced this pull request Feb 8, 2024
When using the Cutlass backend, the compilation
of CUDA source files can totally dominate the runtime required for the benchmarking done
as part of Autotuning.

This change adds a multithreaded precompilation phase, which serves to pre-populate the compilation cache ( both in-memory, and a
possible on-disk sccache ).

Also it ensures that no unneccessary compilation
and benchmarking steps are performed, which was peviously the case.

cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx peterbell10 ipiszy yf225 chenyang78 muchulee8 aakhundov ColinPeppler

[ghstack-poisoned]
@kadeng

kadeng commented Feb 9, 2024

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge

@pytorchmergebot

Copy link
Copy Markdown
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

make_kernel_render: Callable[[CUDATemplateBuffer, Optional[List[IRNode]]], str],
bmreq: CUDABenchmarkRequest,
template: "CUDATemplate",
template: "CUDATemplate", # type: ignore[name-defined]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Huh, this type ignore shouldn't be necessary...

@kadeng kadeng Feb 9, 2024 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I add these type ignores only on linter errors when I run lintrunner locally. I also have the impression that these are a bit inconsistent, e.g. sometimes I had linter warnings about code that was just fine the day before. Most likely reason is that until a short time ago we had a separate lintrunner configuration for inductor.

clee2000 pushed a commit that referenced this pull request Feb 14, 2024
clee2000 pushed a commit that referenced this pull request Feb 14, 2024
When using the Cutlass backend, the compilation
of CUDA source files can totally dominate the runtime required for the benchmarking done
as part of Autotuning.

This change adds a multithreaded precompilation phase, which serves to pre-populate the compilation cache ( both in-memory, and a
possible on-disk sccache ).

Also it ensures that no unneccessary compilation
and benchmarking steps are performed, which was peviously the case.

Pull Request resolved: #119386
Approved by: https://github.com/aakhundov
@github-actions
github-actions Bot deleted the gh/kadeng/26/head branch March 11, 2024 01:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants