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

[DLA 4] qml.dla.center function #5477

Merged
merged 366 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
366 commits
Select commit Hold shift + click to select a range
cfe8850
Merge branch 'master' of https://github.com/PennyLaneAI/pennylane int…
Qottmann Mar 4, 2024
3edc87a
tol test
Qottmann Mar 4, 2024
f645da6
Merge branch 'master' into lieclosure
Qottmann Mar 5, 2024
0f6d4fe
Merge branch 'master' into lieclosure
Qottmann Mar 6, 2024
0eba2bf
merge
Qottmann Mar 6, 2024
4838660
Merge branch 'master' of https://github.com/PennyLaneAI/pennylane int…
Qottmann Mar 6, 2024
7b96605
add test for coverage
Qottmann Mar 6, 2024
1581a5d
black formatting
Qottmann Mar 6, 2024
1485118
Merge branch 'lieclosure' of https://github.com/PennyLaneAI/pennylane…
Qottmann Mar 6, 2024
abb3595
Merge branch 'master' of https://github.com/PennyLaneAI/pennylane int…
Qottmann Mar 8, 2024
6bb9e17
code review suggestions
Qottmann Mar 8, 2024
0ad5840
black formatting
Qottmann Mar 8, 2024
9d2b19a
code review
Qottmann Mar 8, 2024
eff142d
Merge branch 'lieclosure' of https://github.com/PennyLaneAI/pennylane…
Qottmann Mar 8, 2024
44204ba
remove re-defined pauli_rep property
Qottmann Mar 12, 2024
b5e40cd
Update pennylane/dla/lie_closure.py
Qottmann Mar 13, 2024
bdbfd6d
black formatting
Qottmann Mar 13, 2024
b8d23b7
[ci skip]
Qottmann Mar 13, 2024
6dc2e4b
black formatting
Qottmann Mar 13, 2024
a7c9bd9
Apply suggestions from code review
Qottmann Mar 19, 2024
056e750
Merge branch 'master' into lieclosure
Qottmann Mar 19, 2024
be3fe44
merge and add example to doc string
Qottmann Mar 19, 2024
b0b6b2e
black formatting
Qottmann Mar 19, 2024
6acb926
adjoint representation
Qottmann Mar 19, 2024
4f9b086
black formatting
Qottmann Mar 19, 2024
f3cdb7a
add files
Qottmann Mar 19, 2024
e3fa1f5
PauliSentence.trace() method
Qottmann Mar 19, 2024
def9943
black formatting
Qottmann Mar 19, 2024
109415c
PauliWord.trace() function pointless
Qottmann Mar 19, 2024
b21006f
Merge branch 'master' into lieclosure
Qottmann Mar 22, 2024
84a59ef
Merge branch 'master' of https://github.com/PennyLaneAI/pennylane int…
Qottmann Mar 28, 2024
304fd49
changelog
Qottmann Mar 28, 2024
8131cf7
code review
Qottmann Mar 28, 2024
0aefa9c
Merge branch 'lieclosure2' of https://github.com/PennyLaneAI/pennylan…
Qottmann Mar 28, 2024
aef155a
allow operators
Qottmann Mar 28, 2024
429b72d
black formatting
Qottmann Mar 28, 2024
af2651b
changelog
Qottmann Mar 28, 2024
b335e2b
pauli mode
Qottmann Mar 28, 2024
c70ea95
black formatting
Qottmann Mar 28, 2024
b76bd44
changelog order
Qottmann Mar 28, 2024
87155c2
verbose output for codecov
Qottmann Mar 28, 2024
ba7d0a8
black formatting
Qottmann Mar 28, 2024
983266f
Merge branch 'lieclosure2' of https://github.com/PennyLaneAI/pennylan…
Qottmann Mar 28, 2024
bfbbf25
pylint
Qottmann Mar 28, 2024
41020a5
black formatting
Qottmann Mar 28, 2024
38786eb
verbose and max_iterations
Qottmann Mar 28, 2024
6150324
black formatting
Qottmann Mar 28, 2024
721a229
_M dtype back to float
Qottmann Apr 2, 2024
6b2f125
black formatting
Qottmann Apr 2, 2024
ffc6ffe
black formatting
Qottmann Apr 2, 2024
4f3a3ba
bug fix in __eq__ when permutation of pw_to_idx is different
Qottmann Apr 2, 2024
c58d3ee
black formatting
Qottmann Apr 2, 2024
53299d9
Merge branch 'master' of https://github.com/PennyLaneAI/pennylane int…
Qottmann Apr 2, 2024
7b93e36
Merge branch 'lieclosure' of https://github.com/PennyLaneAI/pennylane…
Qottmann Apr 2, 2024
6c4d49b
Merge branch 'lieclosure2' of https://github.com/PennyLaneAI/pennylan…
Qottmann Apr 2, 2024
bc0bdad
Apply suggestions from code review
Qottmann Apr 2, 2024
a3fad7b
Merge branch 'adjointrepr' of https://github.com/PennyLaneAI/pennylan…
Qottmann Apr 2, 2024
8ca8e00
[ci skip]
Qottmann Apr 2, 2024
f997c3e
remove normalization assumption
Qottmann Apr 2, 2024
9ec4b3c
[ci skip]
Qottmann Apr 2, 2024
8645fda
found bug in PauliSentence.__matmul__
Qottmann Apr 2, 2024
4f2ec43
normalization = solved
Qottmann Apr 2, 2024
f35a6db
black formatting
Qottmann Apr 2, 2024
f114ae4
black formatting
Qottmann Apr 2, 2024
b3919ab
black formatting
Qottmann Apr 2, 2024
bd14bcb
Merge branch 'master' of https://github.com/PennyLaneAI/pennylane int…
Qottmann Apr 3, 2024
b82776e
Merge branch 'lieclosure' of https://github.com/PennyLaneAI/pennylane…
Qottmann Apr 3, 2024
fd971e8
code review
Qottmann Apr 3, 2024
9dcefa5
Apply suggestions from code review
Qottmann Apr 3, 2024
472156a
merge
Qottmann Apr 3, 2024
6926e4f
docstring
Qottmann Apr 3, 2024
28717f2
docstring
Qottmann Apr 3, 2024
10a2408
sphinx
Qottmann Apr 3, 2024
8a4432e
sphinx
Qottmann Apr 3, 2024
5481209
Merge branch 'lieclosure2' of https://github.com/PennyLaneAI/pennylan…
Qottmann Apr 3, 2024
ceb5748
code review
Qottmann Apr 3, 2024
241e202
Apply suggestions from code review
Qottmann Apr 3, 2024
d8334e7
minus sign
Qottmann Apr 3, 2024
6ecc7ea
Merge branch 'adjointrepr' of https://github.com/PennyLaneAI/pennylan…
Qottmann Apr 3, 2024
3556fdf
black formatting
Qottmann Apr 3, 2024
3735b83
doc
Qottmann Apr 3, 2024
0c2b25e
changelog
Qottmann Apr 3, 2024
98f0718
clean up docstring
Qottmann Apr 3, 2024
b3a5db9
toctree
Qottmann Apr 3, 2024
95ec647
merge changelog
Qottmann Apr 3, 2024
b4fa8ba
headlines
Qottmann Apr 3, 2024
0621a0f
pylint disable
Qottmann Apr 3, 2024
338f294
empty pauli word re-use
Qottmann Apr 3, 2024
0db8031
Merge branch 'lieclosure2' of https://github.com/PennyLaneAI/pennylan…
Qottmann Apr 3, 2024
23b9790
black formatting
Qottmann Apr 3, 2024
366cab5
Merge branch 'master' of https://github.com/PennyLaneAI/pennylane int…
Qottmann Apr 4, 2024
96d5bdd
Merge branch 'lieclosure' of https://github.com/PennyLaneAI/pennylane…
Qottmann Apr 4, 2024
5be1bf7
add to index.rst
Qottmann Apr 4, 2024
6e54f4c
[ci skip]
Qottmann Apr 4, 2024
c73967f
trigger
Qottmann Apr 4, 2024
668c435
sphinx
Qottmann Apr 4, 2024
f4fc3dd
demo link
Qottmann Apr 4, 2024
bbc21c3
sphinx
Qottmann Apr 4, 2024
6845589
typo
Qottmann Apr 4, 2024
32e20f3
make static link
Qottmann Apr 4, 2024
6ac7857
linking format
Qottmann Apr 4, 2024
1bc212a
merge
Qottmann Apr 4, 2024
94bf765
unused import
Qottmann Apr 4, 2024
c9d7503
identation?
Qottmann Apr 4, 2024
dad5e9b
example simpler format
Qottmann Apr 4, 2024
ea65b95
docs
Qottmann Apr 5, 2024
5fb3922
docs fine tuning
Qottmann Apr 5, 2024
1753641
rename function to structure_constants
Qottmann Apr 5, 2024
705e589
rename files
Qottmann Apr 5, 2024
0477cbe
basic center function
Qottmann Apr 5, 2024
02c8371
black formatting
Qottmann Apr 5, 2024
86d8df6
center tests
Qottmann Apr 5, 2024
504699c
black formatting
Qottmann Apr 5, 2024
a178176
test coverage
Qottmann Apr 5, 2024
d7bea47
black formatting
Qottmann Apr 5, 2024
6e11d06
rename files
Qottmann Apr 5, 2024
018e661
Merge branch 'adjointrepr' of https://github.com/PennyLaneAI/pennylan…
Qottmann Apr 5, 2024
5f65572
Merge branch 'master' of https://github.com/PennyLaneAI/pennylane int…
Qottmann Apr 5, 2024
ba72e40
merge
Qottmann Apr 5, 2024
0ae6308
[ci skip]
Qottmann Apr 5, 2024
5ad3a2c
Merge branch 'lieclosure2' of https://github.com/PennyLaneAI/pennylan…
Qottmann Apr 5, 2024
152850a
Merge branch 'adjointrepr' of https://github.com/PennyLaneAI/pennylan…
Qottmann Apr 5, 2024
21a3568
docs and changelog
Qottmann Apr 5, 2024
0ef5bdf
black formatting
Qottmann Apr 5, 2024
0628a69
pylint
Qottmann Apr 5, 2024
c637576
code review: docs display
Qottmann Apr 5, 2024
403a7d2
code review
Qottmann Apr 5, 2024
9b12140
Merge branch 'lieclosure2' of https://github.com/PennyLaneAI/pennylan…
Qottmann Apr 5, 2024
9ef8ba7
code review
Qottmann Apr 5, 2024
72f399b
tests rearranged
Qottmann Apr 5, 2024
111bf91
tests rearranged
Qottmann Apr 5, 2024
bfa3b8e
black formatting
Qottmann Apr 5, 2024
ad99648
Apply suggestions from code review
Qottmann Apr 5, 2024
1d766aa
Merge branch 'master' of https://github.com/PennyLaneAI/pennylane int…
Qottmann Apr 8, 2024
52886be
Merge branch 'lieclosure' of https://github.com/PennyLaneAI/pennylane…
Qottmann Apr 8, 2024
b6e8af4
Merge branch 'lieclosure2' of https://github.com/PennyLaneAI/pennylan…
Qottmann Apr 8, 2024
180811c
Merge branch 'adjointrepr' of https://github.com/PennyLaneAI/pennylan…
Qottmann Apr 8, 2024
0b8d4aa
link in docs
Qottmann Apr 8, 2024
57429c2
Merge branch 'lieclosure2' of https://github.com/PennyLaneAI/pennylan…
Qottmann Apr 8, 2024
fd5a83c
return type
Qottmann Apr 8, 2024
399a723
typing and pauli keyword
Qottmann Apr 8, 2024
b3630aa
black formatting
Qottmann Apr 8, 2024
fe4fd23
Merge branch 'adjointrepr' of https://github.com/PennyLaneAI/pennylan…
Qottmann Apr 8, 2024
f2412b3
typing, docs
Qottmann Apr 8, 2024
f309be7
black formatting
Qottmann Apr 8, 2024
687f7aa
Update tests/dla/test_center.py
Qottmann Apr 8, 2024
689490b
Update tests/dla/test_center.py
Qottmann Apr 10, 2024
5e1497f
Merge branch 'master' of https://github.com/PennyLaneAI/pennylane int…
Qottmann Apr 12, 2024
1123fd2
code review: add correct error for pauli=True and wrong input types
Qottmann Apr 15, 2024
ea8e606
black formatting
Qottmann Apr 15, 2024
d3907b5
code review: shorten sentence
Qottmann Apr 15, 2024
531da00
Merge branch 'master' of https://github.com/PennyLaneAI/pennylane int…
Qottmann Apr 15, 2024
b5ac2aa
merge
Qottmann Apr 15, 2024
9afaf1a
Merge branch 'lieclosure2' of https://github.com/PennyLaneAI/pennylan…
Qottmann Apr 15, 2024
5f687cb
Merge branch 'adjointrepr' of https://github.com/PennyLaneAI/pennylan…
Qottmann Apr 15, 2024
8d100f4
Merge branch 'liecenter' of https://github.com/PennyLaneAI/pennylane …
Qottmann Apr 15, 2024
35f65fa
pylint
Qottmann Apr 15, 2024
10f9037
Merge branch 'lieclosure2' of https://github.com/PennyLaneAI/pennylan…
Qottmann Apr 15, 2024
b24969e
Merge branch 'adjointrepr' of https://github.com/PennyLaneAI/pennylan…
Qottmann Apr 15, 2024
66f7f3e
Merge branch 'master' of https://github.com/PennyLaneAI/pennylane int…
Qottmann Apr 16, 2024
db24ae9
refactor to ops/opmath
Qottmann Apr 16, 2024
e226615
add new files
Qottmann Apr 16, 2024
4dcf71e
black formatting
Qottmann Apr 16, 2024
f89612d
refactor to pauli module
Qottmann Apr 17, 2024
bb06cbc
merge
Qottmann Apr 17, 2024
4f17b8b
fix tests
Qottmann Apr 17, 2024
4a92bb4
black formatting
Qottmann Apr 17, 2024
c37f42a
refactor docs page
Qottmann Apr 17, 2024
eebed89
merge
Qottmann Apr 17, 2024
de91dcc
refactor
Qottmann Apr 17, 2024
889364d
docstring refactor
Qottmann Apr 17, 2024
ad00317
refactor
Qottmann Apr 17, 2024
b33c24b
black formatting
Qottmann Apr 17, 2024
bb413aa
remove from opmath toctree
Qottmann Apr 17, 2024
9f0c516
explicit list of ops in module description
Qottmann Apr 17, 2024
9cf1ac4
Merge branch 'master' of https://github.com/PennyLaneAI/pennylane int…
Qottmann Apr 17, 2024
55456df
remove from opmath toctree
Qottmann Apr 17, 2024
37a3501
remove linebreak
Qottmann Apr 17, 2024
92c9ad1
Merge branch 'lieclosure' of https://github.com/PennyLaneAI/pennylane…
Qottmann Apr 17, 2024
81f401c
cosmetic
Qottmann Apr 17, 2024
21404c0
cosmetic docs updates
Qottmann Apr 17, 2024
5fcc22f
Merge branch 'lieclosure2' of https://github.com/PennyLaneAI/pennylan…
Qottmann Apr 17, 2024
df12cd7
Merge branch 'adjointrepr' of https://github.com/PennyLaneAI/pennylan…
Qottmann Apr 17, 2024
4a73227
add to toc
Qottmann Apr 17, 2024
9b8abca
Merge branch 'adjointrepr' of https://github.com/PennyLaneAI/pennylan…
Qottmann Apr 17, 2024
addc325
add center to toc
Qottmann Apr 17, 2024
3e5e18d
top level import
Qottmann Apr 17, 2024
a6df873
Merge branch 'lieclosure2' of https://github.com/PennyLaneAI/pennylan…
Qottmann Apr 17, 2024
93ca8f5
top level import
Qottmann Apr 17, 2024
a05cda2
black formatting
Qottmann Apr 17, 2024
0a0527e
Merge branch 'adjointrepr' of https://github.com/PennyLaneAI/pennylan…
Qottmann Apr 17, 2024
0ac7f2e
top level import
Qottmann Apr 17, 2024
1484efd
cross-referencing
Qottmann Apr 17, 2024
db5662d
black formatting
Qottmann Apr 17, 2024
22abeff
see-also -> seealso
Qottmann Apr 17, 2024
f00cec7
specify cross reference
Qottmann Apr 17, 2024
c8923fd
Merge branch 'master' of https://github.com/PennyLaneAI/pennylane int…
Qottmann Apr 18, 2024
0e94c9a
code review: rephrase Args description to avoid confusion
Qottmann Apr 18, 2024
dc157e1
allow ops as inputs
Qottmann Apr 18, 2024
6a704cd
black formatting
Qottmann Apr 18, 2024
379d5fa
Apply suggestions from code review
Qottmann Apr 18, 2024
c863e5e
Merge branch 'lieclosure' of https://github.com/PennyLaneAI/pennylane…
Qottmann Apr 18, 2024
766d6fd
merge
Qottmann Apr 18, 2024
1f4f250
allow PauliWord instances as input when pauli=True
Qottmann Apr 18, 2024
6d0e5a5
verbosity set to bool instead of integer levels
Qottmann Apr 18, 2024
00e6dcc
Update doc/code/qml_pauli.rst
Qottmann Apr 18, 2024
e7f3097
Merge branch 'lieclosure2' of https://github.com/PennyLaneAI/pennylan…
Qottmann Apr 18, 2024
71502c4
small costmetics
Qottmann Apr 18, 2024
d92a31d
code review: use operators in doc string
Qottmann Apr 18, 2024
f748977
Merge branch 'lieclosure2' of https://github.com/PennyLaneAI/pennylan…
Qottmann Apr 18, 2024
9f97fc4
code review: changelog
Qottmann Apr 18, 2024
ae8dc9e
make index orderin more explicit
Qottmann Apr 18, 2024
2dfbf94
cosmetic changes to docs
Qottmann Apr 18, 2024
6dbb349
Merge branch 'lieclosure' of https://github.com/PennyLaneAI/pennylane…
Qottmann Apr 18, 2024
524d457
update module context
Qottmann Apr 18, 2024
8fa1aee
module context
Qottmann Apr 18, 2024
737f9c5
also link PauliVSpace
Qottmann Apr 18, 2024
169f2e0
Merge branch 'master' of https://github.com/PennyLaneAI/pennylane int…
Qottmann Apr 18, 2024
b33178f
add dtype option
Qottmann Apr 19, 2024
5da7b90
Merge branch 'master' of https://github.com/PennyLaneAI/pennylane int…
Qottmann Apr 19, 2024
29d21b5
add dtype test
Qottmann Apr 19, 2024
0331b90
black formatting
Qottmann Apr 19, 2024
371387b
Merge branch 'lieclosure' of https://github.com/PennyLaneAI/pennylane…
Qottmann Apr 19, 2024
cd6ed0d
Merge branch 'lieclosure2' of https://github.com/PennyLaneAI/pennylan…
Qottmann Apr 19, 2024
8f4af2e
Merge branch 'adjointrepr' of https://github.com/PennyLaneAI/pennylan…
Qottmann Apr 19, 2024
4747cab
Merge branch 'master' of https://github.com/PennyLaneAI/pennylane int…
Qottmann Apr 22, 2024
d04af94
Merge branch 'lieclosure' of https://github.com/PennyLaneAI/pennylane…
Qottmann Apr 22, 2024
3a4e171
code review suggestions
Qottmann Apr 22, 2024
ae37f93
Apply suggestions from code review
Qottmann Apr 22, 2024
95d190a
Merge branch 'lieclosure2' of https://github.com/PennyLaneAI/pennylan…
Qottmann Apr 22, 2024
b996e95
Apply suggestions from code review
Qottmann Apr 22, 2024
67bc40f
code review
Qottmann Apr 22, 2024
ece074a
Merge branch 'adjointrepr' of https://github.com/PennyLaneAI/pennylan…
Qottmann Apr 22, 2024
70537cf
trigger
Qottmann Apr 22, 2024
75277ba
merge
Qottmann Apr 23, 2024
f89d251
merge
Qottmann Apr 23, 2024
d948507
merge
Qottmann Apr 23, 2024
27ed468
merge
Qottmann Apr 23, 2024
414d267
merge
Qottmann Apr 23, 2024
5f98629
merge
Qottmann Apr 23, 2024
a3bb7b6
merge
Qottmann Apr 23, 2024
d12ccbb
Merge branch 'master' of https://github.com/PennyLaneAI/pennylane int…
Qottmann Apr 24, 2024
ee7d3b7
fix links and refer to top level functions in docs
Qottmann Apr 24, 2024
3944b08
changelog
Qottmann Apr 24, 2024
e2b1e1a
move center section in changelog to DLA section
Qottmann Apr 24, 2024
26cd7df
PauliWord also valid input, in particular when pauli=True
Qottmann Apr 24, 2024
310f7e6
add test for PauliWord inputs to ensure they are actually valid input…
Qottmann Apr 24, 2024
43133c3
black formatting
Qottmann Apr 24, 2024
dbbc8a0
Merge branch 'master' into liecenter
Qottmann Apr 24, 2024
2a17121
Merge branch 'master' into liecenter
Qottmann Apr 25, 2024
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
3 changes: 2 additions & 1 deletion doc/code/qml_pauli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ for Pauli-word partitioning functionality used in measurement optimization.
:no-heading:
:no-main-docstr:
:no-inherited-members:
:skip: lie_closure, structure_constants
:skip: lie_closure, structure_constants, center

PauliWord and PauliSentence
---------------------------
Expand Down Expand Up @@ -166,3 +166,4 @@ See our `introduction to Dynamical Lie Algebras for quantum practitioners <https

~lie_closure
~structure_constants
~center
15 changes: 12 additions & 3 deletions doc/releases/changelog-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,24 @@

For example, we can compute the adjoint representation of the transverse field Ising model DLA.

```pycon
```python
>>> dla = [X(0) @ X(1), Z(0), Z(1), Y(0) @ X(1), X(0) @ Y(1), Y(0) @ Y(1)]
>>> structure_const = qml.structure_constants(dla)
>>> structure_constp.shape
(6, 6, 6)
```

* We can compute the center of a dynamical Lie algebra.
[(#5477)](https://github.com/PennyLaneAI/pennylane/pull/5477)

Given a DLA `g`, we can now compute its center. The `center` is the collection of operators that commute with _all_ other operators in the DLA.

```pycon
>>> g = [X(0), X(1) @ X(0), Y(1), Z(1) @ X(0)]
>>> qml.center(g)
[X(0)]
```

<h4>Simulate mixed-state qutrit systems 3️⃣</h4>

* Functions `measure_with_samples` and `sample_state` have been added to the new `qutrit_mixed` module found in
Expand All @@ -190,8 +201,6 @@
for `preprocess`.
[(#5451)](https://github.com/PennyLaneAI/pennylane/pull/5451)

<h4>Work easily and efficiently with operators 🔧</h4>

<h3>Improvements 🛠</h3>

* Fixed typo and string formatting in error message in `ClassicalShadow._convert_to_pauli_words` when the input is not a valid pauli.
Expand Down
2 changes: 1 addition & 1 deletion pennylane/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import pennylane.qnn
import pennylane.templates
import pennylane.pauli
from pennylane.pauli import pauli_decompose, lie_closure, structure_constants
from pennylane.pauli import pauli_decompose, lie_closure, structure_constants, center
from pennylane.resource import specs
import pennylane.resource
import pennylane.qchem
Expand Down
2 changes: 1 addition & 1 deletion pennylane/pauli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@
graph_colouring,
)

from .dla import PauliVSpace, lie_closure, structure_constants
from .dla import PauliVSpace, lie_closure, structure_constants, center
1 change: 1 addition & 0 deletions pennylane/pauli/dla/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@
"""

from .structure_constants import structure_constants
from .center import center
from .lie_closure import PauliVSpace, lie_closure
78 changes: 78 additions & 0 deletions pennylane/pauli/dla/center.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Copyright 2024 Xanadu Quantum Technologies Inc.

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""A function to compute the center of a Lie algebra"""
from typing import List, Union
from itertools import combinations

import numpy as np

from pennylane.pauli import PauliSentence, PauliWord
from pennylane.operation import Operator


def center(
g: List[Union[Operator, PauliWord, PauliSentence]], pauli: bool = False
) -> List[Union[Operator, PauliSentence]]:
r"""
A function to compute the center of a Lie algebra.

Given a Lie algebra :math:`\mathfrak{g} = \{h_1,.., h_d\}`, the center :math:`\mathfrak{\xi}(\mathfrak{g})`
is given by all elements in :math:`\mathfrak{g}` that commute with `all` other elements in :math:`\mathfrak{g}`,

.. math:: \mathfrak{\xi}(\mathfrak{g}) := \{h \in \mathfrak{g} | [h, h_i]=0 \ \forall h_i \in \mathfrak{g} \}

Args:
g (List[Union[Operator, PauliSentence, PauliWord]]): List of operators for which to find the center.
pauli (bool): Indicates whether it is assumed that :class:`~.PauliSentence` or :class:`~.PauliWord` instances are input and returned.
This can help with performance to avoid unnecessary conversions to :class:`~pennylane.operation.Operator`
and vice versa. Default is ``False``.

Returns:
List[Union[Operator, PauliSentence]]: Center of ``g``

.. seealso:: :func:`~lie_closure`, :func:`~structure_constants`, :class:`~pennylane.pauli.PauliVSpace`, `Demo: Introduction to Dynamical Lie Algebras for quantum practitioners <https://pennylane.ai/qml/demos/tutorial_liealgebra/>`__

**Example**

We can compute the center of a DLA ``g``. For that, we compute the DLA via :func:`~lie_closure`.

>>> generators = [qml.X(0), qml.X(0) @ qml.X(1), qml.Y(1)]
>>> g = qml.lie_closure(generators)

The ``center`` is then the collection of operators that commute with `all` other operators in the DLA.
In this case, just ``X(0)``.

>>> qml.center(g)
[X(0)]

"""

if not pauli:
g = [o.pauli_rep for o in g]

d = len(g)
commutators = np.zeros((d, d), dtype=int)
for (j, op1), (k, op2) in combinations(enumerate(g), r=2):
res = op1.commutator(op2)
res.simplify()
if res != PauliSentence({}):
commutators[j, k] = 1 # dummy value to indicate operators dont commute
commutators[k, j] = 1

mask = np.all(commutators == 0, axis=0)
res = list(np.array(g)[mask])

if not pauli:
res = [op.operation() for op in res]
return res
6 changes: 4 additions & 2 deletions pennylane/pauli/dla/lie_closure.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ def lie_closure(
Union[list[:class:`~.PauliSentence`], list[:class:`~.Operator`]]: a basis of either :class:`~.PauliSentence` or :class:`~.Operator` instances that is closed under
commutators (Lie closure).

.. seealso:: :func:`~structure_constants`, :func:`~center`, :class:`~pennylane.pauli.PauliVSpace`, `Demo: Introduction to Dynamical Lie Algebras for quantum practitioners <https://pennylane.ai/qml/demos/tutorial_liealgebra/>`__

**Example**

Let us walk through a simple example of computing the Lie closure of the generators of the transverse field Ising model on two qubits.
Expand All @@ -74,7 +76,7 @@ def lie_closure(
This can be done in short via ``lie_closure`` as follows.

>>> ops = [X(0) @ X(1), Z(0), Z(1)]
>>> dla = qml.pauli.lie_closure(ops)
>>> dla = qml.lie_closure(ops)
>>> print(dla)
[X(1) @ X(0),
Z(0),
Expand All @@ -98,7 +100,7 @@ def lie_closure(
... PauliSentence({PauliWord({0: "Z"}): 1.}),
... PauliSentence({PauliWord({1: "Z"}): 1.}),
... ]
>>> dla = qml.pauli.lie_closure(ops, pauli=True)
>>> dla = qml.lie_closure(ops, pauli=True)
>>> print(dla)
[1.0 * X(0) @ X(1),
1.0 * Z(0),
Expand Down
6 changes: 4 additions & 2 deletions pennylane/pauli/dla/structure_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,22 @@ def structure_constants(
Returns:
TensorLike: The adjoint representation of shape ``(d, d, d)``, corresponding to indices ``(gamma, alpha, beta)``.

.. seealso:: :func:`~lie_closure`, :func:`~center`, :class:`~pennylane.pauli.PauliVSpace`, `Demo: Introduction to Dynamical Lie Algebras for quantum practitioners <https://pennylane.ai/qml/demos/tutorial_liealgebra/>`__

**Example**

Let us generate the DLA of the transverse field Ising model using :func:`~lie_closure`.

>>> n = 2
>>> gens = [X(i) @ X(i+1) for i in range(n-1)]
>>> gens += [Z(i) for i in range(n)]
>>> dla = qml.pauli.lie_closure(gens)
>>> dla = qml.lie_closure(gens)
>>> print(dla)
[X(1) @ X(0), Z(0), Z(1), -1.0 * (X(1) @ Y(0)), -1.0 * (Y(1) @ X(0)), -1.0 * (Y(1) @ Y(0))]

The dimension of the DLA is :math:`d = 6`. Hence, the structure constants have shape ``(6, 6, 6)``.

>>> adjoint_rep = qml.pauli.structure_constants(dla)
>>> adjoint_rep = qml.structure_constants(dla)
>>> adjoint_rep.shape
(6, 6, 6)

Expand Down
2 changes: 1 addition & 1 deletion pennylane/pulse/transmon.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def angular_fn(p, t):
class TransmonSettings:
"""Dataclass that contains the information of a Transmon setup.

.. see-also:: :func:`transmon_interaction`
.. seealso:: :func:`transmon_interaction`

Args:
connections (List): List `[[idx_q0, idx_q1], ..]` of connected qubits (wires)
Expand Down
85 changes: 85 additions & 0 deletions tests/pauli/dla/test_center.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Copyright 2024 Xanadu Quantum Technologies Inc.

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Tests for pennylane/dla/center.py functionality"""

import pytest

import pennylane as qml

from pennylane.pauli import PauliSentence, center


def test_trivial_center():
"""Test that the center of an empty list of generators is an empty list of generators."""
ops = []
res = center(ops)
assert res == []


DLA_CENTERS = (
([qml.I()], [qml.I()]), # just the identity
([qml.I(), qml.X(0)], [qml.I(), qml.X(0)]), # identity and some other operator
([qml.X(0), qml.X(1)], [qml.X(0), qml.X(1)]), # two non-overlapping wires
([qml.X(0), qml.Y(1)], [qml.X(0), qml.Y(1)]), # two non-overlapping wires with different ops
([qml.X(0), qml.Y(0), qml.Z(0), qml.I()], [qml.I()]), # non-trivial DLA, but trivial center
)


@pytest.mark.parametrize("ops, true_res", DLA_CENTERS)
def test_center(ops, true_res):
"""Test centers with Identity operators or non-overlapping wires"""
res = center(ops)
assert res == true_res


@pytest.mark.parametrize("ops, true_res", DLA_CENTERS)
def test_center_pauli(ops, true_res):
"""Test centers with Identity operators or non-overlapping wires using their pauli_rep"""
ops = [op.pauli_rep for op in ops]
res = center(ops, pauli=True)

assert all(isinstance(op, PauliSentence) for op in res)
true_res = [op.pauli_rep for op in true_res]
assert res == true_res


@pytest.mark.parametrize("pauli", [False, True])
def test_center_pauli_word_pauli_True(pauli):
"""Test that PauliWord instances can be passed for both pauli=True/False"""
ops = [
qml.pauli.PauliWord({0: "X"}),
qml.pauli.PauliWord({0: "X", 1: "X"}),
qml.pauli.PauliWord({1: "Y"}),
]
if pauli:
assert qml.center(ops, pauli=pauli) == [qml.pauli.PauliWord({0: "X"})]
else:
assert qml.center(ops, pauli=pauli) == [qml.X(0)]


GENERATOR_CENTERS = (
([qml.X(0), qml.X(0) @ qml.X(1), qml.Y(1)], [qml.X(0)]),
([qml.X(0) @ qml.X(1), qml.Y(1), qml.X(0)], [qml.X(0)]),
([qml.X(0) @ qml.X(1), qml.Y(1), qml.X(1)], []),
([qml.X(0) @ qml.X(1), qml.Y(1), qml.Z(0)], []),
([p(0) @ p(1) for p in [qml.X, qml.Y, qml.Z]], [p(0) @ p(1) for p in [qml.X, qml.Y, qml.Z]]),
)


@pytest.mark.parametrize("generators, true_res", GENERATOR_CENTERS)
def test_center_dla(generators, true_res):
"""Test computing the center for a non-trivial DLA"""
g = qml.pauli.lie_closure(generators)
res = center(g)
assert res == true_res
Loading