Skip to content

Commit 861a684

Browse files
committed
Fixed the comments
1 parent 5683644 commit 861a684

File tree

6 files changed

+18
-14
lines changed

6 files changed

+18
-14
lines changed

py/torch_tensorrt/dynamo/_compiler.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ def cross_compile_for_windows(
6666
Set[Union[torch.dtype, dtype]], Tuple[Union[torch.dtype, dtype]]
6767
] = _defaults.ENABLED_PRECISIONS,
6868
engine_capability: EngineCapability = _defaults.ENGINE_CAPABILITY,
69-
debug: bool = False,
7069
num_avg_timing_iters: int = _defaults.NUM_AVG_TIMING_ITERS,
7170
workspace_size: int = _defaults.WORKSPACE_SIZE,
7271
dla_sram_size: int = _defaults.DLA_SRAM_SIZE,
@@ -187,7 +186,7 @@ def cross_compile_for_windows(
187186
f"Cross compile for windows is only supported on x86-64 Linux architecture, current platform: {platform.system()=}, {platform.architecture()[0]=}"
188187
)
189188

190-
if debug:
189+
if kwargs.get("debug", False):
191190
warnings.warn(
192191
"`debug` is deprecated. Please use `torch_tensorrt.dynamo.Debugger` to configure debugging options.",
193192
DeprecationWarning,
@@ -404,7 +403,6 @@ def compile(
404403
Set[Union[torch.dtype, dtype]], Tuple[Union[torch.dtype, dtype]]
405404
] = _defaults.ENABLED_PRECISIONS,
406405
engine_capability: EngineCapability = _defaults.ENGINE_CAPABILITY,
407-
debug: bool = False,
408406
num_avg_timing_iters: int = _defaults.NUM_AVG_TIMING_ITERS,
409407
workspace_size: int = _defaults.WORKSPACE_SIZE,
410408
dla_sram_size: int = _defaults.DLA_SRAM_SIZE,
@@ -523,7 +521,7 @@ def compile(
523521
torch.fx.GraphModule: Compiled FX Module, when run it will execute via TensorRT
524522
"""
525523

526-
if debug:
524+
if kwargs.get("debug", False):
527525
warnings.warn(
528526
"`debug` is deprecated. Please use `torch_tensorrt.dynamo.Debugger` for debugging functionality",
529527
DeprecationWarning,
@@ -946,7 +944,8 @@ def contains_metadata(gm: torch.fx.GraphModule) -> bool:
946944
trt_module.enable_profiling()
947945
else:
948946
path = os.path.join(
949-
_debugger_settings.logging_dir, "engine_visualization"
947+
_debugger_settings.logging_dir,
948+
"engine_visualization_profile",
950949
)
951950
os.makedirs(path, exist_ok=True)
952951
trt_module.enable_profiling(
@@ -990,7 +989,6 @@ def convert_exported_program_to_serialized_trt_engine(
990989
enabled_precisions: (
991990
Set[torch.dtype | dtype] | Tuple[torch.dtype | dtype]
992991
) = _defaults.ENABLED_PRECISIONS,
993-
debug: bool = False,
994992
assume_dynamic_shape_support: bool = _defaults.ASSUME_DYNAMIC_SHAPE_SUPPORT,
995993
workspace_size: int = _defaults.WORKSPACE_SIZE,
996994
min_block_size: int = _defaults.MIN_BLOCK_SIZE,
@@ -1092,7 +1090,7 @@ def convert_exported_program_to_serialized_trt_engine(
10921090
Returns:
10931091
bytes: Serialized TensorRT engine, can either be saved to a file or deserialized via TensorRT APIs
10941092
"""
1095-
if debug:
1093+
if kwargs.get("debug", False):
10961094
warnings.warn(
10971095
"`debug` is deprecated. Please use `torch_tensorrt.dynamo.Debugger` to configure debugging options.",
10981096
DeprecationWarning,
@@ -1181,7 +1179,6 @@ def convert_exported_program_to_serialized_trt_engine(
11811179
compilation_options = {
11821180
"assume_dynamic_shape_support": assume_dynamic_shape_support,
11831181
"enabled_precisions": enabled_precisions,
1184-
"debug": debug,
11851182
"workspace_size": workspace_size,
11861183
"min_block_size": min_block_size,
11871184
"torch_executed_ops": torch_executed_ops,

py/torch_tensorrt/dynamo/_defaults.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
L2_LIMIT_FOR_TILING = -1
5050
USE_DISTRIBUTED_MODE_TRACE = False
5151
OFFLOAD_MODULE_TO_CPU = False
52+
DEBUG_LOGGING_DIR = os.path.join(tempfile.gettempdir(), "torch_tensorrt/debug_logs")
5253

5354

5455
def default_device() -> Device:

py/torch_tensorrt/dynamo/debug/_Debugger.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from unittest import mock
99

1010
import torch
11+
from torch_tensorrt.dynamo._defaults import DEBUG_LOGGING_DIR
1112
from torch_tensorrt.dynamo.debug._DebuggerConfig import DebuggerConfig
1213
from torch_tensorrt.dynamo.debug._supports_debugger import (
1314
_DEBUG_ENABLED_CLS,
@@ -32,7 +33,7 @@ def __init__(
3233
save_engine_profile: bool = False,
3334
profile_format: str = "perfetto",
3435
engine_builder_monitor: bool = True,
35-
logging_dir: str = tempfile.gettempdir(),
36+
logging_dir: str = DEBUG_LOGGING_DIR,
3637
save_layer_info: bool = False,
3738
):
3839
"""Initialize a debugger for TensorRT conversion.
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import tempfile
21
from dataclasses import dataclass
32

3+
from torch_tensorrt.dynamo._defaults import DEBUG_LOGGING_DIR
4+
45

56
@dataclass
67
class DebuggerConfig:
78
log_level: str = "debug"
89
save_engine_profile: bool = False
910
engine_builder_monitor: bool = True
10-
logging_dir: str = tempfile.gettempdir()
11+
logging_dir: str = DEBUG_LOGGING_DIR
1112
profile_format: str = "perfetto"
1213
save_layer_info: bool = False

tools/debug/engine_visualization/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ pip install git+https://github.com/NVIDIA/TensorRT.git#subdirectory=tools/experi
77
sudo apt --yes install graphviz
88
```
99

10+
## Usage
11+
The example usage can be found in `draw_engine_graph_example.py`. We use `torch_tensorrt.dynamo.debugger` to first output the engine profile info that required by TREX. Note that only when the compilation settings `use_python_runtime=False` can it produce TREX profiling. When it is saved to a folder, we call `draw_engine` on the same directory where the profile files are saved, which is in the subdirectory `engine_visualization_profile`.

tools/debug/engine_visualization/draw_engine_graph_example.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import torch
66
import torch_tensorrt as torch_tensorrt
77
import torchvision.models as models
8+
from torch_tensorrt.dynamo._defaults import DEBUG_LOGGING_DIR
89

910
inputs = [torch.rand((1, 3, 224, 224)).to("cuda")]
1011
model = models.resnet18(pretrained=False).eval().to("cuda")
@@ -14,12 +15,13 @@
1415
# min_block_size = 0
1516
use_python_runtime = False
1617
torch_executed_ops = {}
17-
logging_dir = "/home/profile"
18+
1819
with torch_tensorrt.dynamo.Debugger(
1920
"graphs",
20-
logging_dir=logging_dir,
21+
logging_dir=DEBUG_LOGGING_DIR,
2122
capture_fx_graph_after=["constant_fold"],
2223
save_engine_profile=True,
24+
profile_format="trex",
2325
):
2426
trt_gm = torch_tensorrt.dynamo.compile(
2527
exp_program,
@@ -32,5 +34,5 @@
3234

3335
from draw_engine_graph import draw_engine
3436

35-
draw_engine(os.path.join(logging_dir, "engine_visualization"))
37+
draw_engine(os.path.join(DEBUG_LOGGING_DIR, "engine_visualization_profile"))
3638
print()

0 commit comments

Comments
 (0)