accelforge.plotting package#

Submodules#

accelforge.plotting.accesstrace module#

Plot which tensor elements a LoopTree mapping touches at each timestep.

The x-axis is the timestep (one iteration of the innermost temporal loop) and the y-axis is the tensor element being accessed, so the shape of the scatter is the mapping’s data movement: horizontal streaks are elements held across many timesteps, diagonal sweeps are streaming accesses, and repeated blocks are refetches.

Passing memory_level= additionally shades, behind the points, the tile that level holds at each timestep, which turns the same picture into a read on that level’s capacity: a wide block is a long-lived tile, and a tall one is a large tile. Blocks show live residency, i.e. they stop at the tile’s last use rather than running to the end of whatever the mapping reserved.

accelforge.plotting.accesstrace.plot_access_trace(trace, workload=None, tensors=None, color_by='einsum', rank=None, memory_level=None, level_color=_TILE_COLOR, marker_size=None, ncols=1, ax=None, figsize=None, **trace_kwargs)[source]#

Plot timestep (x) against accessed tensor element (y) for a LoopTree mapping.

One subplot is drawn per tensor, sharing the timestep axis, so that fusion and reuse across tensors line up vertically.

Parameters:
  • trace – An AccessTrace, or anything trace_accesses() accepts (a Spec, a mapper result, or a Mapping).

  • workload – The workload, required only when trace is a bare Mapping.

  • tensors (Iterable[str] | None) – Which tensors to plot, and in what order. Defaults to every traced tensor.

  • color_by (str) – "einsum" colors accesses by which Einsum made them; "access" colors by read vs. write. Use "access" when many Einsums share one tensor.

  • rank (str | None) – Plot the coordinate along this tensor rank on the y-axis instead of the flattened element index. Only applies to tensors that have this rank.

  • memory_level (str | None) – Shade, in a background block, the tile of each tensor that is resident in this memory level (a storage component of the architecture, e.g. "GlobalBuffer"). One block covers one tile: its width is how long the tile is live – from its first touch to its last, not the whole span the mapping reserves for it – and its height is which elements it holds, so the blocks show directly what a level is holding while the points show what is being touched. Tensors that this level never holds are left unshaded.

  • level_color (str) – The background color of the memory_level blocks.

  • marker_size (float | None) – Marker size in points. Chosen from the data density if not given.

  • ncols (int) – Number of subplot columns.

  • ax – Draw into this existing axes instead of making a figure. Only valid when a single tensor is being plotted.

  • figsize – Figure size. Scaled to the number of subplots if not given.

  • **trace_kwargs – Passed to trace_accesses() when trace is not already an AccessTrace (e.g. max_timesteps=, einsums=, max_points=).

Returns:

The figure and a list of the axes drawn into.

Return type:

(fig, axes)

accelforge.plotting.latency module#

Latency timelines showing how per-component latency overlaps across Einsums.

accelforge.plotting.latency.plot_latency(spec, mappings=None, ax=None)[source]#

Plots a latency timeline. Time is on the X axis, and component on the Y axis. Component latencies may be divided across multiple shared loop levels, and shared latencies may overlap across Einsums. Private latencies do not get a loop level.

Parameters:
  • spec – The spec to plot.

  • mappings (Mappings) – The mapping to plot. Must hold exactly one mapping. If not given, uses spec.mapping.

  • ax (Axes) – The axes to plot on. If not given, creates a new figure and axes.

Return type:

tuple[Figure, Axes]

Returns:

  • fig – The figure containing the plot.

  • ax – The axes containing the plot.

accelforge.plotting.mappings module#

accelforge.plotting.roofline module#

accelforge.plotting.roofline.plot_roofline(bandwidth, computational_throughput, min_computational_intensity=0, max_computational_intensity=None)[source]#

Plot a roofline model.

Parameters:
  • bandwidth (Number) – The memory bandwidth to use when generating the roofline.

  • computational_throughput (Number) – The peak computational throughput to use when generating the roofline.

  • min_computational_intensity (Number) – The minimum computational intensity to include in the x-axis.

  • max_computational_intensity (Number) – The maximum computational intensity to include in the x-axis.

accelforge.plotting.skislope module#

accelforge.plotting.skislope.generate_ski_slope(workload_fname, einsum_names=None, jinja_parse_data=None, ax=None, y_normalizer=1.0, **plot_kwargs)[source]#
accelforge.plotting.skislope.plot_step(xs, ys, ax=None, **plot_kwargs)[source]#

Plot a staircase pattern (flat then drop) from sorted (x, y) points.

Parameters:
  • points – list of (x, y) tuples, sorted by x

  • ax – optional matplotlib axis

  • plot_kwargs – passed to plt.plot()

accelforge.plotting.specs module#

accelforge.plotting.specs.plot_area(specs, labels=None, ax=None)[source]#

Plot area of one or more specs.

Parameters:
  • specs (Iterable[Spec]) – An iterable of specifications.

  • labels (Iterable[str]) – An iterable of the same length as specs to use as labels in the plot.

  • ax (Axes) – An matplotlib Axes to use. A new one is created by default.

Module contents#

accelforge.plotting.plot_access_trace(trace, workload=None, tensors=None, color_by='einsum', rank=None, memory_level=None, level_color=_TILE_COLOR, marker_size=None, ncols=1, ax=None, figsize=None, **trace_kwargs)[source]#

Plot timestep (x) against accessed tensor element (y) for a LoopTree mapping.

One subplot is drawn per tensor, sharing the timestep axis, so that fusion and reuse across tensors line up vertically.

Parameters:
  • trace – An AccessTrace, or anything trace_accesses() accepts (a Spec, a mapper result, or a Mapping).

  • workload – The workload, required only when trace is a bare Mapping.

  • tensors (Iterable[str] | None) – Which tensors to plot, and in what order. Defaults to every traced tensor.

  • color_by (str) – "einsum" colors accesses by which Einsum made them; "access" colors by read vs. write. Use "access" when many Einsums share one tensor.

  • rank (str | None) – Plot the coordinate along this tensor rank on the y-axis instead of the flattened element index. Only applies to tensors that have this rank.

  • memory_level (str | None) – Shade, in a background block, the tile of each tensor that is resident in this memory level (a storage component of the architecture, e.g. "GlobalBuffer"). One block covers one tile: its width is how long the tile is live – from its first touch to its last, not the whole span the mapping reserves for it – and its height is which elements it holds, so the blocks show directly what a level is holding while the points show what is being touched. Tensors that this level never holds are left unshaded.

  • level_color (str) – The background color of the memory_level blocks.

  • marker_size (float | None) – Marker size in points. Chosen from the data density if not given.

  • ncols (int) – Number of subplot columns.

  • ax – Draw into this existing axes instead of making a figure. Only valid when a single tensor is being plotted.

  • figsize – Figure size. Scaled to the number of subplots if not given.

  • **trace_kwargs – Passed to trace_accesses() when trace is not already an AccessTrace (e.g. max_timesteps=, einsums=, max_points=).

Returns:

The figure and a list of the axes drawn into.

Return type:

(fig, axes)