Saya mendapatkan kode kuantum berikut menggunakan QISKit (berdasarkan hello_quantum.py
):
import sys, os
from qiskit import QuantumProgram, QISKitError, RegisterSizeError
# Create a QuantumProgram object instance.
Q_program = QuantumProgram()
try:
import Qconfig
Q_program.set_api(Qconfig.APItoken, Qconfig.config["url"])
except:
offline = True
print("WARNING: There's no connection with IBMQuantumExperience servers.");
print("The backends available for use are: {}\n".format(",".join(Q_program.available_backends())))
backend = 'ibmqx5'
try:
# Create a Quantum Register called "qr" with 2 qubits.
qr = Q_program.create_quantum_register("qr", 2)
# Create a Classical Register called "cr" with 2 bits.
cr = Q_program.create_classical_register("cr", 2)
# Create a Quantum Circuit called "qc". involving the Quantum Register "qr"
# and the Classical Register "cr".
qc = Q_program.create_circuit("bell", [qr], [cr])
# Add the H gate in the Qubit 0, putting this qubit in superposition.
qc.h(qr[0])
# Add the CX gate on control qubit 0 and target qubit 1, putting
# the qubits in a Bell state
qc.cx(qr[0], qr[1])
# Add a Measure gate to see the state.
qc.measure(qr, cr)
# Compile and execute the Quantum Program.
result = Q_program.execute(["bell"], backend=backend, shots=1024, seed=1)
# Show the results.
print(result)
print(result.get_data("bell"))
except QISKitError as ex:
print('There was an error in the circuit!. Error = {}'.format(ex))
except RegisterSizeError as ex:
print('Error in the number of registers!. Error = {}'.format(ex))
Saya set saya APItoken
di Qconfig.py
sebagai:
APItoken = 'XXX'
config = {
'url': 'https://quantumexperience.ng.bluemix.net/api',
}
Namun, kode gagal dengan kesalahan berikut:
The backends available for use are: ibmqx2,ibmqx5,ibmqx4,ibmqx_hpc_qasm_simulator,ibmqx_qasm_simulator,local_qasm_simulator,local_clifford_simulator,local_qiskit_simulator,local_unitary_simulator
ERROR
There was an error in the circuit!. Error = 'QISkit Time Out'
Saya sudah menguji keduanya ibmqx4
dan ibmqx5
, masalah yang sama. Saya dapat melihat bahwa mereka aktif di / qx / devices .
Apa artinya? Apakah itu berarti server Q IBM sedang down, atau program terlalu besar untuk dijalankan? Atau ada hal lain yang terjadi? Dengan kata lain, apa yang harus saya lakukan untuk menjalankan program Hello Quantum sederhana pada server kuantum IBM?