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

v0.40 changelog - efficient state prep #6761

Draft
wants to merge 10 commits into
base: v0.40.0-changelog
Choose a base branch
from
66 changes: 59 additions & 7 deletions doc/releases/changelog-0.40.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,80 @@

<h4>Efficient state preparation methods 🦾</h4>

* Added new ``MPSPrep`` template to prepare quantum states in tensor simulators.
* State preparation tailored for matrix product states (MPS) is now supported with
:class:`qml.MPSPrep <pennylane.MPSPrep>` on the `lightning.tensor` device.
[(#6431)](https://github.com/PennyLaneAI/pennylane/pull/6431)

* Users can prepare a linear combination of basis states using `qml.Superposition`.
Given a list of :math:`n` tensors that represents an MPS, :math:`[A^{(0)}, ..., A^{(n-1)}]`,
:class:`qml.MPSPrep <pennylane.MPSPrep>` lets you directly inject the MPS into a QNode as the initial
state of the circuit without any need for pre-processing. The first and last tensors in the list
must be rank-2, while all intermediate tensors should be rank-3.

```python
import pennylane as qml
import numpy as np

isaacdevlugt marked this conversation as resolved.
Show resolved Hide resolved
mps = [
np.array([[0.0, 0.107], [0.994, 0.0]]),
np.array(
[
[[0.0, 0.0, 0.0, -0.0], [1.0, 0.0, 0.0, -0.0]],
[[0.0, 1.0, 0.0, -0.0], [0.0, 0.0, 0.0, -0.0]],
]
),
np.array(
[
[[-1.0, 0.0], [0.0, 0.0]],
[[0.0, 0.0], [0.0, 1.0]],
[[0.0, -1.0], [0.0, 0.0]],
[[0.0, 0.0], [1.0, 0.0]],
]
),
np.array([[-1.0, -0.0], [-0.0, -1.0]]),
]

dev = qml.device("lightning.tensor", wires = 3)
isaacdevlugt marked this conversation as resolved.
Show resolved Hide resolved
@qml.qnode(dev)
def circuit():
qml.MPSPrep(mps, wires = [0,1,2])
return qml.state()
```

```pycon
>>> print(circuit())
[ 0. +0.j 0. +0.j 0. +0.j -0.1066+0.j 0. +0.j 0. +0.j
0. +0.j 0. +0.j 0. +0.j 0. +0.j 0. +0.j 0. +0.j
0.9943+0.j 0. +0.j 0. +0.j 0. +0.j]
```

At this time, :class:`qml.MPSPrep <pennylane.MPSPrep>` is only supported on the `lightning.tensor` device.

* Custom-made state preparation for linear combinations of quantum states is now available with
:class:`qml.Superposition <pennylane.Superposition>`.
[(#6670)](https://github.com/PennyLaneAI/pennylane/pull/6670)

Given a list of :math:`m` coefficients :math:`c_i` and basic states :math:`|b_i\rangle`,
:class:`qml.Superposition <pennylane.Superposition>` prepares
:math:`|\phi\rangle = \sum_i^m c_i |b_i\rangle`. Here is a simple example showing how to use
:class:`qml.Superposition <pennylane.Superposition>` to prepare
:math:`\tfrac{1}{\sqrt{2}} |00\rangle + \tfrac{1}{\sqrt{2}} |10\rangle`.

```python
isaacdevlugt marked this conversation as resolved.
Show resolved Hide resolved
coeffs = np.array([0.70710678, 0.70710678])
basis = np.array([[0, 0], [1, 0]])

@qml.qnode(qml.device('default.qubit', wires=2))
@qml.qnode(qml.device('default.qubit'))
def circuit():
qml.Superposition(coeffs, basis)
qml.Superposition(coeffs, basis, wires=[0, 1], work_wire=[2])
return qml.state()
```

```
>>> circuit()
tensor([0.70710678+0.j, 0.+0.j, 0.70710678+0.j, 0.+0.j], requires_grad=True)
Array([0.7071068 +0.j, 0. +0.j, 0. +0.j, 0. +0.j,
0.70710677+0.j, 0. +0.j, 0. +0.j, 0. +0.j], dtype=complex64)
```

This template is also JAX-jit compatible!

<h4>Enhanced QSVT functionality 🤩</h4>

* New functionality to calculate angles for QSP and QSVT has been added. This includes the function `qml.poly_to_angles`
Expand Down