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] qml.AmplitudeEmbedding not supported in lightning.qubit in the middle of the circuit #5526

Open
1 task done
KetpuntoG opened this issue Apr 16, 2024 · 2 comments · Fixed by PennyLaneAI/pennylane-lightning#687
Assignees
Labels
bug 🐛 Something isn't working

Comments

@KetpuntoG
Copy link
Contributor

Expected behavior

import pennylane as qml

dev = qml.device("lightning.qubit", wires = 1)

@qml.qnode(dev)
def circuit():
    qml.Hadamard(0)
    qml.AmplitudeEmbedding([1.,0.], wires = 0)

    return qml.probs(wires=0)

circuit()

This code should give the same output than default.qubit.

Actual behavior

Operation StatePrep cannot we use after other Operations have been already applied [...]

Additional information

No response

Source code

No response

Tracebacks

No response

System information

Name: PennyLane
Version: 0.36.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: /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.36.0.dev0)
- default.gaussian (PennyLane-0.36.0.dev0)
- default.mixed (PennyLane-0.36.0.dev0)
- default.qubit (PennyLane-0.36.0.dev0)
- default.qubit.autograd (PennyLane-0.36.0.dev0)
- default.qubit.jax (PennyLane-0.36.0.dev0)
- default.qubit.legacy (PennyLane-0.36.0.dev0)
- default.qubit.tf (PennyLane-0.36.0.dev0)
- default.qubit.torch (PennyLane-0.36.0.dev0)
- default.qutrit (PennyLane-0.36.0.dev0)
- null.qubit (PennyLane-0.36.0.dev0)

Existing GitHub issues

  • I have searched existing GitHub issues to make sure the issue does not already exist.
@KetpuntoG KetpuntoG added the bug 🐛 Something isn't working label Apr 16, 2024
@albi3ro
Copy link
Contributor

albi3ro commented Apr 16, 2024

@KetpuntoG have you tried with master? Might. have different behavior with the new device interface.

@mudit2812
Copy link
Contributor

@albi3ro This happens because lightning.qubit and default.qubit use different stopping conditions. DQ decomposes until all ops have a matrix. In contrast, LQ decomposes until all decomposed ops are in the list of supported ops, so AmplitudeEmbedding decomposes to StatePrep, and does not get decomposed again. We need to update the decomposition logic to accommodate state prep ops in the middle of a circuit, but the stopping conditions do not currently account for operation index. I can add a new decomposition transform to lightning.qubit to use during preprocessing which does this, but it's going to be almost identical to pennylane.qubit.preprocess.decompose (which is what we were originally using with LQ) so there will be some code smell.

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

Successfully merging a pull request may close this issue.

3 participants