bloqade.qasm2.rewrite.uop_to_parallel.SimpleMergePolicy
classSimpleMergePolicy¶source
bloqade.qasm2.rewrite.uop_to_parallel.SimpleMergePolicy
Bases: MergePolicyABC
General merge policy for merging gates based on their type and arguments.
Signature
class SimpleMergePolicy(address_analysis: Dict[ir.SSAValue, address.Address], merge_groups: List[List[ir.Statement]], group_numbers: Dict[ir.Statement, int], group_has_merged: Dict[int, bool] = dict())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.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
address_analysis | Dict[ir.SSAValue, address.Address] | required | |
merge_groups | List[List[ir.Statement]] | required | |
group_numbers | Dict[ir.Statement, int] | required | |
group_has_merged | Dict[int, bool] | dict() |
Attributes
| Name | Type | Default | Description |
|---|---|---|---|
address_analysis | Dict[ir.SSAValue, address.Address] | required | Mapping from SSA values to their address analysis results. Needed for rewrites |
merge_groups | List[List[ir.Statement]] | required | List of groups of statements that can be merged together |
group_numbers | Dict[ir.Statement, int] | required | Mapping from statements to their group number |
group_has_merged | Dict[int, bool] | field(default_factory=dict) | Mapping from group number to whether the group has been merged |
methodsame_id_checker¶source
bloqade.qasm2.rewrite.uop_to_parallel.SimpleMergePolicy.same_id_checker
def same_id_checker(ssa1: ir.SSAValue, ssa2: ir.SSAValue)Parameters
| Name | Type | Description |
|---|---|---|
ssa1 | ir.SSAValue | |
ssa2 | ir.SSAValue |
methodcheck_equiv_args¶source
bloqade.qasm2.rewrite.uop_to_parallel.SimpleMergePolicy.check_equiv_args
Signature
def check_equiv_args(args1: Iterable[ir.SSAValue], args2: Iterable[ir.SSAValue])Parameters
| Name | Type | Description |
|---|---|---|
args1 | Iterable[ir.SSAValue] | |
args2 | Iterable[ir.SSAValue] |
methodcan_merge¶source
bloqade.qasm2.rewrite.uop_to_parallel.SimpleMergePolicy.can_merge
def can_merge(stmt1: ir.Statement, stmt2: ir.Statement) -> boolParameters
| Name | Type | Description |
|---|---|---|
stmt1 | ir.Statement | |
stmt2 | ir.Statement |
Returns
bool
methodfrom_analysis¶source
bloqade.qasm2.rewrite.uop_to_parallel.SimpleMergePolicy.from_analysis
Signature
def from_analysis(dag: StmtDag, address_analysis: Dict[ir.SSAValue, address.Address])Parameters
| Name | Type | Description |
|---|---|---|
dag | StmtDag | |
address_analysis | Dict[ir.SSAValue, address.Address] |
methodmove_and_collect_qubit_list¶source
bloqade.qasm2.rewrite.uop_to_parallel.SimpleMergePolicy.move_and_collect_qubit_list
Signature
def move_and_collect_qubit_list(qargs: List[ir.SSAValue], node: ir.Statement) -> Tuple[ir.SSAValue, ...] | NoneParameters
| Name | Type | Description |
|---|---|---|
qargs | List[ir.SSAValue] | |
node | ir.Statement |
Returns
Tuple[ir.SSAValue, ...] | None
methodrewrite_group_cz¶source
bloqade.qasm2.rewrite.uop_to_parallel.SimpleMergePolicy.rewrite_group_cz
def rewrite_group_cz(node: ir.Statement, group: List[ir.Statement])Parameters
| Name | Type | Description |
|---|---|---|
node | ir.Statement | |
group | List[ir.Statement] |
methodrewrite_group_U¶source
bloqade.qasm2.rewrite.uop_to_parallel.SimpleMergePolicy.rewrite_group_U
def rewrite_group_U(node: ir.Statement, group: List[ir.Statement])Parameters
| Name | Type | Description |
|---|---|---|
node | ir.Statement | |
group | List[ir.Statement] |
methodrewrite_group_u¶source
bloqade.qasm2.rewrite.uop_to_parallel.SimpleMergePolicy.rewrite_group_u
def rewrite_group_u(node: ir.Statement, group: List[ir.Statement])Parameters
| Name | Type | Description |
|---|---|---|
node | ir.Statement | |
group | List[ir.Statement] |
methodrewrite_group_rz¶source
bloqade.qasm2.rewrite.uop_to_parallel.SimpleMergePolicy.rewrite_group_rz
def rewrite_group_rz(node: ir.Statement, group: List[ir.Statement])Parameters
| Name | Type | Description |
|---|---|---|
node | ir.Statement | |
group | List[ir.Statement] |
methodrewrite_group_barrier¶source
bloqade.qasm2.rewrite.uop_to_parallel.SimpleMergePolicy.rewrite_group_barrier
def rewrite_group_barrier(node: uop.Barrier, group: List[uop.Barrier])Parameters
| Name | Type | Description |
|---|---|---|
node | uop.Barrier | |
group | List[uop.Barrier] |