Skip to content

bloqade.qasm2.passes.parallel.ParallelToUOp

← Module overview

classParallelToUOpsource

bloqade.qasm2.passes.parallel.ParallelToUOp

Bases: Pass

Pass to convert parallel gates into single gates.

class ParallelToUOp

This pass rewrites any parallel gates from the qasm2.parallel dialect into multiple single gates in the qasm2.uop dialect, bringing the program closer to conforming to standard QASM2 syntax.

# Define kernel
@qasm2.extended
def main():
q = qasm2.qreg(4)
qasm2.parallel.cz(ctrls=[q[0], q[2]], qargs=[q[1], q[3]])
# Run rewrite
ParallelToUOp(main.dialects)(main)

The qasm2.parallel.cz statement has been rewritten to individual gates:

qasm2.uop.cz(ctrl=q[0], qarg=q[1])
qasm2.uop.cz(ctrl=q[2], qarg=q[3])

methodgenerate_rulesource

bloqade.qasm2.passes.parallel.ParallelToUOp.generate_rule

def generate_rule(mt: ir.Method) -> ParallelToUOpRule

Parameters

NameTypeDescription
mtir.Method

Returns

ParallelToUOpRule

source

methodunsafe_runsource

bloqade.qasm2.passes.parallel.ParallelToUOp.unsafe_run

def unsafe_run(mt: ir.Method) -> abc.RewriteResult

Parameters

NameTypeDescription
mtir.Method

Returns

abc.RewriteResult

source