accelforge.mapper.FFM package#
Submodules#
accelforge.mapper.FFM.data module#
Results from mapping exploration.
- class accelforge.mapper.FFM.data.ActionDataFrame[source]#
Bases:
DataFrameA hierarchical column dataframe with action counts.
- class accelforge.mapper.FFM.data.ResultDataFrame[source]#
Bases:
DataFrame- property actions: ResultDataFrame#
Returns a ResultDataFrame with all action-related columns.
- property actions_df: ActionDataFrame#
Return an ActionDataFrame.
- property energy: ResultDataFrame#
Returns a ResultDataFrame with all energy-related columns.
accelforge.mapper.FFM.main module#
- accelforge.mapper.FFM.main.join_pmappings(pmappings, metrics, require_all_einsums=True, _pmapping_row_filter_function=None, print_progress=True, _skip_invalid=True, _combine_reservations=True, _runtime_log_file=None)[source]#
Joins pmappings into a full mappings for the entire workload. Pmappings can be generated using make_pmappings.
- Parameters:
pmappings (
MultiEinsumPmappings) – The pmappings to join.require_all_einsums (
bool) – If True, all einsums in the workload must have pmappings. If False, only einsums that have pmappings will be included in the final mappings._pmapping_row_filter_function (
Optional[Callable[[Series],bool]]) – A function that takes in a row of the pmapping dataframe and returns True if the row should be included in the final mappings, and False otherwise. If None, all rows will be included.print_progress (
bool) – Whether to print progress of the mapping process, including progress bars.metrics (
Metrics) – The metrics to optimize when joining pmappings._skip_invalid (
bool) – If True, skip joining incompatible pmappings. If False, join all pairs._combine_reservations (
bool) – If True, consolidate reservations to increase pruning effectiveness._runtime_log_file (
str|None) – If set, append per-step runtime as JSON lines to this file.
- Returns:
A Mappings object containing all valid, optimal mappings for the workload.
- Return type:
- accelforge.mapper.FFM.main.make_pmappings(spec, einsum_names=None, can_combine_multiple_runs=False, cache_dir=None, print_progress=True, print_number_of_pmappings=True, one_pbar_only=False)[source]#
Creates pmappings for a spec. Pmappings must be joined together using join_pmappings to create a full mapping.
- Parameters:
spec (
Spec) – The Spec to generate pmappings for.einsum_names (
list[str] |None) – The einsum names to generate pmappings for. If None, all einsums will be included.can_combine_multiple_runs (
bool) – If True, allows combining multiple make_pmappings runs (e.g.pmappings = make_pmappings(*args_a) | make_pmappings(*args_b)). Set to False for faster execution.cache_dir (
str|None) – The directory to cache pmappings in. If None, no caching will be done.one_pbar_only (
bool) – Whether to only print only a single progress bar. If this is True, then only a progress bar will be created for making tile shapes, which is generally the longest-running part of the mapping process.print_progress (
bool) – Whether to print progress of the mapping process, including progress bars.print_number_of_pmappings (
bool) – Whether to print the number of pmappings for each einsum.Returns – A MultiEinsumPmappings object.
- Return type:
- accelforge.mapper.FFM.main.map_workload_to_arch(spec, einsum_names=None, can_combine_multiple_runs=False, cache_dir=None, one_pbar_only=False, print_progress=True, print_number_of_pmappings=True, _pmapping_row_filter_function=None)[source]#
Maps a workload to an architecture using the AccelForge Fast and Fusiest Mapper (FFM).
- Parameters:
spec (
Spec) – The Spec to map.einsum_names (
list[str] |None) – The einsum names to map. If None, all einsums will be mapped.can_combine_multiple_runs (
bool) – If True, allows combining multiple make_pmappings runs (e.g.pmappings = make_pmappings(*args_a) | make_pmappings(*args_b)). Set to False for faster execution.cache_dir (
str|None) – The directory to cache pmappings in. If None, no caching will be done.one_pbar_only (
bool) – Whether to only print only a single progress bar. If this is True, then only a progress bar will be created for making tile shapes, which is generally the longest-running part of the mapping process.print_progress (
bool) – Whether to print progress of the mapping process, including progress bars.print_number_of_pmappings (
bool) – Whether to print the number of pmappings for each einsum._pmapping_row_filter_function (
Optional[Callable[[Series],bool]]) – A function that takes in a row of the pmapping dataframe and returns True if the row should be included in the final mappings, and False otherwise. If None, all rows will be included.
- Return type:
accelforge.mapper.FFM.mappings module#
- class accelforge.mapper.FFM.mappings.Mappings[source]#
Bases:
objectA collection of mappings and their evaluation results, generated by
join_pmappings().- Variables:
spec – The specification used to generate the mappings.
einsum_names – The names of the Einsums in these mappings.
data – A DataFrame containing the mappings and their evaluation results. Column names in the dataframe are are string separated by “<SEP>”, such as “Total<SEP>energy”.
total_mappings – The total number of mappings that have been explored in order to get the mappings in the dataframe, equal to the full mapspace size.
valid_mappings – The number of valid mappings that have been explored in order to get the mappings in the dataframe, equal to the valid mapspace size.
flattened_arches – A dictionary of (EinsumName, Compute Name) to lists of architecture nodes. These contain the evaluated and flattened architecture node for that particular Einsum and compute combination.
evaluated_specs – A dictionary of Einsum names to evaluated specifications. These contain the evaluated specification for that particular Einsum.
- __init__(spec, einsum_names, data, total_mappings, valid_mappings, flattened_arches, evaluated_specs)[source]#
- access(*keys, col_idx=None)[source]#
Returns a new Mappings object with only the columns that contain the given keys. Column names are strings separated by “<SEP>”, and this method will return columns with one <SEP>-separated string matching the given key. Then, for all remaining columns, the key will be removed.
For example, if the columns are “Compute<SEP>Energy”, and “DRAM<SEP>Energy”, and “DRAM<SEP>Latency”, then access(“Energy”) will return a Mappings object with columns “Compute” and “DRAM”, and access(“DRAM”) will return a Mappings object with columns “Compute” and “Latency”.
If multiple keys are given, then the procedure is repeated for each key.
- col_idx:
The index of the key in the column name. This can be used if the given key is found at multiple indexes in different columns.
- actions(per_einsum=False, per_component=True, per_tensor=False, list_if_one_mapping=False)[source]#
Returns the number of actions performed in the mapping. A dictionary is returned with keys that are tuples of (Einsum name, Component name, Tensor name, Action name), with any of these being omitted if the corresponding parameter is not set to True. If neither of the
per_parameters are set to True, a float or a list of floats is returned.- Parameters:
per_einsum (
bool) – If True, then the number of actions will reported per-Einsum.per_component (
bool) – If True, then the number of actions will reported per-component.per_tensor (
bool) – If True, then the number of actions will reported per-tensor.list_if_one_mapping (
bool) – If True and there is only one mapping, then values in the returned dictionary will be lists of values, each containing a single value. Otherwise, if there is only one mapping, the values in the returned dictionary will each be a single value.
- Returns:
A dictionary with the number of actions performed for each Einsum, Component, Tensor, and Action. Keys are tuples of (Einsum name, Component name, Tensor name, Action name), with any of these being omitted if the corresponding parameter is not set to True. If none of the
per_parameters are set to True, a float or a list of floats is returned.- Return type:
dict[tuple[str,...] |str,float|list[float]] |float|list[float]
- drop(*keys)[source]#
Returns a new Mappings object with the given keys dropped from all columns. Column names are strings separated by “<SEP>”, and this method will will drop columns with one <SEP>-separated string matching the given key. Then, for all remaining columns, the key will be removed.
For example, if the columns are “Compute<SEP>Energy”, and “DRAM<SEP>Energy”, and “DRAM<SEP>Latency”, then drop(“Energy”) will drop “Compute<SEP>Energy” and “DRAM<SEP>Energy”, and drop(“DRAM”) will drop “DRAM<SEP>Energy” and “DRAM<SEP>Latency”.
If multiple keys are given, then the procedure is repeated for each key.
- drop_zeros()[source]#
Returns a new Mappings object with all columns that have only zeros dropped.
- Return type:
- energy(per_einsum=False, per_component=False, per_tensor=False, per_action=False, list_if_one_mapping=False)[source]#
Returns the energy consumed. A dictionary is returned with keys that are tuples of (Einsum name, Component name, Tensor name, Action name), with any of these being omitted if the corresponding parameter is not set to True. If neither of the
per_parameters are set to True, a float or a list of floats is returned.NOTE: Leak power is not per-tensor. If
per_tensoris True, then the tensor name for leak will be None.- Parameters:
per_einsum (
bool) – If True, then the energy will reported per-Einsum.per_component (
bool) – If True, then the energy will reported per-component.per_tensor (
bool) – If True, then the energy will reported per-tensor.per_action (
bool) – If True, then the energy will reported per-action.list_if_one_mapping (
bool) – If True and there is only one mapping, then values in the returned dictionary will be lists of values, each containing a single value. Otherwise, if there is only one mapping, the values in the returned dictionary will each be a single value.
- Returns:
A dictionary with the energy consumed for each Einsum, Component, Tensor, and Action. Keys are tuples of (Einsum name, Component name, Tensor name, Action name), with any of these being omitted if the corresponding parameter is not set to True. If none of the
per_parameters are set to True, a float or a list of floats is returned.- Return type:
dict[tuple[str,...] |str,float|list[float]] |float|list[float]
- items(list_if_one_mapping=False)[source]#
Shorthand for
to_dict().items(). Casts this Mappings object to a dictionary, then returns the items of the dictionary.- Parameters:
list_if_one_mapping (
bool) – If True and there is only one mapping, then values in the returned list will be a single value, rather than a list of values. Otherwise, they will always be a list of values.- Returns:
A list of tuples of (key, value).
- Return type:
- latency(per_einsum=False, per_component=False, list_if_one_mapping=False)[source]#
Returns the latency consumed. A dictionary is returned with keys that are tuples of (Einsum name, Component name), with either being omitted if the corresponding parameter is not set to True. If neither of the
per_parameters are set to True, a float or a list of floats is returned.NOTE: If per-Einsum is False and per-component is True, then the latency of each component will be summed across all Einsums. THE TOTAL LATENCY MAY BE GREATER THAN THE MAX OF THE PER-COMPONENT LATENCIES. This is because different components can be the bottleneck for different Einsums.
- Parameters:
per_einsum (
bool) – If True, then the latency will reported per-Einsum.per_component (
bool) – If True, then the latency will reported per-component.list_if_one_mapping (
bool) – If True and there is only one mapping, then values in the returned dictionary will be lists of values, each containing a single value. Otherwise, if there is only one mapping, the values in the returned dictionary will each be a single value.
- Returns:
A dictionary with the latency for each Einsum+Component pair. Keys are tuples of (Einsum name, Component name), with either being omitted if the corresponding parameter is not set to True. If neither of the
per_parameters are set to True, a float or a list of floats is returned.- Return type:
dict[tuple[str,...] |str,float|list[float]] |float|list[float]
- num_computes(einsum_name=None)[source]#
Returns the number of computes for the given Einsum name, or total computes if
einsum_nameisNone.- Return type:
- per_compute(per_einsum=False)[source]#
Returns the per-compute evaluation results by dividing all statistics by the number of computes.
- Parameters:
per_einsum (
bool) – If True, then for each Einsum, statistics will be divided only by the number of computes for that Einsum. This makes it clear to see per-compute stats for each Einsum, but note that total energy/compute will not be a direct sum of the per-compute stats then (and the same for latency and other statistics).- Returns:
A new Mappings object with the per-compute evaluation results.
- Return type:
- per_tensor_size(return_n_elements=False)[source]#
Returns a dictionary of: {Tensor name: Number of bits} for each tensor in the spec. If return_n_elements is true, then the number of elements is returned instead of the number of bits.
- render(index=None, **kwargs)[source]#
Renders the mapping as a Pydot graph. Returns an SVG string. This is only supported if there is a single mapping; if there are multiple mappings, then either index into this Mappings object first, or pass in an index.
- Parameters:
- Returns:
An SVG string of the mapping.
- Return type:
- Raises:
ValueError – If there are multiple mappings and no index is provided.
- resource_usage(list_if_one_mapping=False)[source]#
Returns the usage of each resource in the mapping.
- Parameters:
list_if_one_mapping (
bool) – If True and there is only one mapping, then values in the returned dictionary will be lists of values, each containing a single value. Otherwise, if there is only one mapping, the values in the returned dictionary will each be a single value.- Returns:
A dictionary with the usage of each resource.
- Return type:
- to_dict(list_if_one_mapping=False)[source]#
Returns the data in this Mappings object as a dictionary. Each column in the this Mappings’ data becomes a key in the dictionary. Values in the dictionary may be a single value if there is only one mapping, or a list of values if there are multiple mappings.
- Parameters:
list_if_one_mapping (
bool) – If True and there is only one mapping, then values in the returned dictionary will be a single value, rather than a list of values. Otherwise, they will always be a list of values.- Returns:
A dictionary with the same keys as the columns of the dataframe, and values that are either a single value or a list of values.
- Return type:
accelforge.mapper.FFM.pmappings module#
- class accelforge.mapper.FFM.pmappings.MultiEinsumPmappings[source]#
Bases:
objectA collection of pmappings for each Einsum in a workload, generated by
make_pmappings().- Parameters:
einsum2pmappings (
dict[str,list[PmappingGroup]]) – A dictionary of Einsum names to lists of PmappingGroups. PmappingGroups contain the Pareto-optimal pmappings for the Einsum.pmapping_objects (
dict[str,dict[UUID,Mapping]]) – A dictionary of Einsum names to dictionaries of UUIDs to Mappings. The entries in the PmappingGroup objects reference these pmapping objects.einsum2jobs (
dict[str,list[Job]]) – A dictionary of Einsum names to lists of Jobs that generated the pmappings.can_combine_multiple_runs (
bool) – Whether the pmappings can be combined from multiple runs. If this is True, then multiple make_pmappings calls can be summed together to get a single MultiEinsumPmappings object. If this is True, the mapper may run more slowly.einsums_with_pmappings_generated (
set[str]) – Einsums for which pmappings were generated (or attempted to be generated).flattened_arches (
dict[str,list[Leaf]]) – A dictionary of (EinsumName, Compute Name) to lists of architecture nodes. These contain the evaluated and flattened architecture node for that particular Einsum and compute combination.evaluated_specs (
dict[str,Spec]) – A dictionary of Einsum names to evaluated specifications. These contain the evaluated specification for that particular Einsum.
- __init__(spec, einsum2pmappings, pmapping_objects, einsum2jobs, can_combine_multiple_runs, einsums_with_pmappings_generated, flattened_arches, evaluated_specs)[source]#
- drop_einsums(*einsums_with_pmappings_generated)[source]#
Removes all pmappings for the given Einsums.
- Parameters:
einsums_with_pmappings_generated (
str) – The Einsums for which to remove pmappings.
- n_evaluated_pmappings(per_einsum=False)[source]#
Returns the number of pmappings that were evaluated for each Einsum. This is greater than the number of Pareto-optimal pmappings because some mappings are found to be suboptimal after they have been evaluated.
- n_pareto_optimal_pmappings(per_einsum=False)[source]#
Returns the number of Pareto-optimal pmappings for each Einsum. This is the number of mappings that will be returned by the make_pmappings function.
- n_pmapping_string()[source]#
Returns a string representation of the number of pmappings in the mapspace. Printing this can help diagnose if the mapper is not finding any pmappings or mappings.
- Returns:
A string representation of the number of pmappings in the mapspace.
- Return type:
- n_valid_pmappings(per_einsum=False)[source]#
Returns the number of valid pmappings for each Einsum. A valid pmapping is one that satisfies all constraints and resource usage limits.
Module contents#
- class accelforge.mapper.FFM.Mappings[source]#
Bases:
objectA collection of mappings and their evaluation results, generated by
join_pmappings().- Variables:
spec – The specification used to generate the mappings.
einsum_names – The names of the Einsums in these mappings.
data – A DataFrame containing the mappings and their evaluation results. Column names in the dataframe are are string separated by “<SEP>”, such as “Total<SEP>energy”.
total_mappings – The total number of mappings that have been explored in order to get the mappings in the dataframe, equal to the full mapspace size.
valid_mappings – The number of valid mappings that have been explored in order to get the mappings in the dataframe, equal to the valid mapspace size.
flattened_arches – A dictionary of (EinsumName, Compute Name) to lists of architecture nodes. These contain the evaluated and flattened architecture node for that particular Einsum and compute combination.
evaluated_specs – A dictionary of Einsum names to evaluated specifications. These contain the evaluated specification for that particular Einsum.
- __init__(spec, einsum_names, data, total_mappings, valid_mappings, flattened_arches, evaluated_specs)[source]#
- access(*keys, col_idx=None)[source]#
Returns a new Mappings object with only the columns that contain the given keys. Column names are strings separated by “<SEP>”, and this method will return columns with one <SEP>-separated string matching the given key. Then, for all remaining columns, the key will be removed.
For example, if the columns are “Compute<SEP>Energy”, and “DRAM<SEP>Energy”, and “DRAM<SEP>Latency”, then access(“Energy”) will return a Mappings object with columns “Compute” and “DRAM”, and access(“DRAM”) will return a Mappings object with columns “Compute” and “Latency”.
If multiple keys are given, then the procedure is repeated for each key.
- col_idx:
The index of the key in the column name. This can be used if the given key is found at multiple indexes in different columns.
- actions(per_einsum=False, per_component=True, per_tensor=False, list_if_one_mapping=False)[source]#
Returns the number of actions performed in the mapping. A dictionary is returned with keys that are tuples of (Einsum name, Component name, Tensor name, Action name), with any of these being omitted if the corresponding parameter is not set to True. If neither of the
per_parameters are set to True, a float or a list of floats is returned.- Parameters:
per_einsum (
bool) – If True, then the number of actions will reported per-Einsum.per_component (
bool) – If True, then the number of actions will reported per-component.per_tensor (
bool) – If True, then the number of actions will reported per-tensor.list_if_one_mapping (
bool) – If True and there is only one mapping, then values in the returned dictionary will be lists of values, each containing a single value. Otherwise, if there is only one mapping, the values in the returned dictionary will each be a single value.
- Returns:
A dictionary with the number of actions performed for each Einsum, Component, Tensor, and Action. Keys are tuples of (Einsum name, Component name, Tensor name, Action name), with any of these being omitted if the corresponding parameter is not set to True. If none of the
per_parameters are set to True, a float or a list of floats is returned.- Return type:
dict[tuple[str,...] |str,float|list[float]] |float|list[float]
- drop(*keys)[source]#
Returns a new Mappings object with the given keys dropped from all columns. Column names are strings separated by “<SEP>”, and this method will will drop columns with one <SEP>-separated string matching the given key. Then, for all remaining columns, the key will be removed.
For example, if the columns are “Compute<SEP>Energy”, and “DRAM<SEP>Energy”, and “DRAM<SEP>Latency”, then drop(“Energy”) will drop “Compute<SEP>Energy” and “DRAM<SEP>Energy”, and drop(“DRAM”) will drop “DRAM<SEP>Energy” and “DRAM<SEP>Latency”.
If multiple keys are given, then the procedure is repeated for each key.
- drop_zeros()[source]#
Returns a new Mappings object with all columns that have only zeros dropped.
- Return type:
- energy(per_einsum=False, per_component=False, per_tensor=False, per_action=False, list_if_one_mapping=False)[source]#
Returns the energy consumed. A dictionary is returned with keys that are tuples of (Einsum name, Component name, Tensor name, Action name), with any of these being omitted if the corresponding parameter is not set to True. If neither of the
per_parameters are set to True, a float or a list of floats is returned.NOTE: Leak power is not per-tensor. If
per_tensoris True, then the tensor name for leak will be None.- Parameters:
per_einsum (
bool) – If True, then the energy will reported per-Einsum.per_component (
bool) – If True, then the energy will reported per-component.per_tensor (
bool) – If True, then the energy will reported per-tensor.per_action (
bool) – If True, then the energy will reported per-action.list_if_one_mapping (
bool) – If True and there is only one mapping, then values in the returned dictionary will be lists of values, each containing a single value. Otherwise, if there is only one mapping, the values in the returned dictionary will each be a single value.
- Returns:
A dictionary with the energy consumed for each Einsum, Component, Tensor, and Action. Keys are tuples of (Einsum name, Component name, Tensor name, Action name), with any of these being omitted if the corresponding parameter is not set to True. If none of the
per_parameters are set to True, a float or a list of floats is returned.- Return type:
dict[tuple[str,...] |str,float|list[float]] |float|list[float]
- items(list_if_one_mapping=False)[source]#
Shorthand for
to_dict().items(). Casts this Mappings object to a dictionary, then returns the items of the dictionary.- Parameters:
list_if_one_mapping (
bool) – If True and there is only one mapping, then values in the returned list will be a single value, rather than a list of values. Otherwise, they will always be a list of values.- Returns:
A list of tuples of (key, value).
- Return type:
- latency(per_einsum=False, per_component=False, list_if_one_mapping=False)[source]#
Returns the latency consumed. A dictionary is returned with keys that are tuples of (Einsum name, Component name), with either being omitted if the corresponding parameter is not set to True. If neither of the
per_parameters are set to True, a float or a list of floats is returned.NOTE: If per-Einsum is False and per-component is True, then the latency of each component will be summed across all Einsums. THE TOTAL LATENCY MAY BE GREATER THAN THE MAX OF THE PER-COMPONENT LATENCIES. This is because different components can be the bottleneck for different Einsums.
- Parameters:
per_einsum (
bool) – If True, then the latency will reported per-Einsum.per_component (
bool) – If True, then the latency will reported per-component.list_if_one_mapping (
bool) – If True and there is only one mapping, then values in the returned dictionary will be lists of values, each containing a single value. Otherwise, if there is only one mapping, the values in the returned dictionary will each be a single value.
- Returns:
A dictionary with the latency for each Einsum+Component pair. Keys are tuples of (Einsum name, Component name), with either being omitted if the corresponding parameter is not set to True. If neither of the
per_parameters are set to True, a float or a list of floats is returned.- Return type:
dict[tuple[str,...] |str,float|list[float]] |float|list[float]
- num_computes(einsum_name=None)[source]#
Returns the number of computes for the given Einsum name, or total computes if
einsum_nameisNone.- Return type:
- per_compute(per_einsum=False)[source]#
Returns the per-compute evaluation results by dividing all statistics by the number of computes.
- Parameters:
per_einsum (
bool) – If True, then for each Einsum, statistics will be divided only by the number of computes for that Einsum. This makes it clear to see per-compute stats for each Einsum, but note that total energy/compute will not be a direct sum of the per-compute stats then (and the same for latency and other statistics).- Returns:
A new Mappings object with the per-compute evaluation results.
- Return type:
- per_tensor_size(return_n_elements=False)[source]#
Returns a dictionary of: {Tensor name: Number of bits} for each tensor in the spec. If return_n_elements is true, then the number of elements is returned instead of the number of bits.
- render(index=None, **kwargs)[source]#
Renders the mapping as a Pydot graph. Returns an SVG string. This is only supported if there is a single mapping; if there are multiple mappings, then either index into this Mappings object first, or pass in an index.
- Parameters:
- Returns:
An SVG string of the mapping.
- Return type:
- Raises:
ValueError – If there are multiple mappings and no index is provided.
- resource_usage(list_if_one_mapping=False)[source]#
Returns the usage of each resource in the mapping.
- Parameters:
list_if_one_mapping (
bool) – If True and there is only one mapping, then values in the returned dictionary will be lists of values, each containing a single value. Otherwise, if there is only one mapping, the values in the returned dictionary will each be a single value.- Returns:
A dictionary with the usage of each resource.
- Return type:
- to_dict(list_if_one_mapping=False)[source]#
Returns the data in this Mappings object as a dictionary. Each column in the this Mappings’ data becomes a key in the dictionary. Values in the dictionary may be a single value if there is only one mapping, or a list of values if there are multiple mappings.
- Parameters:
list_if_one_mapping (
bool) – If True and there is only one mapping, then values in the returned dictionary will be a single value, rather than a list of values. Otherwise, they will always be a list of values.- Returns:
A dictionary with the same keys as the columns of the dataframe, and values that are either a single value or a list of values.
- Return type:
- class accelforge.mapper.FFM.Metrics[source]#
Bases:
FlagMetrics used to optimize mappings or reported by model.
- ACTIONS = 32#
Action counts.
- DETAILED_MEMORY_USAGE = 64#
Memory usage broken down by tensor and Einsum.
- DYNAMIC_ENERGY = 4#
The amount of dynamic energy consumed by the workload.
- ENERGY = 2#
The amount of energy consumed by the workload.
- LATENCY = 1#
The amount of time taken to execute the workload.
- LEAK_ENERGY = 8#
The amount of leak energy consumed by the workload.
- RESOURCE_USAGE = 16#
The amount of resources used by the workload.
When used as a mapper objective, this objective is multivariate, and must consider every resource available to the hardware.
- __new__(value)#
- class accelforge.mapper.FFM.MultiEinsumPmappings[source]#
Bases:
objectA collection of pmappings for each Einsum in a workload, generated by
make_pmappings().- Parameters:
einsum2pmappings (
dict[str,list[PmappingGroup]]) – A dictionary of Einsum names to lists of PmappingGroups. PmappingGroups contain the Pareto-optimal pmappings for the Einsum.pmapping_objects (
dict[str,dict[UUID,Mapping]]) – A dictionary of Einsum names to dictionaries of UUIDs to Mappings. The entries in the PmappingGroup objects reference these pmapping objects.einsum2jobs (
dict[str,list[Job]]) – A dictionary of Einsum names to lists of Jobs that generated the pmappings.can_combine_multiple_runs (
bool) – Whether the pmappings can be combined from multiple runs. If this is True, then multiple make_pmappings calls can be summed together to get a single MultiEinsumPmappings object. If this is True, the mapper may run more slowly.einsums_with_pmappings_generated (
set[str]) – Einsums for which pmappings were generated (or attempted to be generated).flattened_arches (
dict[str,list[Leaf]]) – A dictionary of (EinsumName, Compute Name) to lists of architecture nodes. These contain the evaluated and flattened architecture node for that particular Einsum and compute combination.evaluated_specs (
dict[str,Spec]) – A dictionary of Einsum names to evaluated specifications. These contain the evaluated specification for that particular Einsum.
- __init__(spec, einsum2pmappings, pmapping_objects, einsum2jobs, can_combine_multiple_runs, einsums_with_pmappings_generated, flattened_arches, evaluated_specs)[source]#
- drop_einsums(*einsums_with_pmappings_generated)[source]#
Removes all pmappings for the given Einsums.
- Parameters:
einsums_with_pmappings_generated (
str) – The Einsums for which to remove pmappings.
- n_evaluated_pmappings(per_einsum=False)[source]#
Returns the number of pmappings that were evaluated for each Einsum. This is greater than the number of Pareto-optimal pmappings because some mappings are found to be suboptimal after they have been evaluated.
- n_pareto_optimal_pmappings(per_einsum=False)[source]#
Returns the number of Pareto-optimal pmappings for each Einsum. This is the number of mappings that will be returned by the make_pmappings function.
- n_pmapping_string()[source]#
Returns a string representation of the number of pmappings in the mapspace. Printing this can help diagnose if the mapper is not finding any pmappings or mappings.
- Returns:
A string representation of the number of pmappings in the mapspace.
- Return type:
- n_valid_pmappings(per_einsum=False)[source]#
Returns the number of valid pmappings for each Einsum. A valid pmapping is one that satisfies all constraints and resource usage limits.
- class accelforge.mapper.FFM.PmappingGroup[source]#
Bases:
object- static combine_combineable(pmapping_groups, live_tensors, allow_different_compatibilies=False, _combine_reservations=True, print_progress=True, pbar_postfix='')[source]#
- Return type:
- Return type:
- static left_consolidate(pmapping_groups, live_tensors, pbar=None, parallelize=True)[source]#
- Return type:
- merge_next(right, live_tensors_post_join, live_tensors_with_right, aliased_tensors, compatibility_joined, ignored_resources, permuted_compatibility_left, permuted_compatibility_right, delay=False, _pmapping_row_filter_function=None, _force_allow_invalid_only_for_runtime_test=False, _is_invalid=False)[source]#
- Return type:
- accelforge.mapper.FFM.join_pmappings(pmappings, metrics, require_all_einsums=True, _pmapping_row_filter_function=None, print_progress=True, _skip_invalid=True, _combine_reservations=True, _runtime_log_file=None)[source]#
Joins pmappings into a full mappings for the entire workload. Pmappings can be generated using make_pmappings.
- Parameters:
pmappings (
MultiEinsumPmappings) – The pmappings to join.require_all_einsums (
bool) – If True, all einsums in the workload must have pmappings. If False, only einsums that have pmappings will be included in the final mappings._pmapping_row_filter_function (
Optional[Callable[[Series],bool]]) – A function that takes in a row of the pmapping dataframe and returns True if the row should be included in the final mappings, and False otherwise. If None, all rows will be included.print_progress (
bool) – Whether to print progress of the mapping process, including progress bars.metrics (
Metrics) – The metrics to optimize when joining pmappings._skip_invalid (
bool) – If True, skip joining incompatible pmappings. If False, join all pairs._combine_reservations (
bool) – If True, consolidate reservations to increase pruning effectiveness._runtime_log_file (
str|None) – If set, append per-step runtime as JSON lines to this file.
- Returns:
A Mappings object containing all valid, optimal mappings for the workload.
- Return type:
- accelforge.mapper.FFM.make_pmappings(spec, einsum_names=None, can_combine_multiple_runs=False, cache_dir=None, print_progress=True, print_number_of_pmappings=True, one_pbar_only=False)[source]#
Creates pmappings for a spec. Pmappings must be joined together using join_pmappings to create a full mapping.
- Parameters:
spec (
Spec) – The Spec to generate pmappings for.einsum_names (
list[str] |None) – The einsum names to generate pmappings for. If None, all einsums will be included.can_combine_multiple_runs (
bool) – If True, allows combining multiple make_pmappings runs (e.g.pmappings = make_pmappings(*args_a) | make_pmappings(*args_b)). Set to False for faster execution.cache_dir (
str|None) – The directory to cache pmappings in. If None, no caching will be done.one_pbar_only (
bool) – Whether to only print only a single progress bar. If this is True, then only a progress bar will be created for making tile shapes, which is generally the longest-running part of the mapping process.print_progress (
bool) – Whether to print progress of the mapping process, including progress bars.print_number_of_pmappings (
bool) – Whether to print the number of pmappings for each einsum.Returns – A MultiEinsumPmappings object.
- Return type:
- accelforge.mapper.FFM.map_workload_to_arch(spec, einsum_names=None, can_combine_multiple_runs=False, cache_dir=None, one_pbar_only=False, print_progress=True, print_number_of_pmappings=True, _pmapping_row_filter_function=None)[source]#
Maps a workload to an architecture using the AccelForge Fast and Fusiest Mapper (FFM).
- Parameters:
spec (
Spec) – The Spec to map.einsum_names (
list[str] |None) – The einsum names to map. If None, all einsums will be mapped.can_combine_multiple_runs (
bool) – If True, allows combining multiple make_pmappings runs (e.g.pmappings = make_pmappings(*args_a) | make_pmappings(*args_b)). Set to False for faster execution.cache_dir (
str|None) – The directory to cache pmappings in. If None, no caching will be done.one_pbar_only (
bool) – Whether to only print only a single progress bar. If this is True, then only a progress bar will be created for making tile shapes, which is generally the longest-running part of the mapping process.print_progress (
bool) – Whether to print progress of the mapping process, including progress bars.print_number_of_pmappings (
bool) – Whether to print the number of pmappings for each einsum._pmapping_row_filter_function (
Optional[Callable[[Series],bool]]) – A function that takes in a row of the pmapping dataframe and returns True if the row should be included in the final mappings, and False otherwise. If None, all rows will be included.
- Return type: