Skip to content

Commit

Permalink
Upgrade qml.structure_constants to handle dense matrices (#6861)
Browse files Browse the repository at this point in the history
Integrate structure constants dense into [sc-81966]

Todo

- [x] update and unify documentation

---------

Co-authored-by: David Wierichs <[email protected]>
Co-authored-by: Yushao Chen (Jerry) <[email protected]>
Co-authored-by: ANTH0NY <[email protected]>
Co-authored-by: Diego <[email protected]>
  • Loading branch information
5 people authored Mar 5, 2025
1 parent 3db80cd commit 7bdf71b
Show file tree
Hide file tree
Showing 8 changed files with 249 additions and 262 deletions.
6 changes: 6 additions & 0 deletions doc/releases/changelog-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
Also added ``qml.pauli.trace_inner_product`` that can handle batches of dense matrices.
[(#6811)](https://github.com/PennyLaneAI/pennylane/pull/6811)

* ``qml.structure_constants`` now accepts and outputs matrix inputs using the ``matrix`` keyword.
[(#6861)](https://github.com/PennyLaneAI/pennylane/pull/6861)

<h3>Improvements 🛠</h3>

* Added a class `qml.capture.transforms.MergeAmplitudeEmbedding` that merges `qml.AmplitudeEmbedding` operators
Expand Down Expand Up @@ -326,6 +329,9 @@
* ``pennylane.labs.dla.lie_closure_dense`` is removed and integrated into ``qml.lie_closure`` using the new ``dense`` keyword.
[(#6811)](https://github.com/PennyLaneAI/pennylane/pull/6811)

* ``pennylane.labs.dla.structure_constants_dense`` is removed and integrated into ``qml.structure_constants`` using the new ``matrix`` keyword.
[(#6861)](https://github.com/PennyLaneAI/pennylane/pull/6861)

* ``ResourceOperator.resource_params`` is changed to a property.
[(#6973)](https://github.com/PennyLaneAI/pennylane/pull/6973)

Expand Down
2 changes: 0 additions & 2 deletions pennylane/labs/dla/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
.. autosummary::
:toctree: api
~structure_constants_dense
~cartan_decomp
~recursive_cartan_decomp
~cartan_subalgebra
Expand Down Expand Up @@ -80,7 +79,6 @@
"""

from .structure_constants_dense import structure_constants_dense
from .cartan import (
cartan_decomp,
recursive_cartan_decomp,
Expand Down
3 changes: 1 addition & 2 deletions pennylane/labs/dla/cartan_subalgebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,8 @@ def cartan_subalgebra(
all remaining operators from ``m``.
>>> import numpy as np
>>> from pennylane.labs.dla import structure_constants_dense
>>> g = np.vstack([k, m]) # re-order g to separate k and m operators
>>> adj = structure_constants_dense(g) # compute adjoint representation of g
>>> adj = qml.structure_constants(g, matrix=True) # compute adjoint representation of g
Finally, we can compute a Cartan subalgebra :math:`\mathfrak{a}`, a maximal Abelian subalgebra of :math:`\mathfrak{m}`.
Expand Down
123 changes: 0 additions & 123 deletions pennylane/labs/dla/structure_constants_dense.py

This file was deleted.

121 changes: 0 additions & 121 deletions pennylane/labs/tests/dla/test_structure_constants_dense.py

This file was deleted.

7 changes: 3 additions & 4 deletions pennylane/labs/tests/dla/test_variational_kak.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
check_cartan_decomp,
concurrence_involution,
orthonormalize,
structure_constants_dense,
validate_kak,
variational_kak_adj,
)
Expand Down Expand Up @@ -54,7 +53,7 @@ def test_kak_Ising(n, dense):
adj = qml.structure_constants(g)
else:
g = np.vstack([k, m])
adj = structure_constants_dense(g)
adj = qml.structure_constants(g, matrix=True)

g, k, mtilde, h, adj = cartan_subalgebra(g, k, m, adj, tol=1e-10, start_idx=0)

Expand Down Expand Up @@ -92,7 +91,7 @@ def test_kak_Heisenberg(n, dense):
adj = qml.structure_constants(g)
else:
g = np.vstack([k, m])
adj = structure_constants_dense(g)
adj = qml.structure_constants(g, matrix=True)

g, k, mtilde, h, adj = cartan_subalgebra(g, k, m, adj, tol=1e-10, start_idx=0)

Expand Down Expand Up @@ -132,7 +131,7 @@ def test_kak_Heisenberg_summed(is_orthogonal, dense):
adj = qml.structure_constants(g, is_orthogonal=is_orthogonal)
else:
g = np.vstack([k, m])
adj = structure_constants_dense(g, is_orthonormal=is_orthogonal)
adj = qml.structure_constants(g, matrix=True, is_orthogonal=is_orthogonal)

g, k, mtilde, h, adj = cartan_subalgebra(
g, k, m, adj, tol=1e-10, start_idx=0, is_orthogonal=is_orthogonal
Expand Down
Loading

0 comments on commit 7bdf71b

Please sign in to comment.