PennyLane is a cross-platform Python library for quantum computing, quantum machine learning, and quantum chemistry. Train a quantum computer the same way as a neural network.
When a tensor product between two 'qml.operation.Tensor' operands (c = a @ b) is performed, the result must only be in variable 'c'. The value of operands 'a' and 'b' must not be altered.
Actual behavior
Upon computing c = a @ b, the value of operand 'a' is changed to 'c'. This causes problems as the value of 'a' is lost.
Additional information
No response
Source code
import pennylane as qml
a = qml.Identity(0) @ qml.Identity(1)
b = qml.Identity(2) @ qml.Identity(3)
c = a @ b
print('a = ',a)
print('b = ',b)
print('c = ',c)
Tracebacks
The code snippet doesn't throw an error but does not follow the expected behavior. The output of the above code snippet is as follows:
a = Identity(wires=[0]) @ Identity(wires=[1]) @ Identity(wires=[2]) @ Identity(wires=[3])
b = Identity(wires=[2]) @ Identity(wires=[3])
c = Identity(wires=[0]) @ Identity(wires=[1]) @ Identity(wires=[2]) @ Identity(wires=[3])
Expected behavior
When a tensor product between two 'qml.operation.Tensor' operands (c = a @ b) is performed, the result must only be in variable 'c'. The value of operands 'a' and 'b' must not be altered.
Actual behavior
Upon computing c = a @ b, the value of operand 'a' is changed to 'c'. This causes problems as the value of 'a' is lost.
Additional information
No response
Source code
Tracebacks
System information
Existing GitHub issues