Skip to content

fix/feat: Add Dynamo-only converter registry #1944

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

Merged
merged 3 commits into from
Jul 21, 2023
Merged

Conversation

gs-olive
Copy link
Collaborator

@gs-olive gs-olive commented May 22, 2023

Description

  • Add Dynamo converter registry which functions as a superset of the standard FX converter registry

  • For use with new + experimental converters

  • Uses custom decorator dynamo_tensorrt_converter

  • Update references within Dynamo functions to use the converter registry DYNAMO_CONVERTERS

  • Add custom class overriding default Dictionary class to access converters from various registries

  • Add new dictionary type Dict[Target, Sequence[ConverterSupport]] as well as ConverterSupport class which stores a converter and its validation implementation

  • Add unified DYNAMO_CONVERTERS dictionary which coalesces both the FX and Dynamo converter dictionaries and acts as a single unified dictionary

Fixes #1942
Fixes #2071

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist:

  • [ x ] My code follows the style guidelines of this project (You can use the linters)
  • [ x ] I have performed a self-review of my own code
  • [ x ] I have commented my code, particularly in hard-to-understand areas and hacks
  • [ x ] I have made corresponding changes to the documentation
  • [ - ] I have added tests to verify my fix or my feature
    • Validated with CI + Converter Testing
  • [ x ] New and existing unit tests pass locally with my changes
  • [ x ] I have added the relevant labels to my PR in so that relevant reviewers are notified

@gs-olive gs-olive added component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths Story: Export/Compile Unification Issues relating to unification of Dynamo compile/export paths labels May 22, 2023
@gs-olive gs-olive requested a review from apbose May 22, 2023 22:58
@gs-olive gs-olive self-assigned this May 22, 2023
@github-actions github-actions bot added the component: api [Python] Issues re: Python API label May 22, 2023
@github-actions github-actions bot requested a review from narendasan May 22, 2023 22:58
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to C++ style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to Python style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to C++ style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to Python style guidelines

Copy link
Collaborator

Choose a reason for hiding this comment

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

So this is the file where fx and dynamo converters are getting concatenated. The new converters could be registered using dynamo_tensorrt_converter, so wouldn't it be better to move the new converters to py/torch_tensorrt/dynamo instead of changing the existing converters in py/torch_tensorrt/fx from tensorrt_converter to dynamo_tensorrt_converter?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I agree - no existing converters will need to be moved for this PR. New converters can be placed in the py/torch_tensorrt/dynamo directory and decorated with the @dynamo_tensorrt_converter decorator. If they are to be included in FX as well, we can just switch out the decorator for @tensorrt_converter (and optionally move the converter to py/torch_tensorrt/fx)

@gs-olive gs-olive requested a review from apbose May 23, 2023 19:46
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to Python style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to C++ style guidelines

@gs-olive gs-olive force-pushed the dynamo_converter_registry branch from eece393 to 78b5826 Compare June 26, 2023 20:56
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to C++ style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to Python style guidelines

@gs-olive gs-olive force-pushed the dynamo_converter_registry branch from 78b5826 to 5125c00 Compare June 30, 2023 23:53
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to C++ style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to Python style guidelines

@gs-olive gs-olive force-pushed the dynamo_converter_registry branch from 5125c00 to eaeaa46 Compare June 30, 2023 23:55
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to C++ style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to Python style guidelines

@gs-olive gs-olive force-pushed the dynamo_converter_registry branch from eaeaa46 to 2893d3e Compare July 1, 2023 00:01
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to C++ style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to Python style guidelines

@gs-olive gs-olive force-pushed the dynamo_converter_registry branch from 2893d3e to 846ec17 Compare July 1, 2023 06:39
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to Python style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to Python style guidelines

@gs-olive gs-olive force-pushed the dynamo_converter_registry branch from 90e8b8d to 3057909 Compare July 14, 2023 21:47
@github-actions github-actions bot added the component: tests Issues re: Tests label Jul 14, 2023
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to Python style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to C++ style guidelines

@gs-olive gs-olive changed the base branch from main to dynamo_refactor July 14, 2023 21:48
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In the new structure, does the converter_registry.py file belong in conversion/ @peri044?

@gs-olive gs-olive force-pushed the dynamo_converter_registry branch from 3057909 to 8f518ab Compare July 14, 2023 21:55
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to Python style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to C++ style guidelines

@gs-olive gs-olive force-pushed the dynamo_converter_registry branch from 8f518ab to fe094db Compare July 14, 2023 22:26
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to C++ style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to Python style guidelines

@gs-olive gs-olive force-pushed the dynamo_converter_registry branch from fe094db to 5377e43 Compare July 19, 2023 06:00
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to C++ style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to Python style guidelines

@gs-olive gs-olive force-pushed the dynamo_converter_registry branch from 5377e43 to 170bcd6 Compare July 19, 2023 18:33
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to C++ style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to Python style guidelines

Copy link
Collaborator Author

@gs-olive gs-olive Jul 19, 2023

Choose a reason for hiding this comment

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

Sample implementation of a capability validator which disallows dynamic shapes. It could potentially also check the Dynamo config as an alternative way to verify no Dynamic shapes. This may be too restrictive, however, since static-only converters can still operate within Dynamic-enabled graphs, as long as their inputs are static/constant

Copy link
Collaborator

@narendasan narendasan left a comment

Choose a reason for hiding this comment

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

LGTM

Base automatically changed from dynamo_refactor to main July 20, 2023 17:16
gs-olive added 3 commits July 20, 2023 14:10
- Add Dynamo converter registry which functions as a superset of the
standard FX converter registry
- For use with new + experimental converters
- Uses custom decorator `dynamo_tensorrt_converter`
- Update references within Dynamo functions to use the converter
registry `DYNAMO_CONVERTERS`
- Add custom class overriding default Dictionary class to access
converters from various registries
- Add new dictionary type `Dict[Target, Sequence[ConverterSupport]]` as
well as ConverterSupport class which stores a converter and its
validation implementation
- Add unified `DYNAMO_CONVERTERS` dictionary which coalesces both the FX
and Dynamo converter dictionaries and acts as a single unified
dictionary
- Streamline dictionary accesses via get/contains accessors
- Add priority converter decorator enum to prioritize user-provided
converters and name argument checking "capability validation" to clarify
utility
- Add boilerplate `no_dynamic` converter capability validator for easy
use in specifying converters as not-able to handle dynamic shapes
- Add debug statements for converter registrations in both FX and Dynamo
- Print operator counts along with registry support message
@gs-olive gs-olive force-pushed the dynamo_converter_registry branch from 170bcd6 to 4d14ae8 Compare July 20, 2023 21:10
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to C++ style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to Python style guidelines

@gs-olive gs-olive merged commit 6920876 into main Jul 21, 2023
@gs-olive gs-olive deleted the dynamo_converter_registry branch July 21, 2023 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla signed component: api [Python] Issues re: Python API component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths component: fx component: tests Issues re: Tests Story: Export/Compile Unification Issues relating to unification of Dynamo compile/export paths
Projects
None yet
Development

Successfully merging this pull request may close these issues.

✨[Feature] Augment DYNAMO_CONVERTERS to handle node arg checking Add Dynamo-Only Converter Registry
4 participants