Skip to content

bloqade.qasm2.rewrite.uop_to_parallel.SimpleMergePolicy

← Module overview

classSimpleMergePolicysource

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

NameTypeDefaultDescription
address_analysisDict[ir.SSAValue, address.Address]required
merge_groupsList[List[ir.Statement]]required
group_numbersDict[ir.Statement, int]required
group_has_mergedDict[int, bool]dict()

Attributes

NameTypeDefaultDescription
address_analysisDict[ir.SSAValue, address.Address]requiredMapping from SSA values to their address analysis results. Needed for rewrites
merge_groupsList[List[ir.Statement]]requiredList of groups of statements that can be merged together
group_numbersDict[ir.Statement, int]requiredMapping from statements to their group number
group_has_mergedDict[int, bool]field(default_factory=dict)Mapping from group number to whether the group has been merged

methodsame_id_checkersource

bloqade.qasm2.rewrite.uop_to_parallel.SimpleMergePolicy.same_id_checker

def same_id_checker(ssa1: ir.SSAValue, ssa2: ir.SSAValue)

Parameters

NameTypeDescription
ssa1ir.SSAValue
ssa2ir.SSAValue
source

methodcheck_equiv_argssource

bloqade.qasm2.rewrite.uop_to_parallel.SimpleMergePolicy.check_equiv_args

Signature
def check_equiv_args(args1: Iterable[ir.SSAValue], args2: Iterable[ir.SSAValue])

Parameters

NameTypeDescription
args1Iterable[ir.SSAValue]
args2Iterable[ir.SSAValue]
source

methodcan_mergesource

bloqade.qasm2.rewrite.uop_to_parallel.SimpleMergePolicy.can_merge

def can_merge(stmt1: ir.Statement, stmt2: ir.Statement) -> bool

Parameters

NameTypeDescription
stmt1ir.Statement
stmt2ir.Statement

Returns

bool

source

methodfrom_analysissource

bloqade.qasm2.rewrite.uop_to_parallel.SimpleMergePolicy.from_analysis

Signature
def from_analysis(dag: StmtDag, address_analysis: Dict[ir.SSAValue, address.Address])

Parameters

NameTypeDescription
dagStmtDag
address_analysisDict[ir.SSAValue, address.Address]
source

methodmove_and_collect_qubit_listsource

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, ...] | None

Parameters

NameTypeDescription
qargsList[ir.SSAValue]
nodeir.Statement

Returns

Tuple[ir.SSAValue, ...] | None

source

methodrewrite_group_czsource

bloqade.qasm2.rewrite.uop_to_parallel.SimpleMergePolicy.rewrite_group_cz

def rewrite_group_cz(node: ir.Statement, group: List[ir.Statement])

Parameters

NameTypeDescription
nodeir.Statement
groupList[ir.Statement]
source

methodrewrite_group_Usource

bloqade.qasm2.rewrite.uop_to_parallel.SimpleMergePolicy.rewrite_group_U

def rewrite_group_U(node: ir.Statement, group: List[ir.Statement])

Parameters

NameTypeDescription
nodeir.Statement
groupList[ir.Statement]
source

methodrewrite_group_usource

bloqade.qasm2.rewrite.uop_to_parallel.SimpleMergePolicy.rewrite_group_u

def rewrite_group_u(node: ir.Statement, group: List[ir.Statement])

Parameters

NameTypeDescription
nodeir.Statement
groupList[ir.Statement]
source

methodrewrite_group_rzsource

bloqade.qasm2.rewrite.uop_to_parallel.SimpleMergePolicy.rewrite_group_rz

def rewrite_group_rz(node: ir.Statement, group: List[ir.Statement])

Parameters

NameTypeDescription
nodeir.Statement
groupList[ir.Statement]
source

methodrewrite_group_barriersource

bloqade.qasm2.rewrite.uop_to_parallel.SimpleMergePolicy.rewrite_group_barrier

def rewrite_group_barrier(node: uop.Barrier, group: List[uop.Barrier])

Parameters

NameTypeDescription
nodeuop.Barrier
groupList[uop.Barrier]
source