Qiskit Hardware Backend Cannot Use Pennylane Wires?

line 225, in qregs = [self._reg[i] for i in wires]
line 122, in getitem raise CircuitError(“expected integer or slice index into register”)
qiskit.circuit.exceptions.CircuitError: ‘expected integer or slice index into register’

I have tried to read about the np int wires issue, but from what I can gather the issue was resolved? Below is what I believe to be creation of a Bell state on Qiskit hardware that ought to work? Please let me know if I have made a mistake in my code and I will try figure it out from the docs.

from qiskit import IBMQ
import pennylane as qml



IBMQ.load_account()
provider = IBMQ.get_provider(hub='ibm-q', group='open', project='main')
device = qml.device('qiskit.ibmq', provider=provider,
					backend='ibmq_valencia', wires=2, shots=10)


@qml.qnode(device)
def circuit():
	qml.Hadamard(wires=0)
	qml.CNOT(wires=[0, 1])
	return qml.probs(wires=[0, 1])


print(circuit())

Hi @HelloBeastie,

Thank you for your question! We tried out your Bell state code snippet and it works as expected, so you’re good to go on that front.

Regarding the error message at the top of your post, could you provide some more details, and the code that produced it? We’d like to get a better idea of the context in which the error is occurring.

Thanks!

The Bell state snipet produced that error sorry for not being clear :confused: Here is the full error message:

2020-10-01 18:17:17.375515: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudart.so.11.0
/usr/lib/python3.8/site-packages/qiskit/providers/ibmq/ibmqfactory.py:192: UserWarning: Timestamps in IBMQ backend properties, jobs, and job results are all now in local time instead of UTC.
warnings.warn('Timestamps in IBMQ backend properties, jobs, and job results ’
Traceback (most recent call last):
File “pl_qiskit_hardware.py”, line 17, in
print(circuit())
File “/home/HelloBeastie/.local/lib/python3.8/site-packages/pennylane/interfaces/autograd.py”, line 69, in call
return self.evaluate(args, kwargs)
File “/home/HelloBeastie/.local/lib/python3.8/site-packages/autograd/tracer.py”, line 48, in f_wrapped
return f_raw(*args, **kwargs)
File “/home/HelloBeastie/.local/lib/python3.8/site-packages/pennylane/qnodes/base.py”, line 828, in evaluate
ret = self.device.execute(self.circuit, return_native_type=temp)
File “/home/HelloBeastie/.local/lib/python3.8/site-packages/pennylane/_qubit_device.py”, line 182, in execute
self.apply(circuit.operations, rotations=circuit.diagonalizing_gates, **kwargs)
File “/home/HelloBeastie/.local/lib/python3.8/site-packages/pennylane_qiskit/qiskit_device.py”, line 182, in apply
applied_operations = self.apply_operations(operations)
File “/home/HelloBeastie/.local/lib/python3.8/site-packages/pennylane_qiskit/qiskit_device.py”, line 225, in apply_operations
qregs = [self._reg[i] for i in wires]
File “/home/HelloBeastie/.local/lib/python3.8/site-packages/pennylane_qiskit/qiskit_device.py”, line 225, in
qregs = [self._reg[i] for i in wires]
File “/usr/lib/python3.8/site-packages/qiskit/circuit/register.py”, line 122, in getitem
raise CircuitError(“expected integer or slice index into register”)
qiskit.circuit.exceptions.CircuitError: ‘expected integer or slice index into register’

Gotcha, thanks for clarifying that. Could you please send the output of pip freeze so we can check the version of the packages you’re using?

Not sure if you want the entire console output of pip freeze but here are the qiskit pennylane versions. I did try to upgrade, but I should mention that I usually install my python packages using my distro’s package manager however I used pip only for pennylane and qiskit since I had strange issues otherwise, so perhaps pip and pacman are not working together.

PennyLane==0.11.0
PennyLane-Lightning==0.11.0
PennyLane-qiskit==0.9.0
qiskit==0.21.0
qiskit-aer==0.6.1
qiskit-aqua==0.7.5
qiskit-ibmq-provider==0.9.0
qiskit-ignis==0.4.0
qiskit-terra==0.15.2

That’s perfect, thank you! I was able to reproduce the environment and indeed I get the same error. Please try updating to the newest version of pennylane-qiskit (0.11.0), where the issue has been fixed. All the other packages there look like they’re up to date.

1 Like

I just want to note that pip freeze gave me the version 9 whilst when I uninstalled it was version 11. Also I did try upgrade before posting my question and it didn’t update it, uninstalling and reinstalling didnt work either. Bizarrely (to me anyway) pip install pennylane pennylane-qiskit -U worked but pip install pennylane-qiskit -U did not. Thanks so much for helping me out!

Of course, no problem!