bloqade.qasm2.passes.glob.GlobalToParallel
← Module overview
class
method
sourcemethod
source
classGlobalToParallel¶source
bloqade.qasm2.passes.glob.GlobalToParallel
Bases: Pass
Pass to convert Global gates into parallel gates.
class GlobalToParallelThis pass rewrites the global unitary gate from the qasm2.glob dialect into multiple parallel gates in the qasm2.parallel dialect.
Usage Examples
Section titled “Usage Examples”# Define kernel@qasm2.extendeddef 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])
GlobalToParallel(dialects=main.dialects)(main)
# Run rewriteGlobalToParallel(main.dialects)(main)The qasm2.glob.u statement has been rewritten to individual gates:
qasm2.parallel.u(theta=theta, phi=phi, lam=lam, qargs=[q1[0], q2[0], q2[1]])methodgenerate_rule¶source
bloqade.qasm2.passes.glob.GlobalToParallel.generate_rule
def generate_rule(mt: ir.Method) -> GlobalToParallelRuleParameters
| Name | Type | Description |
|---|---|---|
mt | ir.Method |
Returns
GlobalToParallelRule
methodunsafe_run¶source
bloqade.qasm2.passes.glob.GlobalToParallel.unsafe_run
def unsafe_run(mt: ir.Method) -> abc.RewriteResultParameters
| Name | Type | Description |
|---|---|---|
mt | ir.Method |
Returns
abc.RewriteResult