Skip to content
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

[export] Add run_decomposition() function to ExportedProgram #110236

Closed
wants to merge 1 commit into from

Conversation

angelayi
Copy link
Contributor

Summary:
https://docs.google.com/document/d/1QJJEGnj2nHGPODlw38BEG3KLLCOTfdOVjPrNQbz_LM8/edit#bookmark=id.lp80wfshq130

exported_program.run_decompositions(decomposition_table) will optionally take a decomposition table, and run decompositions on the exported program, returning a new exported program. By default we will run the Core ATen decomposition table.

Splitting up this diff with the following one (D49742989) to make migrating Executorch easier:

  1. Land this diff
  2. Wait for a pytorch nightly to include this diff
  3. Update executorch's pytorch nightly
  4. Land the following diff to have export() return no decomps

Test Plan: Tested in following diff

Differential Revision: D49743208

@pytorch-bot
Copy link

pytorch-bot bot commented Sep 28, 2023

🔗 Helpful Links

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

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

⏳ No Failures, 1 Pending

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

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

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D49743208

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D49743208


if len(new_range_constraints) > 0 or len(new_equality_constraints) > 0:
exported_program = exported_program._transform(
_AddRuntimeAssertionsForInlineConstraintsPass(
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need this?

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'm also not sure if this is 100% needed. If it's possible that some decomposed operator introduces an unbacked symint, then we will also need to add assertions for it 😅

new_range_constraints, new_equality_constraints
)
)
exported_program = lift_constant_tensor_pass(exported_program)
Copy link
Contributor

Choose a reason for hiding this comment

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

So basically anytime we run aot_export, we need to re-run lift_constant_tensor_pass and _ReplaceSymSizeOpPass()?

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'm not sure if this is 100% needed. Basically, if it's possible that some decomposed operator introduces a constant tensor, then we will need to lift it.

).run(core_aten_ep.graph_module.code)
self.assertTrue(torch.allclose(core_aten_ep(*inp), m(*inp)))

def test_export_decomps_dynamic(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

I am all for having more tests. Just a bit curious why dynamic shape affects run-decomposition.

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 just wanted to check that the dynamic shapes were preserved through aot export.

angelayi added a commit to angelayi/pytorch that referenced this pull request Sep 29, 2023
…#110236)

Summary:

https://docs.google.com/document/d/1QJJEGnj2nHGPODlw38BEG3KLLCOTfdOVjPrNQbz_LM8/edit#bookmark=id.lp80wfshq130

`exported_program.run_decompositions(decomposition_table)` will optionally take a decomposition table, and run decompositions on the exported program, returning a new exported program. By default we will run the Core ATen decomposition table.

Splitting up this diff with the following one (D49742989) to make migrating Executorch easier:
1. Land this diff
1. Wait for a pytorch nightly to include this diff
1. Update executorch's pytorch nightly pin
1. Land the following diff to have export() return no decomps + updates executorch code to use the run_decomps()

Test Plan: Tested in following diff

Differential Revision: D49743208
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D49743208

angelayi added a commit to angelayi/pytorch that referenced this pull request Sep 29, 2023
…#110236)

Summary:

https://docs.google.com/document/d/1QJJEGnj2nHGPODlw38BEG3KLLCOTfdOVjPrNQbz_LM8/edit#bookmark=id.lp80wfshq130

`exported_program.run_decompositions(decomposition_table)` will optionally take a decomposition table, and run decompositions on the exported program, returning a new exported program. By default we will run the Core ATen decomposition table.

Splitting up this diff with the following one (D49742989) to make migrating Executorch easier:
1. Land this diff
1. Wait for a pytorch nightly to include this diff
1. Update executorch's pytorch nightly pin
1. Land the following diff to have export() return no decomps + updates executorch code to use the run_decomps()

Test Plan: Tested in following diff

Differential Revision: D49743208
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D49743208

angelayi added a commit to angelayi/pytorch that referenced this pull request Sep 29, 2023
…#110236)

Summary:

https://docs.google.com/document/d/1QJJEGnj2nHGPODlw38BEG3KLLCOTfdOVjPrNQbz_LM8/edit#bookmark=id.lp80wfshq130

`exported_program.run_decompositions(decomposition_table)` will optionally take a decomposition table, and run decompositions on the exported program, returning a new exported program. By default we will run the Core ATen decomposition table.

Splitting up this diff with the following one (D49742989) to make migrating Executorch easier:
1. Land this diff
1. Wait for a pytorch nightly to include this diff
1. Update executorch's pytorch nightly pin
1. Land the following diff to have export() return no decomps + updates executorch code to use the run_decomps()

Test Plan: Tested in following diff

Reviewed By: tugsbayasgalan

Differential Revision: D49743208
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D49743208

…#110236)

Summary:

https://docs.google.com/document/d/1QJJEGnj2nHGPODlw38BEG3KLLCOTfdOVjPrNQbz_LM8/edit#bookmark=id.lp80wfshq130

`exported_program.run_decompositions(decomposition_table)` will optionally take a decomposition table, and run decompositions on the exported program, returning a new exported program. By default we will run the Core ATen decomposition table.

Splitting up this diff with the following one (D49742989) to make migrating Executorch easier:
1. Land this diff
1. Wait for a pytorch nightly to include this diff
1. Update executorch's pytorch nightly pin
1. Land the following diff to have export() return no decomps + updates executorch code to use the run_decomps()

Test Plan: Tested in following diff

Reviewed By: tugsbayasgalan

Differential Revision: D49743208
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D49743208

@facebook-github-bot
Copy link
Contributor

@pytorchbot merge

(Initiating merge automatically since Phabricator Diff has merged)

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Oct 1, 2023
@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
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants