-
Notifications
You must be signed in to change notification settings - Fork 603
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
[QIM-8] Add quantum_fisher
#2676
Conversation
Co-authored-by: antalszava <antalszava@gmail.com> Co-authored-by: Edward Jiang <34989448+eddddddy@users.noreply.github.com>
Codecov Report
@@ Coverage Diff @@
## classicalfisher #2676 +/- ##
===================================================
- Coverage 99.59% 99.59% -0.01%
===================================================
Files 253 253
Lines 20375 20384 +9
===================================================
+ Hits 20293 20301 +8
- Misses 82 83 +1
Continue to review full report at Codecov.
|
🎉 |
Co-authored-by: Romain Moyard <rmoyard@gmail.com>
Co-authored-by: Romain Moyard <rmoyard@gmail.com>
Co-authored-by: Romain Moyard <rmoyard@gmail.com>
Co-authored-by: Romain Moyard <rmoyard@gmail.com>
Co-authored-by: Romain Moyard <rmoyard@gmail.com>
Co-authored-by: Romain Moyard <rmoyard@gmail.com>
Co-authored-by: Romain Moyard <rmoyard@gmail.com>
Co-authored-by: Romain Moyard <rmoyard@gmail.com>
Co-authored-by: Romain Moyard <rmoyard@gmail.com>
Co-authored-by: Romain Moyard <rmoyard@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good @Qottmann! 💯
@@ -236,3 +237,27 @@ def _make_probs(tape, wires=None, post_processing_fn=None): | |||
post_processing_fn = lambda x: qml.math.squeeze(qml.math.stack(x)) | |||
|
|||
return [new_tape], post_processing_fn | |||
|
|||
|
|||
def quantum_fisher(*args, **kwargs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Side note (no action needed): qml.metric_tensor
is differentiable, so all the more reason to support differentiability of classical_fisher
in the near future.
- \langle \partial_i \psi(\bm{\theta}) | \psi(\bm{\theta}) \rangle \langle \psi(\bm{\theta}) | \partial_j \psi(\bm{\theta}) \rangle \right] | ||
|
||
with short notation :math:`| \partial_j \psi(\bm{\theta}) \rangle := \frac{\partial}{\partial \theta_j}| \psi(\bm{\theta}) \rangle`. | ||
It is closely related to the quantum fisher information matrix, see :func:`~.pennylane.qinfo.quantum_fisher` and eq. (27) in `arxiv:2103.15191 <https://arxiv.org/abs/2103.15191>`_. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The link to pennylane.qinfo.quantum_fisher
doesn't seem to be working. Same with the one in the seealso
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep I also noticed that. Any idea on how to fix it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No idea 😆
.. seealso:: | ||
:func:`~.pennylane.adjoint_metric_tensor`; ``quantum_fisher()`` is simply calling :func:`~.pennylane.metric_tensor` with a prefactor of 4. Please refer there for implementation details. | ||
""" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good to add a check here for the shots in tape, such that metric_tensor
can be passed if they are finite and adjoint_metric_tensor
when they are None. Is that possible for transforms like these?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a really good idea! This isn't currently possible, but we would like to overhaul how shots are architected internally, so that this does become possible.
Currently, shots are stored at the device, not at the transform level
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So for the moment maybe add a boolean variable hardware
(or something better) and just do an if-clause?
Due to many changes in the base branch started a new PR to simplify things: #2684 |
Context:
Added a dummy function
qml.qinfo.quantum_fisher
that internally callsqml.metric_tensor
and multiplies the result by 4 to have the same scaling factor as in eq. (27) in 2103.15191.Additionally, I modified the doc-string of
qml.metric_tensor
accordingly.