# Wire Error on IBM simulator

**URL:** <https://discuss.pennylane.ai/t/wire-error-on-ibm-simulator/1282>\
**Category:** PennyLane Plugins\
**Created:** [August 12, 2021, 3:41pm UTC](https://discuss.pennylane.ai/t/wire-error-on-ibm-simulator/1282 "2021-08-12T15:41:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JosephT](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/josepht/32/1773_2.png) [@JosephT](https://discuss.pennylane.ai/u/JosephT)\
**Post date:** [August 12, 2021, 3:41pm UTC](https://discuss.pennylane.ai/t/wire-error-on-ibm-simulator/1282/1 "2021-08-12T15:41:10Z")

</div>

Hi there,

I’m attempting to run the following circuit as part of a VQA, I can draw the circuit, and it gives me what I’m looking for, but I keep getting a Wire error when I attempt to run it. For context, this should implement Circuit 19 of [https://arxiv.org/pdf/1905.10876.pdf](https://arxiv.org/pdf/1905.10876.pdf) on p8.

code:  
dev = qml.device(“qiskit.ibmq”,wires=11, backend=‘ibmq\_qasm\_simulator’)  
@qml.qnode(dev)  
def circuit19(params,n,x):

# Requires 3n parameters

```
qml.templates.AngleEmbedding(x,wires=[i for i in range(n)])
index = 0

```

# RX, RZ block

```
for i in range(n):
    qml.RX(params[index],wires=i)
    index += 1
    qml.RZ(params[index],wires=i)
    index += 1

```

# CRX ring

```
qml.CRX(params[index], wires=[n-1,0])
index += 1

for i in range(n-1):
    qml.CRX(params[index],wires=[n-2-i,n-1-i])
    index +=1 

return [qml.expval(qml.PauliZ(i)) for i in range(n)]

```

I try to input  
params = array([-0.0032389 , -0.01684838, 0.01511622, -0.00838866, 0.00166207,  
-0.00150847, -0.0006588 , 0.01190467, 0.00847062, -0.00101217,  
0.00827397, 0.0164149 , -0.0077316 , 0.00027279, -0.00364212,  
-0.00350231, 0.00694448, -0.02124912, 0.02051644, 0.01000784,  
-0.00304314, 0.00105156, 0.01869766, 0.00629439, 0.00031815,  
0.02199048, -0.0043911 , -0.01440873, 0.01359715, 0.01457333,  
0.02708231, 0.00355718, -0.01900089])  
n = 11  
x = array([ 0.78199136, 0.78347364, 1.28256651, -1.09202159, 1.04188643,  
0.27299406, -0.11969382, 1.16452877, 1.87329371, 0.56716628,  
1. ])

I’m then given the following error message:

File “C:\Users\josep\anaconda3\lib\site-packages\pennylane\_device.py”, line 346, in map\_wires  
mapped\_wires = wires.map(self.wire\_map)

File “C:\Users\josep\anaconda3\lib\site-packages\pennylane\wires.py”, line 271, in map  
raise WireError(

WireError: No mapping for wire label 10 specified in wire map OrderedDict([(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7), (8, 8), (9, 9), (10, 10)]).

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

File “”, line 1, in   
circuit19(var,11,X\_train[0])

File “C:\Users\josep\anaconda3\lib\site-packages\pennylane\qnode.py”, line 598, in **call**  
res = self.qtape.execute(device=self.device)

File “C:\Users\josep\anaconda3\lib\site-packages\pennylane\tape\tape.py”, line 1323, in execute  
return self.\_execute(params, device=device)

File “C:\Users\josep\anaconda3\lib\site-packages\autograd\tracer.py”, line 48, in f\_wrapped  
return f\_raw(\*args, \*\*kwargs)

File “C:\Users\josep\anaconda3\lib\site-packages\pennylane\interfaces\autograd.py”, line 165, in \_execute  
res = self.execute\_device(params, device=device)

File “C:\Users\josep\anaconda3\lib\site-packages\pennylane\tape\tape.py”, line 1354, in execute\_device  
res = device.execute(self)

File “C:\Users\josep\anaconda3\lib\site-packages\pennylane\_qubit\_device.py”, line 192, in execute  
self.apply(circuit.operations, rotations=circuit.diagonalizing\_gates, \*\*kwargs)

File “C:\Users\josep\anaconda3\lib\site-packages\pennylane\_qiskit\qiskit\_device.py”, line 211, in apply  
applied\_operations = self.apply\_operations(operations)

File “C:\Users\josep\anaconda3\lib\site-packages\pennylane\_qiskit\qiskit\_device.py”, line 247, in apply\_operations  
device\_wires = self.map\_wires(operation.wires)

File “C:\Users\josep\anaconda3\lib\site-packages\pennylane\_device.py”, line 348, in map\_wires  
raise WireError(

WireError: Did not find some of the wires \<Wires = [tensor(10, requires\_grad=True), 0]\> on device with wires \<Wires = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\>.

Any help would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![christina](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/christina/32/583_2.png) [@christina](https://discuss.pennylane.ai/u/christina)\
**Post date:** [August 12, 2021, 5:17pm UTC](https://discuss.pennylane.ai/t/wire-error-on-ibm-simulator/1282/2 "2021-08-12T17:17:09Z")

</div>

Hi @JosephT🙂

You encountered a known quirk of PennyLane that we are trying to find a better workaround for. The package assumes all arguments are trainable by default, and so wraps any non-array input in an array.

This causes a problem with labelling wires, because `11` and `np.array(11)` have different hash values, and thus are different wires.

You can get the above code to work by calling

```auto
circuit19(params, n=n, x=x)

```

since keyword arguments are not wrapped.

---

<div class="post-metadata">

**Author:** ![JosephT](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/josepht/32/1773_2.png) [@JosephT](https://discuss.pennylane.ai/u/JosephT)\
**Post date:** [August 13, 2021, 9:06am UTC](https://discuss.pennylane.ai/t/wire-error-on-ibm-simulator/1282/3 "2021-08-13T09:06:46Z")

</div>

Hi @christina,

Thanks for the explanation! That didn’t seem to work for me because the function call is then using undefined variables to give values. My workaround is just using:

n = int(n)

which redefines it within the function.

---

<div class="post-metadata">

**Author:** ![christina](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/christina/32/583_2.png) [@christina](https://discuss.pennylane.ai/u/christina)\
**Post date:** [August 13, 2021, 9:12am UTC](https://discuss.pennylane.ai/t/wire-error-on-ibm-simulator/1282/4 "2021-08-13T09:12:00Z")

</div>

Glad it works for you now. We will keep your feedback in mind for future design and setting priorities on what to fix.
