@@ -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 ,
@@ -140,7 +139,6 @@ def cross_compile_for_windows(
140139 assume_dynamic_shape_support (bool): Setting this to true enables the converters work for both dynamic and static shapes. Default: False
141140 sparse_weights (bool): Enable sparsity for convolution and fully connected layers.
142141 enabled_precision (Set(Union(torch.dtype, torch_tensorrt.dtype))): The set of datatypes that TensorRT can use when selecting kernels
143- debug (bool): Enable debuggable engine
144142 capability (torch_tensorrt.EngineCapability): Restrict kernel selection to safe gpu kernels or safe dla kernels
145143 num_avg_timing_iters (int): Number of averaging timing iterations used to select kernels
146144 workspace_size (int): Maximum size of workspace given to TensorRT
@@ -187,9 +185,9 @@ def cross_compile_for_windows(
187185 f"Cross compile for windows is only supported on x86-64 Linux architecture, current platform: { platform .system ()= } , { platform .architecture ()[0 ]= } "
188186 )
189187
190- if debug :
188+ if kwargs . get ( " debug" , False ) :
191189 warnings .warn (
192- "`debug` is deprecated. Please use `torch_tensorrt.dynamo.Debugger` to configure debugging options ." ,
190+ "`debug` is deprecated. Please use `with torch_tensorrt.dynamo.Debugger(...) ` to wrap your compilation call to enable debugging functionality ." ,
193191 DeprecationWarning ,
194192 stacklevel = 2 ,
195193 )
@@ -404,7 +402,6 @@ def compile(
404402 Set [Union [torch .dtype , dtype ]], Tuple [Union [torch .dtype , dtype ]]
405403 ] = _defaults .ENABLED_PRECISIONS ,
406404 engine_capability : EngineCapability = _defaults .ENGINE_CAPABILITY ,
407- debug : bool = False ,
408405 num_avg_timing_iters : int = _defaults .NUM_AVG_TIMING_ITERS ,
409406 workspace_size : int = _defaults .WORKSPACE_SIZE ,
410407 dla_sram_size : int = _defaults .DLA_SRAM_SIZE ,
@@ -480,7 +477,6 @@ def compile(
480477 assume_dynamic_shape_support (bool): Setting this to true enables the converters work for both dynamic and static shapes. Default: False
481478 sparse_weights (bool): Enable sparsity for convolution and fully connected layers.
482479 enabled_precision (Set(Union(torch.dtype, torch_tensorrt.dtype))): The set of datatypes that TensorRT can use when selecting kernels
483- debug (bool): Enable debuggable engine
484480 capability (torch_tensorrt.EngineCapability): Restrict kernel selection to safe gpu kernels or safe dla kernels
485481 num_avg_timing_iters (int): Number of averaging timing iterations used to select kernels
486482 workspace_size (int): Maximum size of workspace given to TensorRT
@@ -523,9 +519,9 @@ def compile(
523519 torch.fx.GraphModule: Compiled FX Module, when run it will execute via TensorRT
524520 """
525521
526- if debug :
522+ if kwargs . get ( " debug" , False ) :
527523 warnings .warn (
528- "`debug` is deprecated. Please use `torch_tensorrt.dynamo.Debugger` for debugging functionality" ,
524+ "`debug` is deprecated. Please use `with torch_tensorrt.dynamo.Debugger(...)` to wrap your compilation call to enable debugging functionality" ,
529525 DeprecationWarning ,
530526 stacklevel = 2 ,
531527 )
@@ -732,7 +728,7 @@ def compile_module(
732728 settings : CompilationSettings = CompilationSettings (),
733729 engine_cache : Optional [BaseEngineCache ] = None ,
734730 * ,
735- _debugger_settings : Optional [DebuggerConfig ] = None ,
731+ _debugger_config : Optional [DebuggerConfig ] = None ,
736732) -> torch .fx .GraphModule :
737733 """Compile a traced FX module
738734
@@ -935,29 +931,36 @@ def contains_metadata(gm: torch.fx.GraphModule) -> bool:
935931
936932 trt_modules [name ] = trt_module
937933
938- if _debugger_settings :
934+ if _debugger_config :
939935
940- if _debugger_settings .save_engine_profile :
936+ if _debugger_config .save_engine_profile :
941937 if settings .use_python_runtime :
942- if _debugger_settings .profile_format == "trex " :
943- logger . warning (
938+ if _debugger_config .profile_format != "cudagraph " :
939+ raise ValueError (
944940 "Profiling with TREX can only be enabled when using the C++ runtime. Python runtime profiling only support cudagraph visualization."
945941 )
942+ else :
946943 trt_module .enable_profiling ()
947944 else :
948- path = os .path .join (
949- _debugger_settings .logging_dir , "engine_visualization"
950- )
951- os .makedirs (path , exist_ok = True )
952- trt_module .enable_profiling (
953- profiling_results_dir = path ,
954- profile_format = _debugger_settings .profile_format ,
955- )
956-
957- if _debugger_settings .save_layer_info :
945+ if _debugger_config .profile_format == "cudagraph" :
946+ raise ValueError (
947+ "Profiling with Cudagraph can only be enabled when using the Python runtime. C++ runtime profiling only support TREX/Perfetto visualization."
948+ )
949+ else :
950+ path = os .path .join (
951+ _debugger_config .logging_dir ,
952+ "engine_visualization_profile" ,
953+ )
954+ os .makedirs (path , exist_ok = True )
955+ trt_module .enable_profiling (
956+ profiling_results_dir = path ,
957+ profile_format = _debugger_config .profile_format ,
958+ )
959+
960+ if _debugger_config .save_layer_info :
958961 with open (
959962 os .path .join (
960- _debugger_settings .logging_dir , "engine_layer_info.json"
963+ _debugger_config .logging_dir , "engine_layer_info.json"
961964 ),
962965 "w" ,
963966 ) as f :
@@ -990,7 +993,6 @@ def convert_exported_program_to_serialized_trt_engine(
990993 enabled_precisions : (
991994 Set [torch .dtype | dtype ] | Tuple [torch .dtype | dtype ]
992995 ) = _defaults .ENABLED_PRECISIONS ,
993- debug : bool = False ,
994996 assume_dynamic_shape_support : bool = _defaults .ASSUME_DYNAMIC_SHAPE_SUPPORT ,
995997 workspace_size : int = _defaults .WORKSPACE_SIZE ,
996998 min_block_size : int = _defaults .MIN_BLOCK_SIZE ,
@@ -1052,7 +1054,6 @@ def convert_exported_program_to_serialized_trt_engine(
10521054 torch.randn((1, 3, 224, 244)) # Use an example tensor and let torch_tensorrt infer settings
10531055 ]
10541056 enabled_precisions (Optional[Set[torch.dtype | _enums.dtype]]): The set of datatypes that TensorRT can use
1055- debug (bool): Whether to print out verbose debugging information
10561057 workspace_size (int): Workspace TRT is allowed to use for the module (0 is default)
10571058 min_block_size (int): Minimum number of operators per TRT-Engine Block
10581059 torch_executed_ops (Set[str]): Set of operations to run in Torch, regardless of converter coverage
@@ -1092,9 +1093,9 @@ def convert_exported_program_to_serialized_trt_engine(
10921093 Returns:
10931094 bytes: Serialized TensorRT engine, can either be saved to a file or deserialized via TensorRT APIs
10941095 """
1095- if debug :
1096+ if kwargs . get ( " debug" , False ) :
10961097 warnings .warn (
1097- "`debug` is deprecated. Please use `torch_tensorrt.dynamo.Debugger` to configure debugging options ." ,
1098+ "`debug` is deprecated. Please use `with torch_tensorrt.dynamo.Debugger(...) ` to wrap your compilation call to enable debugging functionality ." ,
10981099 DeprecationWarning ,
10991100 stacklevel = 2 ,
11001101 )
@@ -1181,7 +1182,6 @@ def convert_exported_program_to_serialized_trt_engine(
11811182 compilation_options = {
11821183 "assume_dynamic_shape_support" : assume_dynamic_shape_support ,
11831184 "enabled_precisions" : enabled_precisions ,
1184- "debug" : debug ,
11851185 "workspace_size" : workspace_size ,
11861186 "min_block_size" : min_block_size ,
11871187 "torch_executed_ops" : torch_executed_ops ,
0 commit comments