After testing my weighted QAOA code on the simulators, I wanted to experiment with the available IBM hardware via the plugin. I submitted the job but I don’t see any output in pennylane. Here’s the warning I get:
WARNING:urllib3.connectionpool:Retrying (PostForcelistRetry(total=4, connect=3, read=None, redirect=None, status=None)) after connection broken by ‘ReadTimeoutError(“HTTPSConnectionPool(host=‘api.quantum-computing.ibm.com’, port=443): Read timed out. (read timeout=None)”)’: /api/Network/ibm-q/Groups/open/Projects/main/Jobs/6076e9a24c1aae1c26a920b6/v/1
I am not sure what this exactly means. On the other hand, I have a job that is complete when I check my IBM Experience account but the run time is only 7.2 seconds which leads me to believe that only the first iteration of QAOA (p=1) was taken in as the job.
Besides, is there any way to set the optimization level 3 while qiskit transpiles the circuit I sent in from pennylane? It seems like one can do it if they use qiskit end to end but is there a way to do this via pennylane? Any help would be appreciated. Thank you!
Hi @kabirkhanna85!
This may be an issue within Qiskit of not successfully sending and receiving the remote job. Are you able to run this Qiskit code:
from qiskit import IBMQ, assemble, transpile
from qiskit.circuit.random import random_circuit
provider = IBMQ.load_account()
backend = provider.backend.ibmq_qasm_simulator
qx = random_circuit(num_qubits=5, depth=4)
transpiled = transpile(qx, backend=backend)
job = backend.run(transpiled)
retrieved_job = backend.retrieve_job(job.job_id())
This sends a random circuit to the QASM backend. If you aren’t able to run this, then there may be an issue with your setup. You could also consider upgrading to the latest version of Qiskit using pip install qiskit --upgrade
.
Besides, is there any way to set the optimization level 3 while qiskit transpiles the circuit I sent in from pennylane?
You can set the optimization level as a keyword argument when loading the device:
qml.device("qiskit.aer", wires=2, optimization_level=3)
Hi @kabirkhanna85, I’m not completely sure but the error message you shared may have contained your IBMQ API key. I have edited your message to remove, but you may want to consider generating a new key.
from qiskit import IBMQ, assemble, transpile
from qiskit.circuit.random import random_circuit
provider = IBMQ.load_account()
backend = provider.backend.ibmq_qasm_simulator
qx = random_circuit(num_qubits=5, depth=4)
transpiled = transpile(qx, backend=backend)
job = backend.run(transpiled)
retrieved_job = backend.retrieve_job(job.job_id())
I fixed the issue. It was giving an error while loading the account.
qml.device(“qiskit.aer”, wires=2, optimization_level=3)
This works. Could I use all the transpilation options provided by qiskit under qml.device? Thanks!
Hi @kabirkhanna85,
Yes, absolutely! This can be done using the set_transpile_args
function.
For example,
dev= qml.device("qiskit.aer", wires=5, shots=1000)
dev.set_transpile_args(
**{
"optimization_level": 3,
"coupling_map": coupling_map,
"layout_method": "sabre",
"routing_method": "sabre",
}
)
This is taken from this section of our demo on quantum volume, in which you can find the full end-to-end example.
Hope that helps, feel free to let us know if you have any further questions!
Thanks a lot! That was helpful.
No problem, we’re happy to help!