pygsti.layouts.prefixtable.PrefixTable#
- class PrefixTable(circuits_to_evaluate, max_cache_size)#
Bases:
objectAn ordered list (“table”) of circuits to evaluate, where common prefixes can be cached.
Creates a “prefix table” for evaluating a set of circuits.
The table is list of tuples, where each element contains instructions for evaluating a particular operation sequence:
(iDest, iStart, tuple_of_following_items, iCache)
Means that circuit[iDest] = cached_circuit[iStart] + tuple_of_following_items, and that the resulting state should be stored at cache index iCache (for later reference as an iStart value). The ordering of the returned list specifies the evaluation order.
iDest is always in the range [0,len(circuits_to_evaluate)-1], and indexes the result computed for each of the circuits.
- Parameters:
circuit_parameter_sensitivities – A map between the circuits in circuits_to_evaluate and the indices of the model parameters to which these circuits depend.
- Returns:
A tuple of (table_contents, cache_size) where table_contents is a list of tuples as given above and cache_size is the total size of the state cache used to hold intermediate results.
- Return type:
tuple
Methods
__init__(circuits_to_evaluate, max_cache_size)Creates a "prefix table" for evaluating a set of circuits.
find_splitting([max_sub_table_size, ...])Find a partition of the indices of this table to define a set of sub-tables with the desire properties.
find_splitting_new([max_sub_table_size, ...])Find a partition of the indices of this table to define a set of sub-tables with the desire properties.
Return the number of state propagation operations (excluding the action of POVM effects) required for the evaluation strategy given by this PrefixTable.
Return the number of state propagation operations per-circuit (excluding the action of POVM effects) required for the evaluation strategy given by this PrefixTable, returned as a dictionary with keys corresponding to circuits and values corresponding to the number of state propagations required for that circuit.
Return the number of state propagation operations per-circuit (excluding the action of POVM effects) required for an evaluation strategy without caching, returned as a dictionary with keys corresponding to circuits and values corresponding to the number of state propagations required for that circuit.
Return the total number of state propagation operations (excluding the action of POVM effects) required for an evaluation strategy without caching.
- find_splitting(max_sub_table_size=None, num_sub_tables=None, cost_metric='size', verbosity=0)#
Find a partition of the indices of this table to define a set of sub-tables with the desire properties.
This is done in order to reduce the maximum size of any tree (useful for limiting memory consumption or for using multiple cores). Must specify either max_sub_tree_size or num_sub_trees.
- Parameters:
max_sub_table_size (int, optional) – The maximum size (i.e. list length) of each sub-table. If the original table is smaller than this size, no splitting will occur. If None, then there is no limit.
num_sub_tables (int, optional) – The maximum size (i.e. list length) of each sub-table. If the original table is smaller than this size, no splitting will occur.
verbosity (int, optional) – How much detail to send to stdout.
- Returns:
A list of sets of elements to place in sub-tables.
- Return type:
list
- find_splitting_new(max_sub_table_size=None, num_sub_tables=None, initial_cost_metric='size', rebalancing_cost_metric='propagations', imbalance_threshold=1.2, minimum_improvement_threshold=0.1, verbosity=0)#
Find a partition of the indices of this table to define a set of sub-tables with the desire properties.
This is done in order to reduce the maximum size of any tree (useful for limiting memory consumption or for using multiple cores). Must specify either max_sub_tree_size or num_sub_trees.
- Parameters:
max_sub_table_size (int, optional) – The maximum size (i.e. list length) of each sub-table. If the original table is smaller than this size, no splitting will occur. If None, then there is no limit.
num_sub_tables (int, optional) – The maximum size (i.e. list length) of each sub-table. If the original table is smaller than this size, no splitting will occur.
imbalance_threshold (float, optional (default 1.2)) – This number serves as a tolerance parameter for a final load balancing refinement to the splitting. The value corresponds to a threshold value of the ratio of the heaviest to the lightest subtree such that ratios below this value are considered sufficiently balanced and processing stops.
minimum_improvement_threshold (float, optional (default 0.1)) – A parameter for the final load balancing refinement process that sets a minimum balance improvement (improvement to the ratio of the sizes of two subtrees) such that a rebalancing step is considered worth performing (even if it would otherwise bring the imbalance parameter described above in imbalance_threshold below the target value) .
verbosity (int, optional (default 0)) – How much detail to send to stdout.
- Returns:
A list of sets of elements to place in sub-tables.
- Return type:
list
- num_state_propagations()#
Return the number of state propagation operations (excluding the action of POVM effects) required for the evaluation strategy given by this PrefixTable.
- num_state_propagations_by_circuit()#
Return the number of state propagation operations per-circuit (excluding the action of POVM effects) required for the evaluation strategy given by this PrefixTable, returned as a dictionary with keys corresponding to circuits and values corresponding to the number of state propagations required for that circuit.
- num_state_propagations_by_circuit_no_caching()#
Return the number of state propagation operations per-circuit (excluding the action of POVM effects) required for an evaluation strategy without caching, returned as a dictionary with keys corresponding to circuits and values corresponding to the number of state propagations required for that circuit.
- num_state_propagations_no_caching()#
Return the total number of state propagation operations (excluding the action of POVM effects) required for an evaluation strategy without caching.