def Backend_Topology(name, refresh, show=True, datatime=False):
    '''Funzione che mi restituisce tutte le possibili coppie tra gli slot fisici
    in un dizionario, i cui valori sono una lista contenente error gate ed gate length(ns) del cx tra la coppia,
    i valori sono fissati a  100000, se la coppia di slot non è topologicamente legata
    ______________________________________________________________________________________________________
    poni refresh = True per aggiornare ottenere ad ogni chiamata i dati più aggiornati di calibrazione

    name = Nome del backend
    '''
    Topology_properties = {}
    impossible_length = 100000
    impossible_error = 100000
    provider = IBMQ.get_provider(hub='ibm-q')
    provider.backends(simulator=False)
    backend = provider.get_backend(name)
    #print(backend.configuration().basis_gates)

    if show == True:
        plot_gate_map(backend).show()

    coupling_map = IBMQBackend.configuration(backend).to_dict()['coupling_map']
    if datatime != False:
        prp = backend.properties(datetime=datatime).to_dict()
    else:
        prp = backend.properties(refresh=refresh).to_dict()

    Topology_properties['backend_name'] = prp['backend_name']
    Topology_properties['last_update_date'] = prp['last_update_date']

    gates = prp['gates']
    cx_list = []
    for i in range(len(gates)):
        if gates[i]['gate'] == 'cx':
            cx_list.append([gates[i]])

    coupling = {}
    for i in range(len(prp['qubits'])):
        for j in range(len(prp['qubits'])):
            if i != j:
                string_error = 'edge_error_' + str(i) + str(j)
                string_length = 'edge_length_' + str(i) + str(j)
                if not check_in_list([i, j],
                                     coupling_map):  #se la lista è vuota
                    coupling[string_error] = impossible_error
                    coupling[string_length] = impossible_length
                else:
                    for ind in check_in_list([i, j], coupling_map):
                        coupling[string_error] = cx_list[ind][0]['parameters'][
                            0]['value']
                        coupling[string_length] = cx_list[ind][0][
                            'parameters'][1]['value']

    Topology_properties['coupling'] = coupling

    return Topology_properties
Exemplo n.º 2
0
for n in range(0, len(available_backends)):
    backend = provider.get_backend(str(available_backends[n]))
    print("{0:20} {1:<10}".format(backend.name(),
                                  backend.configuration().n_qubits))

# Select a backend or go for the least busy backend with more than 1 qubits
backend_input = input("Enter the name of a backend, or X for the least busy:")
if backend_input not in ["X", "x"]:
    backend = provider.get_backend(backend_input)
else:
    backend = least_busy(
        provider.backends(filters=lambda b: b.configuration().n_qubits > 1 and
                          b.status().operational))
# Display the gate and error map for the backend.
print("\nQubit data for backend:", backend.status().backend_name)

display(plot_gate_map(backend, plot_directed=True))
display(plot_error_map(backend))

# Create and transpile a 2 qubit Bell circuit
qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)

display(qc.draw('mpl'))
qc_transpiled = transpile(qc, backend=backend, optimization_level=3)
display(qc_transpiled.draw('mpl'))

# Display the circuit layout for the backend.
display(plot_circuit_layout(qc_transpiled, backend, view='physical'))
Exemplo n.º 3
0
def save_gate_map(backend):
    return (
        plot_gate_map(backend).savefig(backend.configuration().backend_name +
                                       ".png"))
Exemplo n.º 4
0
#########################################################
# #Circuit

# Quantum Circuit
q = QuantumRegister(nb_qubits + nb_decoherence, "game")
c = ClassicalRegister(nb_qubits + nb_decoherence)

qc = QuantumCircuit(q, c)

# print("00 --A-- 01 --B-- 02 --C-- 03 --D-- 04 --E-- 05 --F-- 06\n"
#       " |        |        |        |        |        |        |\n"
#       " U        T        S        R        Q        P        O\n"
#       " |        |        |        |        |        |        |\n"
#       "14 --N-- 13 --M-- 12 --L-- 11 --K-- 10 --J-- 09 --I-- 08 --H-- 07")

plot_gate_map(quantum_computer)
# plt.show()

# Make random pairing
qubit_decoherence = nb_qubits
for i in range(0, nb_qubits):
    if i % 2 == 0:
        qc.rx(math.pi / 2, q[i])
        qc.cx(q[i], q[i + 1])
        qc.ccx(q[i], q[i + 1], q[qubit_decoherence])
        qubit_decoherence += 1

qc.measure(range(nb_qubits + nb_decoherence),
           range(nb_qubits + nb_decoherence))

# # Drawing the circuit