2
$\begingroup$

After several atempts, I cannot mitigate the error when running the code on a NISQ, via the qiskit library (more specifically on the 'ibmq_16_melbourne').

I've already mapped the connected qubits and simplified my circuit to the basic gates accepted by the backend.

The code is as it follows:

from qiskit import *
from qiskit.circuit.library.standard_gates import HGate
from qiskit.circuit.library import QFT, WeightedAdder
from qiskit.visualization import plot_histogram

def qft_dagger(qc, n):
    """n-qubit QFTdagger the first n qubits in circ"""
    # Don't forget the Swaps!
    for qubit in range(n//2):
        qc.swap(qubit, n-qubit-1)
    for j in range(n):
        for m in range(j):
            qc.cp(-math.pi/float(2**(j-m)), m, j)
        qc.h(j)

IBMQ.load_account()
provider = IBMQ.get_provider('ibm-q')
#backend = Aer.get_backend('qasm_simulator')
shots = 8192

#INFO CIRC
nCountingQ = 3
w = 3.8

#LISTS

tempo = []
eigenvalues = []
allCircs = []

#DEF TEMPO
t0 = 0
tmax = 2
nrInvervalos = 70
deltaT = tmax/nrInvervalos
t = t0

qr = QuantumRegister(4,'qr')
cr = ClassicalRegister(3,'cr')
#CICLO

while t<tmax:
    
    circ = QuantumCircuit(qr,cr)
    theta = 2*w*t
    #HADAMARD
    for i in range(nCountingQ):
        circ.h(i)
        
    #UNITARY 
    repetitions = 1
    for counting_qubit in range(nCountingQ):
        for i in range(repetitions):
            circ.rz(theta/2,nCountingQ)
            circ.cx(counting_qubit,nCountingQ)
            circ.rz(-theta/2,nCountingQ)
            circ.cx(counting_qubit,nCountingQ)
        repetitions *= 2
    
    #QFT
    qft_dagger(circ,nCountingQ)
    
    #MEASUREMENT
    for i in range(nCountingQ):
        circ.measure(i,i)
    #ATUALIZAR TEMPOS
    tempo.append(t)
    t+=deltaT
    
    #ADICIONAR CIRC A TODOS
    allCircs.append(circ)

And I execute the code with the following command:

job = execute(allCircs, backend = backend, shots = shots, initial_layout={qr[0]:4, qr[1]:9, qr[2]:11, qr[3]:10})

Finally, I process the data with a weighted average:

answer = job.result().get_counts()

#MEDIA PESADA
for x in answer:
    #print(x)
    numerador = 0
    denominador = 0
    for key,value in x.items():
        key = int(key,2)
        numerador += (key/2**nCountingQ)*value
        denominador += value
        
    media_pesada = numerador/denominador
    eigenvalues.append(media_pesada)

The results I should've be obtaining are: enter image description here

But what I'm consistently obtaining is (extremely random): enter image description here

Unfortunaly, I couldn't find the correct information to help me mitigate this specific errors

Thank you for your time!

$\endgroup$
6
  • $\begingroup$ You can try to perform error mitigation on your circuit... this might help a tiny bit but I wouldn't expect much or any improvement given the type of circuits you are dealing with. Your circuits when transpile into the hardware is just too long... errors will accumulate to the point that whatever your read out is just noise :) $\endgroup$ – KAJ226 May 31 at 19:26
  • $\begingroup$ Thats also an observation I had in account. Whats funny is that even with just 2 controll qubits for the QPE, it still shows this results... $\endgroup$ – Diogo Gonçalves May 31 at 21:48
  • $\begingroup$ remember that the those controlled operations when decomposed into native gates create a longer circuit. $\endgroup$ – KAJ226 May 31 at 23:42
  • $\begingroup$ Did you have a look at your circuit after it has been transpiled and mapped to the qubits? Based on the Quantum Volume (which is only 8 for Melbourne) you can estimate whether your circuit should work. Also you can drop the swaps in the QFT if you apply it upside down and reverse the bits in the measurement :) Does the expected result come from using a simulator instead of a backend? $\endgroup$ – Cryoris Jun 1 at 6:22
  • $\begingroup$ @KAJ226 Fortunatly I decomposed the Controled Rz gates I used into a Rz + Cnot, whose are the ones accepted by the backend $\endgroup$ – Diogo Gonçalves Jun 1 at 9:14
1
$\begingroup$

Even I have implemented Iterative QPE and the basic QPE in qiskit using approximately the same approach. The point where my simulations also started producing random results was as the phase estimation got beyond 4 qubit precision.

The question of how we mitigate this error is actually a bit wrong to ask at this point because we also need to start looking at the $T_{2}$ time of the qubits on which our circuit is being executed.

Imagine that the coherence time of the device is $100 \mu s$ and average gate time is $1 \mu s$. If you have the depth of your circuit as > 100, the qubits decohere and that is why you are getting random results. I don't really think there is anything we could do to mitigate the errors as the device does not stay quantum beyond a certain point.

At least that is what I could make of it! This is my simulation result for the iterative QPE on ibmq_casablanca as the precision increased to beyond 3 qubits :) QPE plot

New contributor
Harshit Gupta is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
$\endgroup$
2
  • $\begingroup$ Thank you for your answer! In the mean time, I've tried to run with just 2 qubits for precision + 1 for initial state. Therefore, I was able to choose a backend (ibmq_5_yorktown) which has the least gate error and coherence time from all available backends. That lead me to gather some much better results $\endgroup$ – Diogo Gonçalves Jun 8 at 9:28
  • $\begingroup$ Well, I'm glad to be of help :) $\endgroup$ – Harshit Gupta Jun 8 at 15:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.