Skip to content

[BUG] simplify unexpectedly removes all wires with the Identity observable #8746

@SimoneGasperini

Description

@SimoneGasperini

Hello PennyLane Core team! Hope you're all doing well 🥲
I've just found this little bug while working with PennyLane. If you could take a look at it, that would be great, thanks!

Expected behavior

I expect the qml.simplify function to always return a LinearCombination with the same wires of the original object.

Actual behavior

If I call the function on an operator created from the Identity, I'm returned a new object with no wires at all:

>>> qml.simplify(qml.Hamiltonian([1.23], [qml.I(0)])).wires
Wires([])

Additional information

This doesn't happen if I create the same operator as a product between the coefficient and the observable:

>>> qml.simplify(1.23 * qml.I(0)).wires
Wires([0])

System information

Name: pennylane
Version: 0.43.1
Summary: 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.
Home-page:
Author:
Author-email:
License-Expression: Apache-2.0
Location: /home/simone/miniconda3/lib/python3.12/site-packages
Requires: appdirs, autograd, autoray, cachetools, diastatic-malt, networkx, numpy, packaging, pennylane-lightning, requests, rustworkx, scipy, tomlkit, typing_extensions
Required-by: pennylane_lightning

Platform info:           Linux-5.15.167.4-microsoft-standard-WSL2-x86_64-with-glibc2.35
Python version:          3.12.2
Numpy version:           2.3.5
Scipy version:           1.16.3
JAX version:             None
Installed devices:
- lightning.qubit (pennylane_lightning-0.43.0)
- default.clifford (pennylane-0.43.1)
- default.gaussian (pennylane-0.43.1)
- default.mixed (pennylane-0.43.1)
- default.qubit (pennylane-0.43.1)
- default.qutrit (pennylane-0.43.1)
- default.qutrit.mixed (pennylane-0.43.1)
- default.tensor (pennylane-0.43.1)
- null.qubit (pennylane-0.43.1)
- reference.qubit (pennylane-0.43.1)

Existing GitHub issues

  • I have searched existing GitHub issues to make sure the issue does not already exist.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐛Something isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions