Skip to content

Commit

Permalink
[labs.dla 5] All Cartan involutions + Cartan subalgebra (#6396)
Browse files Browse the repository at this point in the history
Providing dense implementations for all Cartan involutions listed in
appendix C of https://arxiv.org/abs/2406.04418

Adds
* `recursive_cartan_decomp` function for recursive cartan decompositions
with the appropriate basis changes in between
* All canonical Cartan involutions working both with dense and operator
representations
* `cartan_subalgebra` function to compute the Cartan subalgebra (CSA),
i.e. the maximal Abelian subalgebra of $\mathfrak{m}$ using the adjoint
representation
 * misc. helper functions

Iterative Cartan decomposition:

```python
from pennylane.labs.dla import AI, AII, AIII, BDI, CI, CII, DIII, cartan_decomposition, check_cartan_decomp

g = list(qml.pauli.pauli_group(3)) # su(8)
g = [qml.matrix(_, wire_order=range(3)) for _ in g]
k0, m0 = cartan_decomposition(g, AII)
print(f"First iteration: {len(k0)}, {len(m0)}")
assert check_cartan_decomp(k0, m0)

k1, m1 = cartan_decomposition(k0, CI)
assert check_cartan_decomp(k1, m1)
print(f"Second iteration: {len(k1)}, {len(m1)}")
```

```pycon
First iteration: 36, 28
Second iteration: 16, 20
```

[sc-76116]

---------

Co-authored-by: David Wierichs <david.wierichs@xanadu.ai>
Co-authored-by: Pietropaolo Frisoni <pietropaolo.frisoni@xanadu.ai>
  • Loading branch information
3 people authored and mudit2812 committed Dec 13, 2024
1 parent a232fda commit 03bc136
Show file tree
Hide file tree
Showing 9 changed files with 1,640 additions and 202 deletions.
87 changes: 48 additions & 39 deletions doc/releases/changelog-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,41 +17,41 @@
* Developers of plugin devices now have the option of providing a TOML-formatted configuration file
to declare the capabilities of the device. See [Device Capabilities](https://docs.pennylane.ai/en/latest/development/plugins.html#device-capabilities) for details.

* An internal module `pennylane.devices.capabilities` is added that defines a new `DeviceCapabilites`
data class, as well as functions that load and parse the TOML-formatted configuration files.
[(#6407)](https://github.com/PennyLaneAI/pennylane/pull/6407)
* An internal module `pennylane.devices.capabilities` is added that defines a new `DeviceCapabilites`
data class, as well as functions that load and parse the TOML-formatted configuration files.
[(#6407)](https://github.com/PennyLaneAI/pennylane/pull/6407)

```pycon
>>> from pennylane.devices.capabilities import DeviceCapabilities
>>> capabilities = DeviceCapabilities.from_toml_file("my_device.toml")
>>> isinstance(capabilities, DeviceCapabilities)
True
```
```pycon
>>> from pennylane.devices.capabilities import DeviceCapabilities
>>> capabilities = DeviceCapabilities.from_toml_file("my_device.toml")
>>> isinstance(capabilities, DeviceCapabilities)
True
```

* Devices that extends `qml.devices.Device` now has an optional class attribute `capabilities`
that is an instance of the `DeviceCapabilities` data class, constructed from the configuration
file if it exists. Otherwise, it is set to `None`.
[(#6433)](https://github.com/PennyLaneAI/pennylane/pull/6433)
* Devices that extends `qml.devices.Device` now has an optional class attribute `capabilities`
that is an instance of the `DeviceCapabilities` data class, constructed from the configuration
file if it exists. Otherwise, it is set to `None`.
[(#6433)](https://github.com/PennyLaneAI/pennylane/pull/6433)

```python
from pennylane.devices import Device
```python
from pennylane.devices import Device

class MyDevice(Device):
class MyDevice(Device):

config_filepath = "path/to/config.toml"
config_filepath = "path/to/config.toml"

...
```
```pycon
>>> isinstance(MyDevice.capabilities, DeviceCapabilities)
True
```
...
```
```pycon
>>> isinstance(MyDevice.capabilities, DeviceCapabilities)
True
```

* Default implementations of `Device.setup_execution_config` and `Device.preprocess_transforms`
are added to the device API for devices that provides a TOML configuration file and thus have
a `capabilities` property.
[(#6632)](https://github.com/PennyLaneAI/pennylane/pull/6632)
[(#6653)](https://github.com/PennyLaneAI/pennylane/pull/6653)
* Default implementations of `Device.setup_execution_config` and `Device.preprocess_transforms`
are added to the device API for devices that provides a TOML configuration file and thus have
a `capabilities` property.
[(#6632)](https://github.com/PennyLaneAI/pennylane/pull/6632)
[(#6653)](https://github.com/PennyLaneAI/pennylane/pull/6653)

* Support is added for `if`/`else` statements and `for` and `while` loops in circuits executed with `qml.capture.enabled`, via Autograph.
Autograph conversion is now used by default in `make_plxpr`, but can be skipped with the keyword arg `autograph=False`.
Expand All @@ -60,10 +60,20 @@
[(#6426)](https://github.com/PennyLaneAI/pennylane/pull/6426)
[(#6645)](https://github.com/PennyLaneAI/pennylane/pull/6645)

* New `qml.GQSP` template has been added to perform Generalized Quantum Signal Processing (GQSP).
* New `qml.GQSP` template has been added to perform Generalized Quantum Signal Processing (GQSP).
The functionality `qml.poly_to_angles` has been also extended to support GQSP.
[(#6565)](https://github.com/PennyLaneAI/pennylane/pull/6565)

* Added `unary_mapping()` function to map `BoseWord` and `BoseSentence` to qubit operators, using unary mapping.
[(#6576)](https://github.com/PennyLaneAI/pennylane/pull/6576)

* Added `binary_mapping()` function to map `BoseWord` and `BoseSentence` to qubit operators, using standard-binary mapping.
[(#6564)](https://github.com/PennyLaneAI/pennylane/pull/6564)

* New functionality to calculate angles for QSP and QSVT has been added. This includes the function `qml.poly_to_angles`
to obtain angles directly and the function `qml.transform_angles` to convert angles from one subroutine to another.
[(#6483)](https://github.com/PennyLaneAI/pennylane/pull/6483)

* Added a function `qml.trotterize` to generalize the Suzuki-Trotter product to arbitrary quantum functions.
[(#6627)](https://github.com/PennyLaneAI/pennylane/pull/6627)

Expand Down Expand Up @@ -96,32 +106,31 @@
b: ──RY(-0.17)─╰X─╰X──RY(-0.17)─┤ State
```

<h4>New `labs` module `dla` for handling dynamical Lie algebras (DLAs)</h4>
<h4>New `pennylane.labs.dla` module for handling (dynamical) Lie algebras (DLAs)</h4>

* Added a dense implementation of computing the Lie closure in a new function
`lie_closure_dense` in `pennylane.labs.dla`.
[(#6371)](https://github.com/PennyLaneAI/pennylane/pull/6371)
[(#6695)](https://github.com/PennyLaneAI/pennylane/pull/6695)

* New functionality to calculate angles for QSP and QSVT has been added. This includes the function `qml.poly_to_angles`
to obtain angles directly and the function `qml.transform_angles` to convert angles from one subroutine to another.
[(#6483)](https://github.com/PennyLaneAI/pennylane/pull/6483)

* Added a dense implementation of computing the structure constants in a new function
`structure_constants_dense` in `pennylane.labs.dla`.
[(#6376)](https://github.com/PennyLaneAI/pennylane/pull/6376)

* Added utility functions for handling dense matrices in the Lie theory context.
* Added utility functions for handling dense matrices and advanced functionality in the Lie theory context.
[(#6563)](https://github.com/PennyLaneAI/pennylane/pull/6563)
[(#6392)](https://github.com/PennyLaneAI/pennylane/pull/6392)
[(#6396)](https://github.com/PennyLaneAI/pennylane/pull/6396)

* Added a ``cartan_decomp`` function along with two standard involutions ``even_odd_involution`` and ``concurrence_involution``.
[(#6392)](https://github.com/PennyLaneAI/pennylane/pull/6392)

* Added `unary_mapping()` function to map `BoseWord` and `BoseSentence` to qubit operators, using unary mapping
[(#6576)](https://github.com/PennyLaneAI/pennylane/pull/6576);
added `binary_mapping()` function to map `BoseWord` and `BoseSentence` to qubit operators, using standard-binary mapping.
[(#6564)](https://github.com/PennyLaneAI/pennylane/pull/6564)
* Added a `recursive_cartan_decomp` function and all canonical Cartan involutions.
[(#6396)](https://github.com/PennyLaneAI/pennylane/pull/6396)

* Added a `cartan_subalgebra` function to compute the (horizontal) Cartan subalgebra of a Cartan decomposition.
[(#6403)](https://github.com/PennyLaneAI/pennylane/pull/6403)
[(#6396)](https://github.com/PennyLaneAI/pennylane/pull/6396)


<h4>New API for Qubit Mixed</h4>
Expand Down
64 changes: 51 additions & 13 deletions pennylane/labs/dla/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
~lie_closure_dense
~structure_constants_dense
~cartan_decomp
~recursive_cartan_decomp
~cartan_subalgebra
Utility functions
Expand All @@ -34,44 +36,80 @@
:toctree: api
~adjvec_to_op
~change_basis_ad_rep
~check_orthonormal
~check_commutation
~check_all_commuting
~check_cartan_decomp
~op_to_adjvec
~trace_inner_product
~orthonormalize
~pauli_coefficients
~batched_pauli_decompose
~trace_inner_product
~check_orthonormal
~check_commutation
~check_all_commuting
~check_cartan_decomp
~change_basis_ad_rep
Involutions
~~~~~~~~~~~
A map :math:`\theta: \mathfrak{g} \rightarrow \mathfrak{g}` from the Lie algebra :math:`\mathfrak{g}` to itself is called an involution
when it fulfills :math:`\theta(\theta(g)) = g \ \forall g \in \mathfrak{g}` and is compatible with commutators,
:math:`[\theta(g), \theta(g')]=\theta([g, g']).` Involutions are used to construct a :func:`~cartan_decomp`. There are seven canonical
Cartan involutions of real simple Lie algebras (``AI, AII, AIII, BDI, CI, CII, DIII``),
see `Wikipedia <https://en.wikipedia.org/wiki/Symmetric_space#Classification_result>`__.
In addition, there is a canonical Cartan involution for real semisimple algebras that consist of
two isomorphic simple components (``ClassB``), see `here <https://en.wikipedia.org/wiki/Symmetric_space#Classification_scheme>`__.
.. currentmodule:: pennylane.labs.dla
.. autosummary::
:toctree: api
~even_odd_involution
~concurrence_involution
~khaneja_glaser_involution
~AI
~AII
~AIII
~BDI
~CI
~CII
~DIII
~ClassB
"""

from .lie_closure_dense import lie_closure_dense
from .structure_constants_dense import structure_constants_dense
from .cartan import cartan_decomp, even_odd_involution, concurrence_involution
from .cartan import (
cartan_decomp,
recursive_cartan_decomp,
)
from .dense_util import (
adjvec_to_op,
change_basis_ad_rep,
check_all_commuting,
check_cartan_decomp,
check_commutation,
check_orthonormal,
pauli_coefficients,
batched_pauli_decompose,
orthonormalize,
check_orthonormal,
trace_inner_product,
adjvec_to_op,
op_to_adjvec,
check_commutation,
check_all_commuting,
check_cartan_decomp,
orthonormalize,
)

from .involutions import (
khaneja_glaser_involution,
even_odd_involution,
concurrence_involution,
AI,
AII,
AIII,
BDI,
CI,
CII,
DIII,
ClassB,
)

from .cartan_subalgebra import cartan_subalgebra
Loading

0 comments on commit 03bc136

Please sign in to comment.