Hello,
I get the following error when I use amplitude embedding with the normalize parameter set to True on a Qiskit device. I observe this error even when I normalize manually. I do not observe this error when using the default simulator device. How do I solve this issue?
Traceback (most recent call last):
File "ensembles_ibm_qx.py", line 117, in <module>
p.append(qnode(learners[j], features=X_valid[i]))
File "/opt/miniconda3/lib/python3.8/site-packages/pennylane/interfaces/autograd.py", line 69, in __call__
return self.evaluate(args, kwargs)
File "/opt/miniconda3/lib/python3.8/site-packages/autograd/tracer.py", line 48, in f_wrapped
return f_raw(*args, **kwargs)
File "/opt/miniconda3/lib/python3.8/site-packages/pennylane/qnodes/base.py", line 826, in evaluate
ret = self.device.execute(self.circuit, return_native_type=temp)
File "/opt/miniconda3/lib/python3.8/site-packages/pennylane/_qubit_device.py", line 169, in execute
self.apply(circuit.operations, rotations=circuit.diagonalizing_gates, **kwargs)
File "/opt/miniconda3/lib/python3.8/site-packages/pennylane_qiskit/qiskit_device.py", line 214, in apply
applied_operations = self.apply_operations(operations)
File "/opt/miniconda3/lib/python3.8/site-packages/pennylane_qiskit/qiskit_device.py", line 265, in apply_operations
gate = mapped_operation(*par)
File "/opt/miniconda3/lib/python3.8/site-packages/qiskit/extensions/quantum_initializer/initializer.py", line 57, in __init__
raise QiskitError("Sum of amplitudes-squared does not equal one.")
qiskit.exceptions.QiskitError: 'Sum of amplitudes-squared does not equal one.'
The following is a section of the code:
dev1 = qml.device(name='qiskit.ibmq', backend='ibmq_rome',
ibmqx_token='xxx',
hub='ibm-q-xxx', group='xxx-uni', project='main', wires=num_wires)
def one_layer(W):
for i in range(num_wires):
qml.Rot(W[i][0], W[i][1], W[i][2], wires=i)
qml.CNOT(wires=[0, 1])
qml.CNOT(wires=[1, 2])
qml.CNOT(wires=[2, 3])
qml.CNOT(wires=[3, 4])
qml.CNOT(wires=[4, 0])
def classifier(weights, features=None):
AmplitudeEmbedding(features=features, wires=range(num_wires), normalize=True)
for W in weights:
one_layer(W)
return qml.expval(qml.PauliZ(0))
Qiskit version info is as follows:
PennyLane-qiskit==0.12.0
qiskit==0.23.1
qiskit-aer==0.7.1
qiskit-aqua==0.8.1
qiskit-ibmq-provider==0.11.1
qiskit-ignis==0.5.1
qiskit-terra==0.16.1
Thank you!