Hello,
I am very new to Pennylane and I am following the demo tutorials. Everything works fine at the moment, but I have problems with the PyTorch noisy demo. I create the device, but whet I try to run the circuit I get the following error.
Any suggestion to understand and solve the problem?
Many thanks!
Regards
Antonio
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-23-ed065177fbb7> in <module>
1 print(phi)
2 print(theta)
----> 3 print(circuit(phi, theta))
4 print(cost(phi, theta, 400))
C:\ProgramData\Anaconda3\lib\site-packages\pennylane\interfaces\torch.py in custom_apply(*args, **kwargs)
295 # [keyword_values[k] for k in sorted(keyword_positions, key=keyword_positions.get)]
296
--> 297 return _TorchQNode.apply(keyword_values, *args)
298
299 return custom_apply
C:\ProgramData\Anaconda3\lib\site-packages\pennylane\interfaces\torch.py in forward(ctx, input_kwargs, *input_)
187
188 # evaluate the QNode
--> 189 res = qnode(*ctx.args, **ctx.kwargs)
190
191 if not isinstance(res, np.ndarray):
C:\ProgramData\Anaconda3\lib\site-packages\pennylane\qnodes\base.py in __call__(self, *args, **kwargs)
799 """Wrapper for :meth:`BaseQNode.evaluate`.
800 """
--> 801 return self.evaluate(args, kwargs)
802
803 def evaluate(self, args, kwargs):
C:\ProgramData\Anaconda3\lib\site-packages\pennylane\qnodes\base.py in evaluate(self, args, kwargs)
826 if isinstance(self.device, qml.QubitDevice):
827 # TODO: remove this if statement once all devices are ported to the QubitDevice API
--> 828 ret = self.device.execute(self.circuit, return_native_type=temp)
829 else:
830 ret = self.device.execute(
C:\ProgramData\Anaconda3\lib\site-packages\pennylane\_qubit_device.py in execute(self, circuit, **kwargs)
180
181 # apply all circuit operations
--> 182 self.apply(circuit.operations, rotations=circuit.diagonalizing_gates, **kwargs)
183
184 # generate computational basis samples
C:\ProgramData\Anaconda3\lib\site-packages\pennylane_forest\qvm.py in apply(self, operations, **kwargs)
148 # pylint: disable=attribute-defined-outside-init
149 if self.parametric_compilation and "pyqvm" not in self.qc.name:
--> 150 self.apply_parametric_program(operations, **kwargs)
151 else:
152 super().apply(operations, **kwargs)
C:\ProgramData\Anaconda3\lib\site-packages\pennylane_forest\qvm.py in apply_parametric_program(self, operations, **kwargs)
179 for i, operation in enumerate(operations):
180 # map the operation wires to the physical device qubits
--> 181 wires = self.remap_wires(operation.wires)
182
183 if i > 0 and operation.name in ("QubitStateVector", "BasisState"):
C:\ProgramData\Anaconda3\lib\site-packages\pennylane_forest\device.py in remap_wires(self, wires)
231 """
232 if hasattr(self, "wiring"):
--> 233 return [int(self.wiring[i]) for i in wires]
234
235 return [int(w) for w in wires]
C:\ProgramData\Anaconda3\lib\site-packages\pennylane_forest\device.py in <listcomp>(.0)
231 """
232 if hasattr(self, "wiring"):
--> 233 return [int(self.wiring[i]) for i in wires]
234
235 return [int(w) for w in wires]
KeyError: <Wires = [0]>