accelforge.tracegen package#
Submodules#
accelforge.tracegen.accesstrace module#
Trace which tensor elements a LoopTree mapping touches at each timestep.
The entry point is trace_accesses(), which walks a
Mapping and returns an AccessTrace:
a record of (timestep, tensor element) pairs, plus the timestep spans over which
each memory level holds one tile. Feeding that to
accelforge.plotting.accesstrace.plot_access_trace() gives the classic
“iteration space vs. data space” picture, from which reuse, tiling, and fusion
behavior are directly readable.
- class accelforge.tracegen.accesstrace.AccessTrace[source]#
Bases:
objectA full record of which tensor elements a mapping accesses at each timestep.
A timestep is one iteration of the innermost temporal loop, i.e. one step of the sequential schedule that the LoopTree describes. Spatial loops do not advance the timestep, so spatially-parallel accesses share an x-coordinate.
- __init__(traces=<factory>, n_timesteps=0, tensor_shapes=<factory>, tensor_ranks=<factory>, einsum_timespans=<factory>, tile_windows=<factory>, truncated=False)#
- einsum_timespans: dict[str, tuple[int, int]]#
{einsum: (first_timestep, last_timestep + 1)}for each Einsum.
- for_tensor(tensor)[source]#
Return every
TensorAccessTracethat touchestensor.- Return type:
- property memory_levels: list[str]#
The names of the storage components the mapping holds tensors in, outermost first.
- tensor_ranks: dict[str, tuple[str, ...]]#
The rank names of each traced tensor, ordered to match
tensor_shapes.
- tile_lifetime(memory_level, tensor)[source]#
The timestep spans over which one tile of
tensorstays resident inmemory_level. Empty if that level never holds the tensor.
- tile_windows: dict[str, dict[str, list[tuple[int, int]]]]#
the timestep spans over which one tile of the tensor stays resident in that memory level. A memory level is the
componentof aStoragenode, and a new span starts whenever a loop outside that node advances.- Type:
{memory_level: {tensor: [(first_timestep, last_timestep + 1), ...]}}
- to_dataframe()[source]#
Return a tidy
pandas.DataFramewith one row per access and columnseinsum,tensor,is_output,timestep, andelement.
- traces: list[TensorAccessTrace]#
One entry per (Einsum, tensor) pair that the mapping touches.
- class accelforge.tracegen.accesstrace.TensorAccessTrace[source]#
Bases:
objectThe accesses that one Einsum makes to one tensor, as a flat list of
(timestep, element)pairs.All arrays share a length: entry
iof every array describes the same access. Duplicate accesses within a single timestep are removed, so an element that is read many times in one timestep appears once.- __init__(tensor, einsum, is_output, timestep, element, coordinates, ranks, tensor_shape)#
- accelforge.tracegen.accesstrace.trace_accesses(spec_or_mapping, workload=None, tensors=None, einsums=None, max_timesteps=None, max_points=DEFAULT_MAX_POINTS)[source]#
Trace which tensor elements a LoopTree mapping accesses at each timestep.
- Parameters:
spec_or_mapping – Either a
Spec(whosemappingandworkloadare used), aMappingsresult (whose single mapping is used), or aMapping. If a bareMappingis given,workloadis required.workload (
Workload|None) – The workload the mapping targets. Required only whenspec_or_mappingis a bareMapping.tensors (
Optional[Iterable[str]]) – If given, only trace these tensors.einsums (
Optional[Iterable[str]]) – If given, only trace these Einsums. Timesteps are still numbered as if all Einsums ran, so traces stay aligned on the x-axis.max_timesteps (
int|None) – If given, trace only the first this-many timesteps. Useful for peeking at the start of a schedule too large to enumerate in full.max_points (
int) – Safety limit on the number of iteration-space points enumerated for a single Einsum. RaisesValueErrorif exceeded; raise the limit or usemax_timestepsto see a prefix instead.
- Returns:
The traced accesses, and the tile-residency spans of every memory level the mapping stores tensors in. Pass to
accelforge.plotting.accesstrace.plot_access_trace()to visualize.- Return type:
accelforge.tracegen.tracemapping module#
Module contents#
- class accelforge.tracegen.AccessTrace[source]#
Bases:
objectA full record of which tensor elements a mapping accesses at each timestep.
A timestep is one iteration of the innermost temporal loop, i.e. one step of the sequential schedule that the LoopTree describes. Spatial loops do not advance the timestep, so spatially-parallel accesses share an x-coordinate.
- __init__(traces=<factory>, n_timesteps=0, tensor_shapes=<factory>, tensor_ranks=<factory>, einsum_timespans=<factory>, tile_windows=<factory>, truncated=False)#
- einsum_timespans: dict[str, tuple[int, int]]#
{einsum: (first_timestep, last_timestep + 1)}for each Einsum.
- for_tensor(tensor)[source]#
Return every
TensorAccessTracethat touchestensor.- Return type:
- property memory_levels: list[str]#
The names of the storage components the mapping holds tensors in, outermost first.
- tensor_ranks: dict[str, tuple[str, ...]]#
The rank names of each traced tensor, ordered to match
tensor_shapes.
- tile_lifetime(memory_level, tensor)[source]#
The timestep spans over which one tile of
tensorstays resident inmemory_level. Empty if that level never holds the tensor.
- tile_windows: dict[str, dict[str, list[tuple[int, int]]]]#
the timestep spans over which one tile of the tensor stays resident in that memory level. A memory level is the
componentof aStoragenode, and a new span starts whenever a loop outside that node advances.- Type:
{memory_level: {tensor: [(first_timestep, last_timestep + 1), ...]}}
- to_dataframe()[source]#
Return a tidy
pandas.DataFramewith one row per access and columnseinsum,tensor,is_output,timestep, andelement.
- traces: list[TensorAccessTrace]#
One entry per (Einsum, tensor) pair that the mapping touches.
- class accelforge.tracegen.TensorAccessTrace[source]#
Bases:
objectThe accesses that one Einsum makes to one tensor, as a flat list of
(timestep, element)pairs.All arrays share a length: entry
iof every array describes the same access. Duplicate accesses within a single timestep are removed, so an element that is read many times in one timestep appears once.- __init__(tensor, einsum, is_output, timestep, element, coordinates, ranks, tensor_shape)#
- accelforge.tracegen.trace_accesses(spec_or_mapping, workload=None, tensors=None, einsums=None, max_timesteps=None, max_points=DEFAULT_MAX_POINTS)[source]#
Trace which tensor elements a LoopTree mapping accesses at each timestep.
- Parameters:
spec_or_mapping – Either a
Spec(whosemappingandworkloadare used), aMappingsresult (whose single mapping is used), or aMapping. If a bareMappingis given,workloadis required.workload (
Workload|None) – The workload the mapping targets. Required only whenspec_or_mappingis a bareMapping.tensors (
Optional[Iterable[str]]) – If given, only trace these tensors.einsums (
Optional[Iterable[str]]) – If given, only trace these Einsums. Timesteps are still numbered as if all Einsums ran, so traces stay aligned on the x-axis.max_timesteps (
int|None) – If given, trace only the first this-many timesteps. Useful for peeking at the start of a schedule too large to enumerate in full.max_points (
int) – Safety limit on the number of iteration-space points enumerated for a single Einsum. RaisesValueErrorif exceeded; raise the limit or usemax_timestepsto see a prefix instead.
- Returns:
The traced accesses, and the tile-residency spans of every memory level the mapping stores tensors in. Pass to
accelforge.plotting.accesstrace.plot_access_trace()to visualize.- Return type: