KEMBAR78
Modest code motion in compile_fx by ezyang · Pull Request #141574 · pytorch/pytorch · GitHub
Skip to content

Conversation

@ezyang
Copy link
Contributor

@ezyang ezyang commented Nov 26, 2024

[ghstack-poisoned]
@pytorch-bot
Copy link

pytorch-bot bot commented Nov 26, 2024

🔗 Helpful Links

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

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

✅ You can merge normally! (1 Unrelated Failure)

As of commit df08081 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

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

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

ghstack-source-id: 879c932
Pull Request resolved: #141574
NB: This function TAKES OWNERSHIP of the input ``model_`` and can potentially
mutate it! Make a copy if you need to preserve the original 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.

New docblock (and a few comments sprinkled here and there later)

model_,
example_inputs_,
recursive_compile_fx,
)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

All of these early short circuits (above, not shown due to whitespace changed ignored) have been hoisted out of the top level context managers here. The reasoning is that they immediately call back to compile_fx, and so therefore we don't have to set the context manager multiple times.


if isinstance(model_, GraphModule) and isinstance(
model_.graph._codegen, _PyTreeCodeGen
):
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 short circuit was nestled with recursive pre-grad passes conditional, I have hoisted it out and duplicated the condition

model: GraphModule,
example_inputs: List[InputType],
is_inference: bool,
) -> CompiledFxGraph:
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 inlined _fw_compiler_base into fw_compiler_base at the cost of one level of indentation (see autoformat fix below)


# TODO: can add logging before/after the call to create_aot_dispatcher_function
# in torch._functorch/aot_autograd.py::aot_module_simplified::aot_function_simplified::new_func
# once torchdynamo is merged into pytorch
Copy link
Contributor Author

Choose a reason for hiding this comment

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

torchdynamo is merged into pytorch so I assume this is obsolete

@ezyang ezyang added the topic: not user facing topic category label Nov 26, 2024
[ghstack-poisoned]
@ezyang
Copy link
Contributor Author

ezyang commented Nov 27, 2024

@pytorchbot merge

@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 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

@pytorchmergebot
Copy link
Collaborator

Merge failed

Reason: 1 jobs have failed, first few of them are: inductor / cuda12.1-py3.10-gcc9-sm86 / test (inductor_timm, 1, 2, linux.g5.4xlarge.nvidia.gpu)

Details for Dev Infra team Raised by workflow job

@ezyang
Copy link
Contributor Author

ezyang commented Nov 27, 2024

@pytorchbot merge

@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

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
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/3017/head branch December 28, 2024 02:03
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