pytorch/torch/export
Tugsbayasgalan Manlaibaatar d7fe3c4123 [RELAND] Switch default behavoir of export IR to be predispatch (#125860)
This PR switches export IR from aot-dispatch to pre-dispatch IR.

**What is pre-dispatch IR and why should you care?**

Currently the default IR returned by torch.export can contain only functional ATen operators after ALL pytorch dispatcher decompositions (for example, CompositeImplicitAutograd) run.

In contrast, pre-dispatch IR refers to an IR that can contain all functional ATen operators (i.e., not just from the core subset), before any decomposition happens, as well as operators that manipulate autograd state. Pre-dispatch IR closely resembles eager PyTorch computation, but is still functional and serializable by torch.export. As a result:

You can train the pre-dispatch IR in eager mode as the IR contains necessary information for the autograd engine to automatically generate a backward graph.
You can write sound graph transformations more easily as the IR is functional.
Since it is an ATen IR, it is still normalized. For example, torch.add has multiple overloads, but aten.add.Tensor is unique in this IR.
If you want to get the core aten IR out of torch.export, you will need to:
```
ep = torch.export.export(M(), inputs)
ep_for_core_aten = ep.run_decompositions()
```

Differential Revision: [D57172986](https://our.internmc.facebook.com/intern/diff/D57172986)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/125860
Approved by: https://github.com/zhxchen17
2024-05-10 17:36:53 +00:00
..
__init__.py [RELAND] Switch default behavoir of export IR to be predispatch (#125860) 2024-05-10 17:36:53 +00:00
_remove_auto_functionalized_pass.py Refactored _remove_auto_functionalization_from_graph_helper (#125180) 2024-04-30 21:44:07 +00:00
_remove_effect_tokens_pass.py [export] Fix handling output in remove_effect_tokens_pass (#122357) 2024-03-22 03:35:59 +00:00
_safeguard.py [export] Update error message for set_grad (#121666) 2024-03-12 16:41:45 +00:00
_trace.py [export] handle constant aliasing for export (#125509) 2024-05-10 00:14:37 +00:00
_tree_utils.py [export] do not use tree_flatten_spec (#118608) 2024-01-30 19:14:04 +00:00
_unlift.py [export] Restore user input names to unlifted graph modules (#124765) 2024-04-29 20:58:17 +00:00
custom_obj.py [Export] Introduce class_fqn into CustomObjArgument (#118158) 2024-01-25 18:44:25 +00:00
dynamic_shapes.py dynamic shapes builder API (#124898) 2024-04-30 03:59:49 +00:00
exported_program.py Fix graph partitioner and make runtime assertion work with submodules in export (#125793) 2024-05-09 18:13:46 +00:00
graph_signature.py Make metadata serialization more strict (#124411) 2024-04-29 02:11:40 +00:00
unflatten.py [export] handle constant aliasing for export (#125509) 2024-05-10 00:14:37 +00:00