Skip to content

fix: Improve logging and kwarg passing in Dynamo #2052

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 1 commit into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions py/torch_tensorrt/dynamo/backend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
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.backend.utils import prepare_inputs, prepare_device
from torch_tensorrt.dynamo.backend.backends import torch_tensorrt_backend
from torch_tensorrt.dynamo.backend._defaults import (
Expand Down Expand Up @@ -62,6 +61,10 @@ def compile(

inputs = prepare_inputs(inputs, prepare_device(device))

if not isinstance(enabled_precisions, collections.abc.Collection):
enabled_precisions = [enabled_precisions]

# Parse user-specified enabled precisions
if (
torch.float16 in enabled_precisions
or torch_tensorrt.dtype.half in enabled_precisions
Expand Down Expand Up @@ -123,19 +126,12 @@ def create_backend(
Returns:
Backend for torch.compile
"""
if debug:
logger.setLevel(logging.DEBUG)

settings = CompilationSettings(
return partial(
torch_tensorrt_backend,
Comment on lines +129 to +130
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The default backend now takes kwargs instead of compilation settings.

debug=debug,
precision=precision,
workspace_size=workspace_size,
min_block_size=min_block_size,
torch_executed_ops=torch_executed_ops,
pass_through_build_failures=pass_through_build_failures,
)

return partial(
torch_tensorrt_backend,
settings=settings,
)
11 changes: 5 additions & 6 deletions py/torch_tensorrt/dynamo/backend/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,12 @@ def _pretraced_backend(
)
return trt_compiled
except:
logger.error(
"FX2TRT conversion failed on the subgraph. See trace above. "
+ "Returning GraphModule forward instead.",
exc_info=True,
)

if not settings.pass_through_build_failures:
logger.warning(
"TRT conversion failed on the subgraph. See trace above. "
+ "Returning GraphModule forward instead.",
exc_info=True,
)
return gm.forward
else:
raise AssertionError(
Expand Down