Skip to content

bloqade.qasm2.loads

← Module overview

functionloadssource

bloqade.qasm2.loads

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

Loads a QASM2 string and returns the corresponding kernel object.

Example:

from bloqade import qasm2
method = qasm2.loads('''
OPENQASM 2.0;
qreg q[2];
creg c[2];
h q[0];
cx q[0], q[1];
measure q[0] -> c[0];
''')

Parameters

NameTypeDefaultDescription
qasmstrrequiredThe QASM2 string to load.
kernel_namestr'main'
dialectsir.DialectGroup | NoneNone
returnsstr | NoneNone
globalsdict[str, Any] | NoneNone
filestr | NoneNone
lineno_offsetint0
col_offsetint0
compactifyboolTrue

Other Parameters

NameTypeDescription
kernel_namestrThe name of the kernel to load. Defaults to "main".
dialectsir.DialectGroup | NoneThe dialects to use. Defaults to `qasm2.main`.
returnsstr | NoneThe return type of the kernel. Defaults to None.
globalsdict[str, Any] | NoneThe global variables to use. Defaults to None.
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[[], None]

source