Skip to content

feat: Add support for TorchTensorRTModule in Dynamo [1 / x] #2003

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 3 commits into from
Jul 7, 2023

Conversation

gs-olive
Copy link
Collaborator

@gs-olive gs-olive commented Jun 8, 2023

Description

  • Rename TRTModuleNext to TorchTensorRTModule across the repository, and move the source directory to dynamo
  • Update imports across the repository
  • Refactor convert_module code to support conversion to a TorchTensorRTModule
  • Add tests for TorchTensorRTModule functionality in Dynamo

Fixes #2019

Type of change

  • 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
  • [ x ] I have added tests to verify my fix or my feature
  • [ 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 the component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths label Jun 8, 2023
@gs-olive gs-olive requested a review from narendasan June 8, 2023 19:58
@gs-olive gs-olive self-assigned this Jun 8, 2023
@github-actions github-actions bot added component: api [Python] Issues re: Python API component: fx component: tests Issues re: Tests labels Jun 8, 2023
@github-actions github-actions bot requested a review from yinghai June 8, 2023 19:58
@gs-olive gs-olive removed the request for review from yinghai June 8, 2023 19: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 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_compile_trt_module_next branch from 7df445e to 8ec3f01 Compare June 8, 2023 21:07
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_compile_trt_module_next branch from 8ec3f01 to 76a85d9 Compare June 8, 2023 21: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 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_compile_trt_module_next branch from 76a85d9 to 08e9d5a Compare June 8, 2023 22:05
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 requested a review from narendasan June 13, 2023 21:09
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

@narendasan narendasan changed the base branch from dynamo_compile_interpreter_update to main June 13, 2023 21:13
@gs-olive gs-olive force-pushed the dynamo_compile_trt_module_next branch from e9ec251 to 487ba93 Compare June 28, 2023 02: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_compile_trt_module_next branch from 487ba93 to 49cd3a6 Compare June 28, 2023 21:45
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_compile_trt_module_next branch from 49cd3a6 to e2594b6 Compare June 29, 2023 00:47
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

Comment on lines +74 to +76
use_python_runtime: Whether to strictly use Python runtime or C++ runtime. To auto-select a runtime
based on C++ dependency presence (preferentially choosing C++ runtime if available), leave the
argument as None
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added a new compilation argument called use_python_runtime to replace use_experimental_rt and use_experimental_fx_rt. This new compilation argument has three potential settings/implications:

  • True: Strictly use Python runtime
  • False: Strictly use C++ runtime
  • None [DEFAULT]: Automatically detect presence of C++ dependency and select C++ runtime if available, else default to Python runtime

@gs-olive gs-olive force-pushed the dynamo_compile_trt_module_next branch from 7247ce7 to f31e528 Compare July 5, 2023 22:48
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

@gs-olive gs-olive force-pushed the dynamo_compile_trt_module_next branch from de669eb to c0f0a22 Compare July 6, 2023 22:49
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

Comment on lines +34 to +35
"optimization_level": 1,
"min_block_size": 8,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Decreased optimization level (from 3 to 1) and increased block size (from 5 to 8) to improve compilation times and reduce segmentation in models, pending upcoming converter implementations.

gs-olive added 3 commits July 6, 2023 17:29
- Rename `TRTModuleNext` to `TorchTensorRTModule` across the repository,
and move the source directory to `dynamo`
- Update imports across the repository
- Refactor `convert_module` code to support conversion to a
`TorchTensorRTModule`
- Add logging information about which runtime is being used in Dynamo
compile
- Add tests for `TorchTensorRTModule` functionality in Dynamo
- Default automatically to test for presence of C++ dependency and use
appropriate runtime if not specified by the user
- Improve test timing for TRT Backend testing, which now utilizes C++
runtime
@gs-olive gs-olive force-pushed the dynamo_compile_trt_module_next branch from c0f0a22 to 1756b12 Compare July 7, 2023 00:29
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 b5dbc11 into main Jul 7, 2023
# for free to join this conversation on GitHub. Already have an account? # 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 fx
Projects
None yet
Development

Successfully merging this pull request may close these issues.

✨[Feature] Toggle usage of TRTModuleNext based on C++ availability
3 participants