Skip to content

qubic.pygsti.transpile

transpile(pygsti_circuit, qubit_map, gateware_twirl=False, delay_before_circuit=0.0005)

Transpile a pygsti circuit into a qubic program.

Parameters:

Name Type Description Default
pygsti_circuit Circuit

circuit to transpile

required
qubit_map List[str] | Dict[int, str]

Maps pygsti quantum registers to physical qubits. If list of physical qubits, register 0 is assumed to correspond to the first element, etc. If dict, register -> qubit mapping is given directly as key value pairs.

required
gateware_twirl bool
False
delay_before_circuit float

relaxation delay to insert at the beginning of each circuit

0.0005

Returns:

Name Type Description
qubic_circuits List[Dict]

transpiled qubic circuit

Source code in qubic/pygsti/transpiler.py
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
def transpile(pygsti_circuit: pygsti.circuits.Circuit, 
              qubit_map: List[str] | Dict[int, str], 
              gateware_twirl: bool = False,
              delay_before_circuit: float = 500.e-6) -> List[Dict]:
    """
    Transpile a pygsti circuit into a qubic program. 

    Parameters
    ----------
    pygsti_circuit: pygsti.circuits.Circuit
        circuit to transpile
    qubit_map: List[str] | Dict[int, str]
        Maps pygsti quantum registers to physical qubits. If list
        of physical qubits, register 0 is assumed to correspond to the
        first element, etc. If dict, register -> qubit mapping is given
        directly as key value pairs.
    gateware_twirl: bool = False
    delay_before_circuit: float = 500.e-6
        relaxation delay to insert at the beginning of each circuit

    Returns
    -------
    qubic_circuits: List[Dict]
        transpiled qubic circuit 
    """
    qubic_circuit = list()
    qubic_circuit.append({'name': 'delay', 't': delay_before_circuit})
    if gateware_twirl:
        qubits = [qubit_map[qid] for qid in pygsti_circuit.line_labels]
        qubic_circuit.append({'name': 'begin_rc', 'qubits': qubits})
    for layer in pygsti_circuit:
        qubic_circuit.extend(_parse_layer(layer, qubit_map))
        qubic_circuit.append({'name': 'barrier'})
    if gateware_twirl:
        qubits = [qubit_map[qid] for qid in pygsti_circuit.line_labels]
        qubic_circuit.append({'name': 'end_rc', 'qubits': qubits})
    for qid in pygsti_circuit.line_labels:
        qubic_circuit.append({'name': 'read', 'qubit': qubit_map[qid]})
    return qubic_circuit