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 - Generalized Trotter products #6763

Merged
merged 5 commits into from
Jan 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 41 additions & 9 deletions doc/releases/changelog-0.40.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,50 @@

<h4>Generalized Trotter products 🐖</h4>

* Added a function `qml.trotterize` to generalize the Suzuki-Trotter product to arbitrary quantum functions.
* Trotter products that work on exponentiated operators directly instead of full system hamiltonians
can now be encoded into circuits with the addition of
:class:`qml.TrotterizedQfunc <pennylane.TrotterizedQfunc>` and :func:`qml.trotterize <pennylane.trotterize>`. This
allows for custom specification of the first-order expansion of the Suzuki-Trotter product formula
and extrapolating it to the :math:`n^{\text{th}}` order.
[(#6627)](https://github.com/PennyLaneAI/pennylane/pull/6627)

If the first-order of the Suzuki-Trotter product formula for a given problem is known,
:class:`qml.TrotterizedQfunc <pennylane.TrotterizedQfunc>` and :func:`qml.trotterize <pennylane.trotterize>`
let you implement the :math:`n^{\text{th}}`-order product formula while only specifying the
first-order term as a quantum function.

```python
def my_custom_first_order_expansion(time, theta, phi, wires, flip):
"This is the first order expansion (U_1)."
qml.RX(time*theta, wires[0])
qml.RY(time*phi, wires[1])
qml.RX(time * theta, wires[0])
qml.RY(time * phi, wires[1])
if flip:
qml.CNOT(wires=wires[:2])
```

:func:`qml.trotterize <pennylane.trotterize>` requires the quantum function representing the first-order
product formula, the number of Trotter steps, and the desired order. It returns a function with
the same call signature as the first-order product formula quantum function:

```python
@qml.qnode(qml.device("default.qubit"))
def my_circuit(time, theta, phi, num_trotter_steps):
qml.trotterize(
first_order_expansion,
n=num_trotter_steps,
order=2,
)(time, theta, phi, wires=['a', 'b'], flip=True)
return qml.state()
```

Alternatively, :class:`qml.TrotterizedQfunc <pennylane.TrotterizedQfunc>` can be used as follows:

```python
@qml.qnode(qml.device("default.qubit"))
def my_circuit(time, angles, num_trotter_steps):
TrotterizedQfunc(
def my_circuit(time, theta, phi, num_trotter_steps):
qml.TrotterizedQfunc(
time,
*angles,
theta,
phi,
qfunc=my_custom_first_order_expansion,
n=num_trotter_steps,
order=2,
Expand All @@ -69,14 +97,18 @@
)
return qml.state()
```

```pycon
>>> time = 0.1
>>> angles = (0.12, -3.45)
>>> print(qml.draw(my_circuit, level=3)(time, angles, num_trotter_steps=1))
>>> theta, phi = (0.12, -3.45)
>>> print(qml.draw(my_circuit, level="device")(time, theta, phi, num_trotter_steps=1))
a: ──RX(0.01)──╭●─╭●──RX(0.01)──┤ State
b: ──RY(-0.17)─╰X─╰X──RY(-0.17)─┤ State
```

Both methods produce the same results, but offer different interfaces based on the application or overall
preference.

<h4>Bosonic operators 🎈</h4>

* Added `unary_mapping()` function to map `BoseWord` and `BoseSentence` to qubit operators, using unary mapping.
Expand Down
Loading