Qiskit / qiskit

Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.
https://www.ibm.com/quantum/qiskit
Apache License 2.0
5.03k stars 2.32k forks source link

Problems with running PennyLane's Transfer Learning notebook on real backend #7690

Closed AlexanderGeng closed 2 years ago

AlexanderGeng commented 2 years ago

Environment

Qiskit Software Version
qiskit-terra 0.18.3
qiskit-aer 0.9.0
qiskit-ignis 0.6.0
qiskit-ibmq-provider 0.16.0
qiskit-aqua 0.9.5
qiskit 0.30.1
Python 3.7.11 (default, Jul 27 2021, 14:32:16) [GCC 7.5.0]
OS Linux
CPUs 12
Memory (Gb) 62.85524368286133

Fri Feb 18 18:53:45 2022 CET

What is happening?

I wanted to run PennyLane's notebook "Quantum transfer learning": I tried it and it works quite fine, when using dev = qml.device('default.qubit', wires=n_qubits) as device, so PennyLane's default device.

However, if I test it on an actual IBM machine (e.g. ibm_cairo) it does not work or runs for days. The queue time is not the problem may be rather some other issues. I also tested it on some of the other IBM backends. But the result was all the same.

When calling the train_model command quite at the end of the notebook, it arises the following UserWarning:

Resynthesized 

<qiskit.circuit.library.standard_gates.rz.RZGate object at 0x7f971b2d50d0>
<qiskit.circuit.library.standard_gates.sx.SXGate object at 0x7f971b2d5310>
<qiskit.circuit.library.standard_gates.rz.RZGate object at 0x7f9730849fd0>
<qiskit.circuit.library.standard_gates.sx.SXGate object at 0x7f971b327fd0>

and got

<qiskit.circuit.library.standard_gates.rz.RZGate object at 0x7f971b327690>
<qiskit.circuit.library.standard_gates.sx.SXGate object at 0x7f971b327410>
<qiskit.circuit.library.standard_gates.rz.RZGate object at 0x7f971b327e50>
<qiskit.circuit.library.standard_gates.sx.SXGate object at 0x7f971b327610>
<qiskit.circuit.library.standard_gates.rz.RZGate object at 0x7f971b3276d0>

but the original was native (for ['id', 'rz', 'sx', 'x', 'cx', 'reset']) and the new value is longer.  This indicates an efficiency bug in synthesis.  Please report it by opening an issue here: https://github.com/Qiskit/qiskit-terra/issues/new/choose
  new_dag = pass_.run(dag)

Maybe this is in some sense the reason for it, but I do not know.

I want to get something similar to the paper Transfer learning in hybrid classical-quantum neural networks, where they showed it with the ibmqx4 backend and an execution time of 26 seconds for the full dataset.

How can we reproduce the issue?

What should happen?

I would expect a longer execution time due to the queue and the execution of the circuit on the backends themselves. I expect some similar results as I get on the qasm_simulator or some fake backends. But not the error message showed above in every execution.

Any suggestions?

No response

AlexanderGeng commented 2 years ago

The bug can be fixed by updating Pennylane and Pennlane-qiskit to the version 0.21.0 instead of the previous used 0.18.0