Skip to content

Conversation

[ghstack-poisoned]
@pytorch-bot
Copy link

pytorch-bot bot commented Nov 27, 2024

🔗 Helpful Links

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

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 197cc26 with merge base 4c1f50a (image):

UNSTABLE - The following jobs failed but were 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.

ezyang added a commit that referenced this pull request Nov 27, 2024
Signed-off-by: Edward Z. Yang <[email protected]>

ghstack-source-id: 3bcb4b1
Pull Request resolved: #141654
@ezyang ezyang added the topic: not user facing topic category label Nov 27, 2024
[ghstack-poisoned]
# python test/inductor/test_codecache.py
# TestFxGraphCache.test_constant_handling_device_cpu
# TODO: Why are we monkeypatching it......
import torch._inductor.output_code as output_code
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@masnesral you added the test in question, is there really no way to do it without monkeypatching?

Copy link
Contributor

Choose a reason for hiding this comment

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

I can get the testing I want more directly from another test in that same file: #141898

@@ -0,0 +1,179 @@
"""
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This stuff is new and explains the motivation for code motion

class OutputCode(Protocol):
def __call__(self, inputs: Sequence[Any]) -> Any:
...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Everything below is code movement only



def _typecheck_CompiledFxGraph(h: CompiledFxGraph) -> OutputCode:
return h
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Except this, this is new

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe put this in an if TYPE_CHECKING block along w/ a comment that it's just used to verify that CompiledFxGraph implements the OutputCode protocol.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, there's an interesting idea. I'll do it in follow up (there are a few other places I did this pattern too)

[ghstack-poisoned]
ezyang added a commit that referenced this pull request Nov 27, 2024
Signed-off-by: Edward Z. Yang <[email protected]>

ghstack-source-id: c5c09cb
Pull Request resolved: #141654
ezyang added a commit that referenced this pull request Nov 27, 2024
Signed-off-by: Edward Z. Yang <[email protected]>

ghstack-source-id: c5c09cb
Pull Request resolved: #141654
ezyang added a commit that referenced this pull request Nov 27, 2024
Signed-off-by: Edward Z. Yang <[email protected]>

ghstack-source-id: c5c09cb
Pull Request resolved: #141654
ezyang added a commit that referenced this pull request Nov 27, 2024
Signed-off-by: Edward Z. Yang <[email protected]>

ghstack-source-id: c5c09cb
Pull Request resolved: #141654
ezyang added a commit that referenced this pull request Nov 27, 2024
Signed-off-by: Edward Z. Yang <[email protected]>

ghstack-source-id: c5c09cb
Pull Request resolved: #141654
ezyang added a commit that referenced this pull request Nov 27, 2024
Signed-off-by: Edward Z. Yang <[email protected]>

ghstack-source-id: c5c09cb
Pull Request resolved: #141654
_StrideExprStr: TypeAlias = str


def has_frozen_params(gm: torch.fx.GraphModule) -> bool:
Copy link
Contributor

Choose a reason for hiding this comment

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

Why isn't this just a method on GraphModule?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It probably shouldn't live straight on GraphModule, because it's a very Inductor specific concept. But the real reason is I was just shoving code around lol.



def _typecheck_CompiledFxGraph(h: CompiledFxGraph) -> OutputCode:
return h
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe put this in an if TYPE_CHECKING block along w/ a comment that it's just used to verify that CompiledFxGraph implements the OutputCode protocol.

from .triton_bundler import TritonKernelArtifacts


class OutputCode(Protocol):
Copy link
Contributor

Choose a reason for hiding this comment

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

What's a protocol?

Copy link
Contributor

Choose a reason for hiding this comment

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

Structural subtyping (duck typing). You're basically saying "I take/return something that looks like this" without having to use inheritance to force the things to actually be related.

ezyang added a commit that referenced this pull request Nov 27, 2024
Signed-off-by: Edward Z. Yang <[email protected]>

ghstack-source-id: c5c09cb
Pull Request resolved: #141654
@ezyang
Copy link
Contributor Author

ezyang commented Nov 27, 2024

@pytorchbot merge -i

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Nov 27, 2024
@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged while ignoring the following 2 checks: inductor / cuda12.1-py3.10-gcc9-sm86 / test (inductor_timm, 1, 2, linux.g5.4xlarge.nvidia.gpu), inductor / cuda12.4-py3.10-gcc9-sm86 / test (inductor_timm, 1, 2, linux.g5.4xlarge.nvidia.gpu, unstable)

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

Esquains pushed a commit to Esquains/study1 that referenced this pull request Dec 15, 2024
Signed-off-by: Edward Z. Yang <[email protected]>

ghstack-source-id: c5c09cb
Pull Request resolved: pytorch/pytorch#141654
@github-actions github-actions bot deleted the gh/ezyang/3021/head branch January 2, 2025 02:04
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.

7 participants