KEMBAR78
Add README for torch._inductor.runtime by ezyang · Pull Request #141492 · pytorch/pytorch · GitHub
Skip to content

Conversation

@ezyang
Copy link
Contributor

@ezyang ezyang commented Nov 25, 2024

[ghstack-poisoned]
@pytorch-bot
Copy link

pytorch-bot bot commented Nov 25, 2024

🔗 Helpful Links

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

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

✅ You can merge normally! (2 Unrelated Failures)

As of commit 35e86f1 with merge base 4c1f50a (image):

BROKEN TRUNK - The following job failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

UNSTABLE - The following job failed but was likely due to flakiness present on trunk and has been marked as unstable:

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

Comment on lines 3 to 19
There's not really a coherent concept for this folder; in general it contains
code for:

1. Out-of-process Triton compilation (e.g., when doing multiprocess parallel
Triton compile)

2. Code that is accessed by the code we generated in Inductor codegen (the
"runtime", although not really a true runtime because we don't actually run
this code when running, it's what the Triton compilation uses).

It isn't really a true runtime (aka, code that needs to be invoked when
actually running Inductor compiled kernels).

One of the original motivations for this directory split was so that the
subprocesses could access Triton and our compiler support code without having
to import torch. However, we never actually go this to work, so there are
still plenty of torch imports in this folder.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
There's not really a coherent concept for this folder; in general it contains
code for:
1. Out-of-process Triton compilation (e.g., when doing multiprocess parallel
Triton compile)
2. Code that is accessed by the code we generated in Inductor codegen (the
"runtime", although not really a true runtime because we don't actually run
this code when running, it's what the Triton compilation uses).
It isn't really a true runtime (aka, code that needs to be invoked when
actually running Inductor compiled kernels).
One of the original motivations for this directory split was so that the
subprocesses could access Triton and our compiler support code without having
to import torch. However, we never actually go this to work, so there are
still plenty of torch imports in this folder.
This folder contains code needed at runtime by the output code of TorchInductor. The output code of TorchInductor will import `torch` and `torch._inductor.runtime`, but should not import from other files in `torch._inductor.*`.
Runtime includes Triton/C++ compiles, which are compiled (sometimes in parallel) when the output code of TorchInductor is imported. It also includes the autotuning code and heuristics to decide block sizes of generated code.
One of the original motivations for this directory split was so that the Triton compile
subprocesses could access Triton and our compiler support code while mocking out most of `torch`, which can take seconds to import (sometimes more than a Triton compile itself). An abandoned prototype of this can be found [here](https://github.com/pytorch/pytorch/pull/124682/files).
  1. This directory does contain the code needed to run Inductor compiled kernels/code. In that sense I think it is a true runtime and I think this directory structure makes sense even without the MockTorch stuff landing.

  2. Not importing torch is not a requirement of the prototype in [inductor] Add thread+subproc-based worker_start_method #124682 -- triton imports torch, so that requirement is clearly not attainable. Instead, the prototype mocks out torch by doing:

sys.modules["torch"] = MockTorch()

with some trickery to allow only files inside torch to be imported.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I took this suggestion and reworded a little bit of it

[ghstack-poisoned]
ezyang added a commit that referenced this pull request Nov 25, 2024
Signed-off-by: Edward Z. Yang <ezyang@meta.com>

ghstack-source-id: 98af2af
Pull Request resolved: #141492
@ezyang
Copy link
Contributor Author

ezyang commented Nov 26, 2024

@pytorchbot merge -f "unrelated failures"

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use -f as last resort and instead consider -i/--ignore-current to continue the merge ignoring current failures. This will allow currently pending tests to finish and report signal before the merge.

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

pytorchmergebot pushed a commit that referenced this pull request Nov 27, 2024
Do code review with whitespace changes off. Check comments for what I changed.

Signed-off-by: Edward Z. Yang <ezyang@meta.com>

Pull Request resolved: #141574
Approved by: https://github.com/bobrenjc93, https://github.com/jansel
ghstack dependencies: #141491, #141492
pytorchmergebot pushed a commit that referenced this pull request Nov 27, 2024
Signed-off-by: Edward Z. Yang <ezyang@meta.com>

Pull Request resolved: #141654
Approved by: https://github.com/aorenste, https://github.com/jansel
ghstack dependencies: #141491, #141492, #141574
pobin6 pushed a commit to pobin6/pytorch that referenced this pull request Dec 5, 2024
Signed-off-by: Edward Z. Yang <ezyang@meta.com>

Pull Request resolved: pytorch#141492
Approved by: https://github.com/jansel
ghstack dependencies: pytorch#141491
pobin6 pushed a commit to pobin6/pytorch that referenced this pull request Dec 5, 2024
Do code review with whitespace changes off. Check comments for what I changed.

Signed-off-by: Edward Z. Yang <ezyang@meta.com>

Pull Request resolved: pytorch#141574
Approved by: https://github.com/bobrenjc93, https://github.com/jansel
ghstack dependencies: pytorch#141491, pytorch#141492
pobin6 pushed a commit to pobin6/pytorch that referenced this pull request Dec 5, 2024
Signed-off-by: Edward Z. Yang <ezyang@meta.com>

Pull Request resolved: pytorch#141654
Approved by: https://github.com/aorenste, https://github.com/jansel
ghstack dependencies: pytorch#141491, pytorch#141492, pytorch#141574
@github-actions github-actions bot deleted the gh/ezyang/3014/head branch December 27, 2024 02:06
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.

3 participants