You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would expect Ham_evolve and Ham_evolve2 to build the same circuit.
Actual behavior
Drawing print(qml.draw(Ham_evolve, expansion_strategy="device")(0.9,1.0,0.4)) gives the correct circuit, since the Hamiltonian was defined with qml.dot.
Drawing print(qml.draw(Ham_evolve2, expansion_strategy="device")(0.9,1.0,0.4)) queues extra gates.
This can be fixed by running qml.operation.enable_new_opmath() but it does seem like an extra step users wouldn't be aware of.
Additional information
Happens all the time with version 0.35.1, as long as new_opmath is disabled.
alvaro-at-xanadu
changed the title
Hamiltonians defined using operator arithmetic queuing extra gates [BUG]
[BUG] Hamiltonians defined using operator arithmetic queuing extra gates
Apr 1, 2024
**Context:**
A user was encountering issues where operations were remaining in the
circuit after being used to construct a hamiltonian.
**Description of the Change:**
De-queue the arguments to `Hamiltonian.__matmul__`
**Benefits:**
No more things in the circuit that shouldn't be in the circuit.
**Possible Drawbacks:**
**Related GitHub Issues:**
Fixes#5454 [sc-60158]
Expected behavior
When defining
I would expect
Ham_evolve
andHam_evolve2
to build the same circuit.Actual behavior
Drawing
print(qml.draw(Ham_evolve, expansion_strategy="device")(0.9,1.0,0.4))
gives the correct circuit, since the Hamiltonian was defined withqml.dot
.Drawing
print(qml.draw(Ham_evolve2, expansion_strategy="device")(0.9,1.0,0.4))
queues extra gates.This can be fixed by running
qml.operation.enable_new_opmath()
but it does seem like an extra step users wouldn't be aware of.Additional information
Happens all the time with version
0.35.1
, as long as new_opmath is disabled.Source code
Tracebacks
No error tracebacks since it's a queuing issue.
System information
Name: PennyLane Version: 0.35.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: https://github.com/PennyLaneAI/pennylane Author: Author-email: License: Apache License 2.0 Location: /usr/local/lib/python3.10/dist-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-6.1.58+-x86_64-with-glibc2.35 Python version: 3.10.12 Numpy version: 1.25.2 Scipy version: 1.11.4 Installed devices: - lightning.qubit (PennyLane_Lightning-0.35.1) - default.clifford (PennyLane-0.35.1) - default.gaussian (PennyLane-0.35.1) - default.mixed (PennyLane-0.35.1) - default.qubit (PennyLane-0.35.1) - default.qubit.autograd (PennyLane-0.35.1) - default.qubit.jax (PennyLane-0.35.1) - default.qubit.legacy (PennyLane-0.35.1) - default.qubit.tf (PennyLane-0.35.1) - default.qubit.torch (PennyLane-0.35.1) - default.qutrit (PennyLane-0.35.1) - null.qubit (PennyLane-0.35.1)
Existing GitHub issues
The text was updated successfully, but these errors were encountered: