1
$\begingroup$

I am trying to implement Quantum Teleportation Algorithm on an actual device, I am using IBM-Q Jupyter notebook for the same purpose.

The code is as follows:

import qiskit as qk
from qiskit import ClassicalRegister, QuantumRegister, QuantumCircuit
from qiskit import execute, Aer
from qiskit import IBMQ
from qiskit.visualization import plot_histogram
%config InlineBackend.figure_format = 'svg'

def apply_secret_unitary(secret_unitary, qubit, quantum_circuit, dagger):
  functionmap = {
    'x': quantum_circuit.x,
    'y': quantum_circuit.y,
    'z': quantum_circuit.z,
    'h': quantum_circuit.h,
    't': quantum_circuit.t
  }
  if dagger == 1:
    functionmap['t'] = quantum_circuit.tdg

  if dagger:
    [functionmap[unitary](qubit) for unitary in secret_unitary]
  else:
    [functionmap[unitary](qubit) for unitary in secret_unitary[::-1]]

secret_unitary = 'hzxhzhx'

qc = QuantumCircuit(3, 1)
'''
qc[0] -> The qubit to be teleported
qc[1] -> entangled state, possessed by alice
qc[2] -> entangled state, possessed by bob
'''

apply_secret_unitary(secret_unitary, qc.qubits[0], qc, dagger = 0) 
qc.barrier()
qc.h(1)
qc.cx(1, 2)
qc.barrier()
qc.cx(0, 1)
qc.h(0)
qc.cx(1, 2)
qc.cz(0, 2)
apply_secret_unitary(secret_unitary, qc.qubits[0], qc, dagger = 1)
qc.barrier()
qc.measure(2, 0);
qc.draw(output= 'mpl')

IBMQ.load_account()
provider = IBMQ.get_provider(hub='ibm-q')
provider.backends()

from qiskit.providers.ibmq import least_busy
backend = least_busy(provider.backends(filters = lambda b: b.configuration().n_qubits >= 3 and 
                                       not b.configuration().simulator and 
                                       b.status().operational == True))
job_exp = execute(qc, backend = backend, shots = 8192)
exp_result = job_exp.result()

exp_measurement_result = exp_result.get_counts()
print(exp_measurement_result)
plot_histogram(exp_measurement_result)

The error which the following code gives is:

IBMQJobApiError: "'400 Client Error: Bad Request for url: https://api.quantum-computing.ibm.com/api/Network/ibm-q/Groups/open/Projects/main/Jobs/5e73033786653e0018a2364e/resultDownloadUrl. Cannot get presigned download url., Error code: 3202.'"

I've tried deleting my account and load a new account using a newly generated token but that doesn't seem to work either.

Clicking the link in the error gives the following error:

OPERATION_NOT_AVAILABLE
404 Shared class "Hub" has no method handling GET /ibm-q/Groups/open/Projects/main/Jobs/5e72ff01121d5e0018bfe775/resultDownloadUrl.
code: 2411

perhaps, I am using a method which is now deprecated. How can I tackle this situation?

$\endgroup$
  • $\begingroup$ Can you try removing the barriers? $\endgroup$ – met927 Mar 19 at 9:20
  • $\begingroup$ It remains the same. $\endgroup$ – IE Irodov Mar 19 at 9:57
1
$\begingroup$

I'm not sure what had caused the problem but I was able to solve it and most likely know what the problem was.

Consider these two lines from my code above:

job_exp = execute(qc, backend = backend, shots = 8192)
exp_result = job_exp.result()

Problem with the above lines is that we are not waiting for the actual quantum device to compute and send over the data. To avoid this, we can use a method called job_monitor from qiskit.tools.monitor which when called, let us know whether the job is complete or not.

After it displays that the job has successfully run we should expect value from result

Following is the code for the same purpose:

IBMQ.load_account()
provider = IBMQ.get_provider(hub = 'ibm-q')
backend = least_busy(provider.backends(filters = lambda x: x.configuration().n_qubits >= 3
                                      and not x.configuration().simulator
                                      and x.status().operational == True))
print('least busy backend: ', backend)
from qiskit.tools.monitor import job_monitor
job = execute(qc, backend = backend, shots = 8192)
job_monitor(job)

Proceed further only after the output to the above cell becomes 'Job Status: job has successfully run' which may take some time depending upon the value of shots.

After that, you can call result() and get_counts() to get the values:

result = job.result()
counts = result.get_counts()
| improve this answer | |
$\endgroup$
1
$\begingroup$

EDIT: I believe this is solved in @IEIrodov's answer below.

I'm not sure what's causing the issue, but based on similar issues on the qiskit slack channel, I don't think it's something you're doing.

As a workaround, try running:

exp_result = job_exp.result()
exp_measurement_result = exp_result.get_counts()
print(exp_measurement_result)
plot_histogram(exp_measurement_result)

Separately in a new cell.

(also, if you're trying to verify teleportation, you need to apply_secret_unitary on line 42 to qc.qubits[2] instead of qc.qubits[0]).

| improve this answer | |
$\endgroup$
  • $\begingroup$ That's what I think as well, it doesn't seem to work that way either. Also, you're right about using qubit_2, that's a silly mistake on my side. thanks! $\endgroup$ – IE Irodov Mar 19 at 10:00
  • $\begingroup$ Okay, sorry I wasn't able to help more. Hopefully the issue will be fixed soon. $\endgroup$ – Frank Mar 20 at 11:26
  • $\begingroup$ I've added a solution that worked for me, check it out! $\endgroup$ – IE Irodov Mar 20 at 11:55
  • $\begingroup$ @IEIrodov, I can't comment on your answer, but I'm glad you've solved it! Maybe I had just been waiting long enough between running the cells that the job could complete. $\endgroup$ – Frank Mar 23 at 14:52
0
$\begingroup$

Error 3202 is a networking error when trying to get the requested page. In this case the results for your job.

| improve this answer | |
$\endgroup$

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.