-
Notifications
You must be signed in to change notification settings - Fork 586
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[new opmath 2] New
LinearCombination
class to succeed `qml.Hamilton…
…ian` (#5216) Branching: #5269 > #5216 > #5322 > #5335 The basic idea is to have a clone of `qml.Hamiltonian` with a better name, `LinearCombination` - that inherits from `CompositeOp` and plays nice with new opmath. The motivation is that sometimes it is still handy to have an operator class for which you _know_ there is no funny nesting and that has `coeffs` and `ops` separately on demand without processing. ToDo - [x] basic init - [x] `tests/ops/op_math/test_linear_combination.py` pass - [x] update map_wires - [x] all tests pass - [x] add pauli_rep - [x] add operands attribute and make iterable (?) - [x] update string repr - [x] upgrade to internally use new opmath - [x] update tests with default new opmath - [x] dunder math methods support with new opmath - [x] simplify and speed-up `simplify()`, also make sure to not act in-place - [x] Could we make the matrix generation workflow more general like Sum? - [x] Also, deferring to the pauli rep method for matrix generation leads to substantial performance improvements. - [x] toggle `__use_new_opmath` - [x] tests_linear_combination pass - [x] Integration tests - [x] get all linear combination tests to pass locally - [x] utilize super().sparse_matrix - [x] use grouping functionality from Sum that Mudit is adding in #5179 - [x] update matmul to handle other LinearCombination instances - [x] remove top level import - [x] remove unnecessary copies - [x] add diagonalizing gates - [x] bugfix trivial case of simplify empty LinearCombination - [x] add trivial case for is_hermitian - [ ] torch differentiation with simplify=True in constructor - [x] changelog Optional features (likely to be included in a follow-up) - [x] `qml.Hamiltonian` points to either old Hamiltonian or LinearCombination depending on `__use_new_opmath` - [x] support Hermitian - [ ] matrix method (optional) - [ ] adjoint method (optional) - [ ] batching support (optional) - [ ] qml.dot points to LinearCombination - [ ] take care of xfails (mostly about raiseing errors in other parts of the codebase) - [ ] update logic of adjoint differentiation to catch attempt to differentiate lincomb coeffs - [x] support in qml.equal - [x] add special matmul with other product or non-composite ops - [x] add special matmul with other LinearCombination [sc-56704] --------- Co-authored-by: lillian542 <38584660+lillian542@users.noreply.github.com> Co-authored-by: Astral Cai <astral.cai@xanadu.ai> Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai> Co-authored-by: Christina Lee <christina@xanadu.ai> Co-authored-by: Pietropaolo Frisoni <pietropaolo.frisoni@xanadu.ai> Co-authored-by: albi3ro <chrissie.c.l@gmail.com> Co-authored-by: Utkarsh <utkarshazad98@gmail.com> Co-authored-by: lillian542 <Lillian.frederiksen@xanadu.ai> Co-authored-by: Alex Preciado <alex.preciado@xanadu.ai> Co-authored-by: Thomas R. Bromley <49409390+trbromley@users.noreply.github.com> Co-authored-by: Vincent Michaud-Rioux <vincentm@nanoacademic.com> Co-authored-by: Josh Izaac <josh146@gmail.com> Co-authored-by: Nathan Killoran <co9olguy@users.noreply.github.com> Co-authored-by: Matthew Silverman <matthews@xanadu.ai> Co-authored-by: Mikhail Andrenkov <mikhail@xanadu.ai> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
aaa07da
commit 7343038
Showing
143 changed files
with
6,858 additions
and
2,407 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,6 +68,7 @@ | |
"Projector", | ||
"SparseHamiltonian", | ||
"Hamiltonian", | ||
"LinearCombination", | ||
"Sum", | ||
"SProd", | ||
"Prod", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.