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.

Hermitian observables and (avoiding) diagonalization of (large) matrices

See original GitHub issue

Feature details

This is half a question and half a feature / documentation request.

One issue with the qml.Hermitian observable is that (at least when running on default.qubit) its .matrix is diagonalized (via .diagonalizing_gates) even to compute return values such as qml.expval(qml.Hermitiaion(...)) and qml.var(qml.Hermitiaion(...)), which could be computed via a simple matrix vector (inner)products. This is already not ideal performance wise when the qml.Hermitian observable acts on few wires, but gets worse exponentially for large number of wires.

Looking into DefaultQubit.expval() I get the impression that for qml.Hamiltonian and qml.SparseHamiltonian this diagonalization is avoided.

So, am I right that wrapping a qml.Hermitian observable in a qml.Hamiltonian (as also discussed here) avoids the diagonalization?

  • Maybe it would be worth explaining this to users?
  • Maybe the same trick could be enabled to also speed up var()?
  • Maybe this wrapping, which is counter intuitive and difficult to explain to users could be avoided altogether by calculating the diagonalizing gates of qml.Hermitian only when the user executes a QNode with a return type that requires diagonalization such as qml.probs() but not for expval or var?

Implementation

No response

How important would you say this feature is?

1: Not important. Would be nice to have.

Additional information

No response

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
cvjjmcommented, Mar 25, 2022

This is also related to #1344

1reaction
cvjjmcommented, Mar 3, 2022

Agree, but tape.diagonalizing_gates is not part of the public API, isn’t it? So breaking is not an issue here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Block diagonalisation of Hermitian matrices - ResearchGate
There are infinitely many different unitary transformations which bring a given Hermitian matrix into block diagonal form.
Read more >
Eigenvalues, Hermitian operators and observables in ...
The operator is diagonalizable and the values of the diagonal are its eigenvalues. An observable is a Hermitian operator whose eigenvectors ...
Read more >
Diagonalizing Hermitian Operators - YouTube
Hermitian operators on finite-dimensional vector spaces are always diagonalizable, with real eigenvalues and orthogonal eigenvectors.
Read more >
A new method for diagonalising large matrices
The method requires the direct diagonalisation of only a small submatrix, does not require the storage of the large matrix and provides.
Read more >
arXiv:2006.01837v1 [cond-mat.mes-hall] 2 Jun 2020
which can be considered as the generalization of the diagonalized form for Hermitian matri- ces to general non-Hermitian matrices as follows ...
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