Skip to content

chore/fix: Restructure Dynamo directory [7 / x] #1981

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

Closed
wants to merge 1 commit into from

Conversation

gs-olive
Copy link
Collaborator

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

Description

  • Add common directory which stores code common to both the compile and export path, to reduce code duplication and better organize the repository
  • Update necessary imports, fix minor argument pass-through issues in fx_ts_compat
  • Update defaults in fx_ts_compat to agree with those in compile

Type of change

Please delete options that are not relevant and/or add your own.

  • Chore: restructuring folders, reducing code duplication

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 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 Story: Dynamo Compile Improvements Issues relating to improvement of the Dynamo compile path labels Jun 5, 2023
@gs-olive gs-olive requested a review from narendasan June 5, 2023 17:05
@gs-olive gs-olive self-assigned this Jun 5, 2023
@github-actions github-actions bot added the component: api [Python] Issues re: Python API label Jun 5, 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 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 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

@gs-olive gs-olive requested a review from peri044 June 5, 2023 17: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_general_purpose_acceleration branch from a3dd0c8 to 2003b07 Compare June 5, 2023 17:21
@gs-olive gs-olive force-pushed the dynamo_folder_refactoring branch from 5024e4a to 4ed3e3f Compare June 5, 2023 17:21
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_folder_refactoring branch from 4ed3e3f to d48d5c1 Compare June 5, 2023 18:30
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_folder_refactoring branch from d48d5c1 to ea64529 Compare June 5, 2023 20: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 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

@@ -8,10 +8,10 @@
from torch_tensorrt import EngineCapability, Device
from torch_tensorrt.fx.utils import LowerPrecision

from torch_tensorrt.dynamo.backend._settings import CompilationSettings
from torch_tensorrt.dynamo.common import CompilationSettings
Copy link
Collaborator

Choose a reason for hiding this comment

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

do you think its worth having dynamo.common.CompilationSettings vs just dynamo.CompilationSettings?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it would be better as dynamo.common.CompilationSettings until both compile and export use them, since dynamo.CompilationSettings might imply it is used across dynamo, whereas common could just be general purpose utilities.

from torch_tensorrt.dynamo.backend.utils import prepare_inputs, prepare_device
from torch_tensorrt.dynamo.backend.backends import torch_tensorrt_backend
from torch_tensorrt.dynamo.backend._defaults import (
from torch_tensorrt.dynamo.common._defaults import (
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here

Copy link
Collaborator Author

@gs-olive gs-olive Jun 7, 2023

Choose a reason for hiding this comment

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

This one, I am more open to moving up a level since the necessary changes have been made to both compile and export. I could add from torch_tensorrt.dynamo.common import _defaults to the torch_tensorrt.dynamo.__init__.py

@gs-olive gs-olive force-pushed the dynamo_general_purpose_acceleration branch from 2003b07 to 9e805d1 Compare June 8, 2023 20:14
@gs-olive gs-olive force-pushed the dynamo_folder_refactoring branch from ea64529 to ece13a7 Compare June 8, 2023 20:17
@gs-olive gs-olive requested a review from narendasan June 8, 2023 20:17
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 dynamo_compile_trt_module_next to main June 28, 2023 02:50
Comment on lines 143 to 150
use_experimental_rt=use_experimental_rt,
max_aux_streams=max_aux_streams,
version_compatible=version_compatible,
optimization_level=optimization_level,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Similar fixes in #1997 - to rebase after merge.

@gs-olive gs-olive force-pushed the dynamo_folder_refactoring branch from f851dd0 to c62f30b Compare June 28, 2023 03:54
@gs-olive gs-olive changed the base branch from main to dynamo_compile_trt_module_next June 28, 2023 03:54
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_folder_refactoring branch from c62f30b to fc85356 Compare June 28, 2023 04:54
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 487ba93 to 49cd3a6 Compare June 28, 2023 21:45
@gs-olive gs-olive force-pushed the dynamo_folder_refactoring branch from fc85356 to d2fcab0 Compare June 28, 2023 21: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

@gs-olive gs-olive force-pushed the dynamo_compile_trt_module_next branch from 49cd3a6 to e2594b6 Compare June 29, 2023 00:47
@gs-olive gs-olive force-pushed the dynamo_folder_refactoring branch from d2fcab0 to 369f442 Compare June 29, 2023 00: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

@gs-olive gs-olive force-pushed the dynamo_compile_trt_module_next branch 3 times, most recently from c0f0a22 to 1756b12 Compare July 7, 2023 00:29
@gs-olive gs-olive changed the base branch from dynamo_compile_trt_module_next to main July 7, 2023 22:15
@gs-olive gs-olive force-pushed the dynamo_folder_refactoring branch from 369f442 to 43b18c8 Compare July 7, 2023 22:20
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.

There are some changes that do not conform to Python style guidelines:

--- py/torch_tensorrt/dynamo/fx_ts_compat/lower.py	2023-07-07 22:21:04.022422 +0000
+++ py/torch_tensorrt/dynamo/fx_ts_compat/lower.py	2023-07-07 22:21:19.929000 +0000
@@ -8,11 +8,15 @@
import torch.fx as fx
import torch.nn as nn
import torch_tensorrt.fx.tracer.dispatch_tracer.aten_tracer as aten_tracer
from torch.fx.passes.splitter_base import SplitResult

-from torch_tensorrt.dynamo.common import TRTInterpreter, TRTInterpreterResult, use_python_runtime_parser
+from torch_tensorrt.dynamo.common import (
+    TRTInterpreter,
+    TRTInterpreterResult,
+    use_python_runtime_parser,
+)
from .lower_setting import LowerSetting
from .passes.lower_pass_manager_builder import LowerPassManagerBuilder
from .passes.pass_utils import PassFunc, validate_inference
from torch_tensorrt.fx.tools.timing_cache_utils import TimingCacheManager
from torch_tensorrt.fx.tools.trt_splitter import TRTSplitter, TRTSplitterSetting

- Add `common` directory which stores code common to both the compile
and export path, to reduce code duplication and better organize the
repository
- Update necessary imports, promote the `_defaults` module to
`torch_tensorrt.dynamo._defaults`
@gs-olive gs-olive force-pushed the dynamo_folder_refactoring branch from 43b18c8 to db3523a Compare July 7, 2023 22:27
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
Copy link
Collaborator Author

Closed in favor of unified restructuring PR.

@gs-olive gs-olive closed this Jul 12, 2023
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: Dynamo Compile Improvements Issues relating to improvement of the Dynamo compile path 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.

3 participants