Skip to content

bloqade.qasm3.loads

← Module overview

functionloadssource

bloqade.qasm3.loads

Signature
def loads(qasm: str, *, kernel_name: str = 'main', dialects: ir.DialectGroup | None = None, file: str | None = None, lineno_offset: int = 0, col_offset: int = 0, compactify: bool = True) -> ir.Method

Parse a QASM3 string and return an ir.Method.

Example:

from bloqade import qasm3
method = qasm3.loads('''
OPENQASM 3.0;
qubit[2] q;
bit[2] c;
h q[0];
cx q[0], q[1];
c[0] = measure q[0];
c[1] = measure q[1];
''')

Parameters

NameTypeDefaultDescription
qasmstrrequiredThe OpenQASM 3.0 string to parse.
kernel_namestr'main'
dialectsir.DialectGroup | NoneNone
filestr | NoneNone
lineno_offsetint0
col_offsetint0
compactifyboolTrue

Other Parameters

NameTypeDescription
kernel_namestrThe name of the kernel. Defaults to "main".
dialectsir.DialectGroup | NoneThe dialect group to use. Defaults to `qasm3.main`.
filestr | NoneThe file name for error reporting. Defaults to None.
lineno_offsetintThe line number offset for error reporting. Defaults to 0.
col_offsetintThe column number offset for error reporting. Defaults to 0.
compactifyboolWhether to compactify the output. Defaults to True.

Returns

ir.Method

source