question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Avoid diagonalizing generators every time a parameter shift jacobian is calculated

See original GitHub issue

This is just a suggestion, feel free to ignore:

These lines of code are executed many times when constructing the recipe during parameter shift jacobian computation:

https://github.com/PennyLaneAI/pennylane/blob/ca0c079905974ddd3735177a306fad61ce7c9ded/pennylane/operation.py#L1212-L1218

The construction of the generator and its diagonalization are relatively expensive operations given the frequency with which these lines are executed, especially when the generator is larger than just a 2x2 matrix. Double construction of the generator can be avoided trivially by re-using gen in place of self.generator() in line 1217 the eigenvalues can probably be either cached in the Operator class or instance or Operations can at least be given the option to specify their generator eigenvalues directly to avoid matrix diagonalization.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
cvjjmcommented, Feb 23, 2022

Nice! Thanks for the explanation! In my case this lead to nearly double the execution time with master compared to v0.21.0, which is why I noticed.

It would be great if this could all be documented in the new guide on how to write custom Operations.

0reactions
cvjjmcommented, Mar 25, 2022

Yes, this seems to be resolved. Thanks for the good work!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Avoiding and Suppressing Oscillations - IAN DOBSON
Figure 2 shows how some eigenvalues change with the parameters. At the final value, an eigenvalue λ = 0.1324 + 3.0767j is located...
Read more >
Path Integrals on sl(2,R) Orbits - arXiv
A new challenge and our main interest lies in understanding the path integral quantization when the orbit is sliced according to the action...
Read more >
NUMERICAL METHODS FOR LARGE EIGENVALUE ...
Proposition 1.3 A matrix is diagonalizable if and only if all its eigenvalues are semi-simple. Since every simple eigenvalue is semi-simple, an immediate ......
Read more >
5 the jacobian in path integrals and quantum anomalies
This chapter gives a general path integral formulation of the quantum anomaly for chiral symmetry. The quantum anomaly is identified as the Jacobian...
Read more >
Is strong modal resonance a precursor to power system ...
For example, parameter changes such as bulk power transactions or generator redis- patch change the power system equilibrium, and hence change.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found