Skip to content

Commit f70574e

Browse files
authored
chore: Fix Logging in torch_compile path (#2238)
Signed-off-by: Dheeraj Peri <[email protected]>
1 parent e77e445 commit f70574e

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

py/torch_tensorrt/dynamo/backend/backends.py

+11
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@
2020
def torch_tensorrt_backend(
2121
gm: torch.fx.GraphModule, sample_inputs: Sequence[torch.Tensor], **kwargs: Any
2222
) -> torch.nn.Module:
23+
# Set log level at the top of compilation (torch_tensorrt.dynamo)
24+
if (
25+
(
26+
"options" in kwargs
27+
and "debug" in kwargs["options"]
28+
and kwargs["options"]["debug"]
29+
)
30+
or ("debug" in kwargs and kwargs["debug"])
31+
) and logger.parent:
32+
logger.parent.setLevel(logging.DEBUG)
33+
2334
DEFAULT_BACKEND = aot_torch_tensorrt_aten_backend
2435

2536
compiled_mod: torch.nn.Module = DEFAULT_BACKEND(gm, sample_inputs, **kwargs)

py/torch_tensorrt/dynamo/compile.py

+3
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,9 @@ def compile_module(
197197

198198
submodule = getattr(partitioned_module, name)
199199

200+
logger.debug(
201+
"Submodule name: " + str(name) + " Graph: \n" + str(submodule.graph)
202+
)
200203
# Get submodule inputs
201204
submodule_inputs = partitioning.get_submod_inputs(
202205
partitioned_module, submodule, sample_inputs

py/torch_tensorrt/dynamo/utils.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,6 @@ def parse_dynamo_kwargs(kwargs: Any) -> CompilationSettings:
159159
valid_kwargs = {k: v for k, v in kwargs.items() if k in valid_attrs}
160160
settings = replace(settings, **valid_kwargs)
161161

162-
# Enable debug/verbose mode if requested
163-
if settings.debug:
164-
logger.setLevel(logging.DEBUG)
165-
166162
# TODO: Remove once Dynamo precisions refactoring is complete
167163
if "enabled_precisions" in kwargs:
168164
enabled_precisions = kwargs["enabled_precisions"]
@@ -188,7 +184,7 @@ def parse_dynamo_kwargs(kwargs: Any) -> CompilationSettings:
188184
# Parse input runtime specification
189185
settings.use_python_runtime = use_python_runtime_parser(settings.use_python_runtime)
190186

191-
logger.debug(f"Compiling with Settings:\n{settings}")
187+
logger.info("Compilation Settings: %s\n", settings)
192188

193189
return settings
194190

0 commit comments

Comments
 (0)