Skip to content

Dashboard Core — QASM Library

Real, standard OpenQASM 2.0 circuits offered as Composer presets — textbook examples (Bell pair, GHZ, W-state) and dense_evolution's own gate library exercised end to end, not synthetic placeholder text.

qasm_library

Real, standard OpenQASM 2.0 circuits offered as Composer presets -- textbook examples (Bell pair, GHZ, W-state) and dense_evolution's own real circuit generators (QFT, random circuit), not synthetic results. The Composer runs every one of these through the real engine just like any custom circuit typed in by hand.

gate_tuples_to_qasm

gate_tuples_to_qasm(
    ops, n_qubits: int, measure: bool = True
) -> str

Converts a dense_evolution gate-tuple circuit (the format de.qft/de.ghz_state/de.random_circuit/... all return) into real OpenQASM 2.0 text, so any of dense_evolution's own circuit generators can be offered as a Composer preset without hand-transcribing gates.

Source code in tools/dashboard_core/qasm_library.py
def gate_tuples_to_qasm(ops, n_qubits: int, measure: bool = True) -> str:
    """Converts a dense_evolution gate-tuple circuit (the format
    de.qft/de.ghz_state/de.random_circuit/... all return) into real
    OpenQASM 2.0 text, so any of dense_evolution's own circuit generators
    can be offered as a Composer preset without hand-transcribing gates."""
    lines = ['OPENQASM 2.0;', 'include "qelib1.inc";', f'qreg q[{n_qubits}];']
    if measure:
        lines.append(f'creg c[{n_qubits}];')
    for op in ops:
        name = op[0]
        if name in _ONE_QUBIT_STATIC:
            lines.append(f'{name} q[{op[1]}];')
        elif name in _ONE_QUBIT_PARAM:
            lines.append(f'{name}({op[2]}) q[{op[1]}];')
        elif name in _TWO_QUBIT_STATIC:
            lines.append(f'{name} q[{op[1]}],q[{op[2]}];')
        elif name in _TWO_QUBIT_PARAM:
            lines.append(f'{name}({op[3]}) q[{op[1]}],q[{op[2]}];')
        elif name in _THREE_QUBIT_STATIC:
            lines.append(f'{name} q[{op[1]}],q[{op[2]}],q[{op[3]}];')
        else:
            raise ValueError(f"gate_tuples_to_qasm: unrecognized gate {name!r}")
    if measure:
        lines.append('measure q -> c;')
    return '\n'.join(lines) + '\n'

See also: dense_evolution.parser.QASMParser, which these presets are meant to be fed into.