Closed yangjy0826 closed 5 years ago
Hi,
Quantum Chips that exist now are noisy and discrepancies between simulators and real devices are expected. Have you tried to run your circuits on other real device backends? And on other set of qubits within the same backend to see how the results change (being better or worse)?
Hi, thank you for your reply. I find out that the result on quantum chip QX2 (5-quibit) has the best result, which is around 0.5. But for QX4 (5-qubit) and the 16-qubit quantum chip, the result is even worse, which sometimes can be more than 1. If I take the connections between qubits into consideration and try QX2 again (I modified the quantum circuit, making controlled gates only exist on the connections, and this process makes the circuit deeper), I will get a worse result. Does the depth of quantum circuit affect the result?
Yes, the deeper the circuit the more error we get as gates are very noisy and decoherence time is limited. qiskit-ignis is the package that is used for easing the error mitigation.
I am relieved that your circuit runs well and it is not really a bug. Instead, it is a limitation of NISQ devices. I am closing this issue, but feel free to reopen if necessary.
OK! Thank you for your suggestion.
Informations
What is the current behavior?
When I simulate the HHL algorithm provided by the teach_me_qiskit (link) locally, I had a same result with the tutorial. The ratio (the variable 'p' in the code) of the probability of getting '1000' and '1100' is around 0.25.
But when I run the same quantum circuit on a remote quantum chip, I found the ratio is very different from the simulation result, which can take the value between 0.5 to 0.8.
The number of slots for both cases are set to
Steps to reproduce the problem
import Qiskit
from qiskit import BasicAer, execute, IBMQ from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
import basic plot tools
from qiskit.tools.visualization import plot_histogram
create Quantum Register called "qr" with 4 qubits
qr = QuantumRegister(4, name="qr")
create Quantum Register called "cr" with 4 qubits
cr = ClassicalRegister(4, name="cr")
Creating Quantum Circuit called "qc" involving your Quantum Register "qr"
and your Classical Register "cr"
qc = QuantumCircuit(qr, cr, name="solve_linear_sys")
Set the input|b> state"
qc.x(qr[2])
Set the phase estimation circuit
qc.h(qr[0]) qc.h(qr[1]) qc.u1(pi, qr[0]) qc.u1(pi/2, qr[1]) qc.cx(qr[1], qr[2])
The quantum inverse Fourier transform
qc.h(qr[0]) qc.cu1(-pi/2, qr[0], qr[1]) qc.h(qr[1])
R(lamda^-1) Rotation
qc.x(qr[1]) qc.cu3(pi/16, 0, 0, qr[0], qr[3]) qc.cu3(pi/8, 0, 0, qr[1], qr[3])
Uncomputation
qc.x(qr[1]) qc.h(qr[1]) qc.cu1(pi/2, qr[0], qr[1]) qc.h(qr[0])
qc.cx(qr[1], qr[2]) qc.u1(-pi/2, qr[1]) qc.u1(-pi, qr[0])
qc.h(qr[1]) qc.h(qr[0])
qc.measure(qr, cr)
Use Aer's qasm_simulator
backend_sim = BasicAer.get_backend('qasm_simulator')
Execute the circuit on the qasm simulator.
We've set the number of repeats of the circuit to be 1024, which is the default.
job_sim = execute(qc, backend_sim, shots=8192)
Grab the results from the job.
result_sim = job_sim.result()
counts = result_sim.get_counts(qc) print(counts) x1_square = counts['1000'] x2_square = counts['1100'] p = x1_square/x2_square print('probability of state 1000:', x1_square) print('probability of state 1100:', x2_square) print('the ratio of two probabilities', p) plot_histogram(result_sim.get_counts())
IBMQ.load_accounts() # If you don't load your account, you cannot get access to the IBM remote quantum chip
from qiskit.providers.ibmq import least_busy
large_enough_devices = IBMQ.backends(filters=lambda x: x.configuration().n_qubits > 3 and not x.configuration().simulator) backend = least_busy(large_enough_devices) print("The best backend is " + backend.name())
from qiskit.tools.monitor import job_monitor shots = 8192 # Number of shots to run the program (experiment); maximum is 8192 shots. max_credits = 3 # Maximum number of credits to spend on executions.
job_exp = execute(qc, backend=backend, shots=shots, max_credits=max_credits) job_monitor(job_exp)
result_exp = job_exp.result() counts = result_exp.get_counts(qc) print(counts) x1_square = counts['1000'] x2_square = counts['1100'] p = x1_square/x2_square print('probability of state 1000:', x1_square) print('probability of state 1100:', x2_square) print('the ratio of two probabilities', p) plot_histogram(result_exp.get_counts(qc))