Uop to parallel
GreedyMixin
Bases: MergePolicyABC
Merge policy that greedily merges gates together.
The merge_gates
method will merge policy will try greedily merge gates together.
This policy has a worst case complexity of O(n) where n is the
number of gates in the input iterable.
OptimalMixIn
Bases: MergePolicyABC
Merge policy that merges gates together optimally.
The merge_gates
method will merge policy will try to merge every gate into every
group of gates, terminating when it finds a group that can be merged with the current
gate. This policy has a worst case complexity of O(n^2) where n is the number of gates
in the input iterable.
SimpleMergePolicy
dataclass
SimpleMergePolicy(
address_analysis: Dict[SSAValue, Address],
merge_groups: List[List[Statement]],
group_numbers: Dict[Statement, int],
group_has_merged: Dict[int, bool] = dict(),
)
Bases: MergePolicyABC
General merge policy for merging gates based on their type and arguments.
Base class to implement a merge policy for CZ, U and RZ gates, To completed the policy implement the
merge_gates
class method. This will take an iterable of statements and return a list
of groups of statements that can be merged together. There are two mix-in classes
that can be used to implement the merge_gates
method. The GreedyMixin
will merge
gates together greedily, while the OptimalMixIn
will merge gates together optimally.
address_analysis
instance-attribute
address_analysis: Dict[SSAValue, Address]
Mapping from SSA values to their address analysis results. Needed for rewrites
group_has_merged
class-attribute
instance-attribute
group_has_merged: Dict[int, bool] = field(
default_factory=dict
)
Mapping from group number to whether the group has been merged
group_numbers
instance-attribute
group_numbers: Dict[Statement, int]
Mapping from statements to their group number
merge_groups
instance-attribute
merge_groups: List[List[Statement]]
List of groups of statements that can be merged together