Visualization#

Visualization utilities for Nsight Python profiling and tensor difference analysis.

This module provides:
  • Plotting functions for profiling results with configurable layout and annotation.

nsight.visualization.visualize(
agg_df: str | DataFrame,
row_panels: Sequence[str] | None,
col_panels: Sequence[str] | None,
x_keys: Sequence[str] | None = None,
print_data: bool = False,
title: str = '',
filename: str = 'plot.png',
ylabel: str = '',
annotate_points: bool = True,
show_avg: bool = True,
plot_type: str = 'line',
plot_width: int = 6,
plot_height: int = 4,
show_geomean: bool = True,
show_grid: bool = True,
variant_fields: Sequence[Any] | None = None,
variant_annotations: Sequence[Any] | None = None,
plot_callback: Callable[[Figure], None] | None = None,
)#

Plots profiling results using line or bar plots in a subplot grid.

Parameters:
  • agg_df (str | DataFrame) – Aggregated profiling data or path to CSV file.

  • row_panels (Sequence[str] | None) – List of fields for whose unique values to create a new subplot along the vertical axis.

  • col_panels (Sequence[str] | None) – List of fields for whose unique values to create a new subplot along the horizontal axis.

  • x_keys (Optional[Sequence[str]]) – List of fields to use for the x-axis. By default, we use all parameters of the decorated function except those specified in row_panels and col_panels.

  • print_data (bool) – Whether to print aggregated profiling data to stdout.

  • title (str) – Main plot title.

  • filename (str) – Output filename for the saved plot.

  • ylabel (str) – Label for the y-axis (typically the metric name).

  • annotate_points (bool) – Whether to annotate data points with values.

  • show_avg (bool) – Whether to add an “Avg” column with average metric values.

  • plot_type (str) – Type of plot: “line” or “bar”.

  • show_geomean (bool) – Whether to show geometric mean values.

  • show_grid (bool) – Whether to display grid lines on the plot.

  • variant_fields (Optional[Sequence[Any]]) – List of config fields to use as variant fields (lines).

  • variant_annotations (Optional[Sequence[Any]]) – List of annotated range names for which to apply variant splitting. The provided strings must each match one of the names defined using nsight.annotate.

  • plot_width (int)

  • plot_height (int)

  • plot_callback (Callable[[Figure], None] | None)

Return type:

DataFrame