Skip to content

bloqade.qasm2.passes.glob.GlobalToUOP

← Module overview

classGlobalToUOPsource

bloqade.qasm2.passes.glob.GlobalToUOP

Bases: Pass

Pass to convert Global gates into single gates.

class GlobalToUOP

This pass rewrites the global unitary gate from the qasm2.glob 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():
q1 = qasm2.qreg(1)
q2 = qasm2.qreg(2)
theta = 1.3
phi = 1.1
lam = 1.2
qasm2.glob.u(theta=theta, phi=phi, lam=lam, registers=[q1, q2])
GlobalToUOP(dialects=main.dialects)(main)
# Run rewrite
GlobalToUOP(main.dialects)(main)

The qasm2.glob.u statement has been rewritten to individual gates:

qasm2.uop.u(q1[0], theta, phi, lam)
qasm2.uop.u(q2[0], theta, phi, lam)
qasm2.uop.u(q2[1], theta, phi, lam)

methodgenerate_rulesource

bloqade.qasm2.passes.glob.GlobalToUOP.generate_rule

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

Parameters

NameTypeDescription
mtir.Method

Returns

GlobalToUOpRule

source

methodunsafe_runsource

bloqade.qasm2.passes.glob.GlobalToUOP.unsafe_run

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

Parameters

NameTypeDescription
mtir.Method

Returns

abc.RewriteResult

source