Compare model stages
Follow layers from the source model to the compiled graph.
Exporting and compiling a model changes its graph. An operation may split into several operations, or several layers may fuse into one. Visualizer shows these stages side by side and maps the corresponding layers between them.
Use this to understand what a compiler changed, check an optimization, or trace a slow compiled operation back to the part of the source model you can change.
In this illustrative example, Conv, BatchNorm, and ReLU become one TensorRT operation. The highlighted bands connect the corresponding layers across stages.
Open the stages#
Start with files from the same model’s export and compilation process. You can compare two stages or follow the model through all three:
| Stage | File to add |
|---|---|
| PyTorch | A .pt2 exported program. |
| ONNX | The exported .onnx model. |
| TensorRT | The engine’s layer-info JSON, with an optional profile JSON for layer timings. |
Select Visualizer in the Hub sidebar. In Add Models, use + PyTorch Export, + ONNX, and + TensorRT to add the files you have. Arrange them in processing order—PyTorch, ONNX, then TensorRT—and select Visualize when they are prepared. Keep the ONNX stage between PyTorch and TensorRT so you can follow the mapping through it.
To add a stage to an open workspace, use Manage Models. Drag the models in the preview to reorder them, then select Apply changes.
Follow a layer#
Select an operation in any stage. Visualizer highlights its corresponding operations in the other graphs and opens Node details for your selection. You can start at the source and follow it forward, or select a compiled operation and trace it back.
In the example above, the compiled convolution represents three earlier operations. Batch normalization and the activation have been fused into it; they no longer appear as separate operations in the TensorRT graph.
Turn on Show differences in View settings to highlight changes across the graphs, including fused operations. Inspect the selected nodes and their tensors to compare shapes, precision, and other recorded properties.
Understand the mapping#
Visualizer builds mappings automatically using the information in the files, such as layer names, operation types, graph structure, and source-layer references recorded by the compiler. A mapping can connect one layer to several layers, or several layers to one.
If a layer has no match, that alone does not mean it was removed. The files may not contain enough information to establish the connection.
For a performance investigation, start with a costly operation in the compiled graph and follow its mapped layers back to the source. Use the input shapes and operation properties to understand the work it performs. When you include a TensorRT profile, you can inspect its recorded layer timings too.
Keep the comparison#
Use Download .embedl bundle in the toolbar to save the workspace for yourself or a teammate. Store it as a run artifact alongside the model and its results. Add your findings to the run description so the reason for an optimization stays with the experiment.
Use Experiment Tracking to compare the measured accuracy and hardware performance before and after the change.