bloqade.qasm2.emit.target.QASM2
← Module overview
class
method
sourcemethod
source
classQASM2¶source
bloqade.qasm2.emit.target.QASM2
QASM2 target for Bloqade kernels.
Signature
class QASM2(qelib1: bool = True, allow_parallel: bool = False, allow_global: bool = False, custom_gate: bool = True, unroll_ifs: bool = True, allow_noise: bool = True)QASM2 target that accepts a Bloqade kernel and produces an AST that you can then obtain a string for printing or saving as a file.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
qelib1 | bool | True | Include the `include "qelib1.inc"` line in the resulting QASM2 AST that's submitted to qBraid. Defaults to `True`. |
allow_parallel | bool | False | Allow parallel gate in the resulting QASM2 AST. Defaults to `False`. In the case its False, and the input kernel uses parallel gates, they will get rewrite into uop gates. |
allow_global | bool | False | Allow global gate in the resulting QASM2 AST. Defaults to `False`. In the case its False, and the input kernel uses global gates, they will get rewrite into parallel gates. If both `allow_parallel` and `allow_global` are False, the input kernel will be rewritten to use uop gates. |
custom_gate | bool | True | Include the custom gate definitions in the resulting QASM2 AST. Defaults to `True`. If `False`, all the qasm2.gate will be inlined. |
unroll_ifs | bool | True | Unrolls if statements with multiple qasm2 statements in the body in order to produce valid qasm2 output, which only allows a single operation in an if body. Defaults to `True`. |
allow_noise | bool | True |
Attributes
| Name | Type | Default | Description |
|---|---|---|---|
main_target | — | qasm2.main | |
gate_target | — | qasm2.gate | |
qelib1 | — | qelib1 | |
custom_gate | — | custom_gate | |
allow_parallel | — | allow_parallel | |
allow_global | — | allow_global | |
unroll_ifs | — | unroll_ifs |
methodemit¶source
bloqade.qasm2.emit.target.QASM2.emit
def emit(entry: ir.Method) -> ast.MainProgramEmit a QASM2 AST from the Bloqade kernel.
Parameters
| Name | Type | Description |
|---|---|---|
entry | ir.Method | The Bloqade kernel to convert to the QASM2 AST |
Returns
ast.MainProgramA QASM2 AST object
methodemit_str¶source
bloqade.qasm2.emit.target.QASM2.emit_str
def emit_str(entry: ir.Method) -> strEmit a QASM2 AST from the Bloqade kernel.
Parameters
| Name | Type | Description |
|---|---|---|
entry | ir.Method | The Bloqade kernel to convert to the QASM2 AST |
Returns
strstr: A string with the QASM2 representation of the kernel