bloqade.qasm2.passes.parallel.UOpToParallel
← Module overview
class
method
source
classUOpToParallel¶source
bloqade.qasm2.passes.parallel.UOpToParallel
Bases: Pass
Pass to convert single gates into parallel gates.
Signature
class UOpToParallel(merge_policy_type: Type[MergePolicyABC] = SimpleOptimalMergePolicy, rewrite_to_native_first: bool = False)This pass looks for single gates from the qasm2.uop dialect that can be combined
into parallel gates from the qasm2.parallel dialect and performs a rewrite to do so.
Usage Examples
Section titled “Usage Examples”# Define kernel@qasm2.maindef test(): q = qasm2.qreg(4)
theta = 0.1 phi = 0.2 lam = 0.3
qasm2.u(q[1], theta, phi, lam) qasm2.u(q[3], theta, phi, lam) qasm2.cx(q[1], q[3]) qasm2.u(q[2], theta, phi, lam) qasm2.u(q[0], theta, phi, lam) qasm2.cx(q[0], q[2])
# Run rewriteUOpToParallel(main.dialects)(main)The individual qasm2.u statements have now been combined into a single qasm2.parallel.u statement.
qasm2.parallel.u(qargs = [q[0], q[1], q[2], q[3]], theta, phi, lam)qasm2.uop.CX(q[1], q[3])qasm2.uop.CX(q[0], q[2])Parameters
| Name | Type | Default | Description |
|---|---|---|---|
merge_policy_type | Type[MergePolicyABC] | SimpleOptimalMergePolicy | |
rewrite_to_native_first | bool | False |
Attributes
| Name | Type | Default | Description |
|---|---|---|---|
merge_policy_type | Type[MergePolicyABC] | SimpleOptimalMergePolicy | |
rewrite_to_native_first | bool | False | |
constprop | const.Propagate | field(init=False) |
methodunsafe_run¶source
bloqade.qasm2.passes.parallel.UOpToParallel.unsafe_run
def unsafe_run(mt: ir.Method) -> abc.RewriteResultParameters
| Name | Type | Description |
|---|---|---|
mt | ir.Method |
Returns
abc.RewriteResult