Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Tensor product alters operands #5823

Closed
1 task done
poojithumeshrao opened this issue Jun 9, 2024 · 0 comments
Closed
1 task done

[BUG] Tensor product alters operands #5823

poojithumeshrao opened this issue Jun 9, 2024 · 0 comments
Labels
bug 🐛 Something isn't working

Comments

@poojithumeshrao
Copy link

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

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])

System information

Name: PennyLane
Version: 0.32.0
Summary: PennyLane is a Python quantum machine learning library by Xanadu Inc.
Home-page: https://github.com/PennyLaneAI/pennylane
Author: 
Author-email: 
License: Apache License 2.0
Location: /home/poojith/miniconda3/envs/pennylane/lib/python3.9/site-packages
Requires: appdirs, autograd, autoray, cachetools, networkx, numpy, pennylane-lightning, requests, rustworkx, scipy, semantic-version, toml, typing-extensions
Required-by: PennyLane-Lightning

Platform info:           Linux-4.19.0-23-amd64-x86_64-with-glibc2.28
Python version:          3.9.17
Numpy version:           1.23.5
Scipy version:           1.11.2
Installed devices:
- default.gaussian (PennyLane-0.32.0)
- default.mixed (PennyLane-0.32.0)
- default.qubit (PennyLane-0.32.0)
- default.qubit.autograd (PennyLane-0.32.0)
- default.qubit.jax (PennyLane-0.32.0)
- default.qubit.tf (PennyLane-0.32.0)
- default.qubit.torch (PennyLane-0.32.0)
- default.qutrit (PennyLane-0.32.0)
- null.qubit (PennyLane-0.32.0)
- lightning.qubit (PennyLane-Lightning-0.32.0)

Existing GitHub issues

  • I have searched existing GitHub issues to make sure the issue does not already exist.
@poojithumeshrao poojithumeshrao added the bug 🐛 Something isn't working label Jun 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant