Debugger#
The torch_tensorrt.dynamo.Debugger context manager provides visibility into
the Torch-TensorRT compilation pipeline. Use it to capture FX graph
visualizations around lowering passes, monitor engine building, save profiling
data, and control logging verbosity — all without modifying your model code.
Usage#
Wrap your torch_tensorrt.dynamo.compile (or torch.compile) call inside
the Debugger context:
import torch_tensorrt
with torch_tensorrt.dynamo.Debugger(
log_level="debug",
logging_dir="/tmp/trt_debug",
engine_builder_monitor=True,
capture_fx_graph_before=["remove_detach"],
capture_fx_graph_after=["complex_graph_detection"],
):
trt_model = torch_tensorrt.dynamo.compile(exported_program, arg_inputs=inputs)
output = trt_model(*inputs)
On exit the context restores all previous logging state and lowering-pass lists automatically.
Options#
Parameter |
Default |
Description |
|---|---|---|
|
|
Verbosity level: |
|
|
Directory where logs, profiles, and graph SVGs are written. |
|
|
List of lowering-pass names. An SVG of the FX graph is saved before each named pass runs. |
|
|
List of lowering-pass names. An SVG of the FX graph is saved after each named pass runs. |
|
|
Stream TensorRT engine-build progress to the console. |
|
|
Save per-layer profiling data after the first inference run. |
|
|
Format for saved profiles. C++ runtime supports |
|
|
Record TensorRT API calls for replay-based debugging (Linux only).
Requires |
|
|
Write a JSON file containing per-layer metadata for the compiled engine. |
Output layout#
After the context exits, logging_dir contains:
<logging_dir>/
torch_tensorrt_logging.log # always written
lowering_passes_visualization/ # when capture_fx_graph_before/after used
before_<pass_name>.svg
after_<pass_name>.svg
engine_visualization_profile/ # when save_engine_profile=True
engine_layer_info.json # when save_layer_info=True
TensorRT API recordings (capture_tensorrt_api_recording=True) are written
separately to /tmp/torch_tensorrt_<user>/shim/ and are independent of
logging_dir.