pennylane
pennylane copied to clipboard
Compute matrix of only the operators that act on overlapping wires
- Add
overlapping_ops
property to theComposite
class. - Improve performance of
eigvals
,diagonalizing_gates
andProd.matrix
methods using the aforementioned property. - Move
eigvals
method to theComposite
class. To do so I defined a new class attribute that defines the math operator that will be applied to the operands eigenvalues (math.prod
forProd
andmath.sum
forSum
).
Notes:
When computing the eigvals
or diagonalizing_gates
of a Composite
operator, we computed the whole matrix when the operands had overlapping wires.
Now we separate the operands into subgroups that commute with each other, and only compute the matrices of these subgroups.
Hello. You may have forgotten to update the changelog!
Please edit doc/releases/changelog-dev.md
with:
- A one-to-two sentence description of the change. You may include a small working example for new features.
- A link back to this PR.
- Your name (or GitHub username) in the contributors section.
Codecov Report
Merging #3084 (91518f1) into master (a8a47d5) will increase coverage by
0.00%
. The diff coverage is100.00%
.
@@ Coverage Diff @@
## master #3084 +/- ##
=======================================
Coverage 99.69% 99.69%
=======================================
Files 276 276
Lines 24232 24273 +41
=======================================
+ Hits 24159 24200 +41
Misses 73 73
Impacted Files | Coverage Δ | |
---|---|---|
pennylane/ops/op_math/composite.py | 100.00% <100.00%> (ø) |
|
pennylane/ops/op_math/prod.py | 100.00% <100.00%> (ø) |
|
pennylane/ops/op_math/sum.py | 100.00% <100.00%> (ø) |
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.
Sum operator
-
Before:
-
After:
The wires of the summands are sampled randomly. We can see that there is a huge speedup when there is a subset of operators that act on overlapping wires.
Prod operator
-
Before:
-
After:
Prod operator matrix computation
-
Before
-
After
[sc-26176]