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] single_qubit_fusion gets rid of the GlobalPhase #6002

Open
1 task done
EmilianoG-byte opened this issue Jul 16, 2024 · 0 comments
Open
1 task done

[BUG] single_qubit_fusion gets rid of the GlobalPhase #6002

EmilianoG-byte opened this issue Jul 16, 2024 · 0 comments
Labels
bug 🐛 Something isn't working

Comments

@EmilianoG-byte
Copy link
Contributor

EmilianoG-byte commented Jul 16, 2024

Expected behavior

The global phase of the operators inside the transform is taken into account. The returned qfunc contains a qml.GlobalPhase operator gathering the phases of all gates that were transformed into a qml.Rot gate.

Actual behavior

Global phase is ignored for all gates that were transformed.

Additional information

At the very least, the docs of the function should be clear about this behaviour and not use the formulation "general single-qubit unitary operation (Rot)" but rather "special unitary ..."

Source code

dev = qml.device('default.qubit', wires=1)

def qfunc(r1, r2):
    qml.Hadamard(wires=0)
    qml.Rot(*r1, wires=0)
    qml.Rot(*r2, wires=0)
    qml.RZ(r1[0], wires=0)
    qml.RZ(r2[0], wires=0)
    # qml.CNOT((0,1))
    return qml.expval(qml.X(0))

optimized_qfunc = qml.transforms.single_qubit_fusion(qfunc)
optimized_qnode = qml.QNode(optimized_qfunc, dev)

optimized_matrix = qml.matrix(optimized_qnode)([0.1, 0.2, 0.3], [0.4, 0.5, 0.6])
circuit_matrix = qml.matrix(qnode)([0.1, 0.2, 0.3], [0.4, 0.5, 0.6])

qml.math.allclose(optimized_matrix, circuit_matrix)
>>> False

Tracebacks

No response

System information

Name: PennyLane
Version: 0.38.0.dev0
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: /Users/emiliano.godinez/.pyenv/versions/3.10.14/envs/pennylane-dev/lib/python3.10/site-packages
Editable project location: /Users/emiliano.godinez/Documents/software_development/pennylane
Requires: appdirs, autograd, autoray, cachetools, networkx, numpy, packaging, pennylane-lightning, requests, rustworkx, scipy, semantic-version, toml, typing-extensions
Required-by: PennyLane-qiskit, PennyLane_Lightning

Platform info:           macOS-14.5-arm64-arm-64bit
Python version:          3.10.14
Numpy version:           1.26.4
Scipy version:           1.13.1
Installed devices:
- lightning.qubit (PennyLane_Lightning-0.37.0)
- qiskit.aer (PennyLane-qiskit-0.37.0)
- qiskit.basicaer (PennyLane-qiskit-0.37.0)
- qiskit.basicsim (PennyLane-qiskit-0.37.0)
- qiskit.ibmq (PennyLane-qiskit-0.37.0)
- qiskit.ibmq.circuit_runner (PennyLane-qiskit-0.37.0)
- qiskit.ibmq.sampler (PennyLane-qiskit-0.37.0)
- qiskit.remote (PennyLane-qiskit-0.37.0)
- default.clifford (PennyLane-0.38.0.dev0)
- default.gaussian (PennyLane-0.38.0.dev0)
- default.mixed (PennyLane-0.38.0.dev0)
- default.qubit (PennyLane-0.38.0.dev0)
- default.qubit.autograd (PennyLane-0.38.0.dev0)
- default.qubit.jax (PennyLane-0.38.0.dev0)
- default.qubit.legacy (PennyLane-0.38.0.dev0)
- default.qubit.tf (PennyLane-0.38.0.dev0)
- default.qubit.torch (PennyLane-0.38.0.dev0)
- default.qutrit (PennyLane-0.38.0.dev0)
- default.qutrit.mixed (PennyLane-0.38.0.dev0)
- default.tensor (PennyLane-0.38.0.dev0)
- null.qubit (PennyLane-0.38.0.dev0)

Existing GitHub issues

  • I have searched existing GitHub issues to make sure the issue does not already exist.
@EmilianoG-byte EmilianoG-byte added the bug 🐛 Something isn't working label Jul 16, 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