-
Notifications
You must be signed in to change notification settings - Fork 2
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
[Feature] Add quantum information tools #16
Conversation
Hey @inafergra thank you for this. Is this ready for review ? In case, you should un-draft it. |
It is ready for review now |
Thanks Ignacio! I think you should add the qinfo_tools imports to the init.py of the package in the same way as the constructors. I am testing it with some PDEs and will try to add a proper review soon. |
Thanks @inafergra. Is this reviewable ? Another quick question: would it make sense to move SPSA to PyQ as another differentiation method ? |
@Roland-djee we can add spsa in pyq but the implementation in this MR is highly geared towards ignacios usecase, it for example works only for overlap models which do not exist atm in pyq |
@Roland-djee I still need to add some tests related to the indexing order of the vparams. I'll mark this PR as a draft until it's done. Regarding the SPSA approximation, I agree with Dominik, it can make sense to place it in PyQ in the future but that will require generalizing the module quite a bit. |
The PR is ready for review now. I have tried to implement the changes as discussed in the comments and in our meetings, mainly:
|
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.
Thanks @inafergra. Looking good to me. Will approve as soon as comments are addressed.
Co-authored-by: Roland-djee <[email protected]>
Thank you for the comments @Roland-djee, all addressed. Ready to merge |
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.
Thanks @inafergra looking very nice.
Thanks @Roland-djee, will merge now! |
This PR follows the work of this old qadence PR. It adds a subpackage
qinfo_tools
containing different quantum information-related functionalities. The three files of the subpackage are:qadence_libs/qinfo_tools/qfi.py
contains code related to the calculation of the Quantum Fisher Information (QFI) matrix. The functionget_quantum_fisher()
calculates the QFI matrix of aQuantumCircuit
in an exact way, while theget_quantum_fisher_spsa()
can be used to iteratively construct an approximation of the QFI matrix through the SPSA algorithm.qadence_libs/qinfo_tools/spsa.py
contains the code to calculate the SPSA gradients. Only the second order gradient is used in the QNG-SPSA optimizer but the first order gradient is also implemented for completeness.qadence_libs/qinfo_tools/qng.py
file implementing the Quantum Natural Gradient (QNG) and the QNG-SPSA optimizers. Both optimizers use the QFI matrix in the parameter update rule to better navigate the gradient descent. The QNG uses the exact QFI matrix, which takesA new section in the docs has also been created for quantum information related topics, with a file explaining how to use the QNG and QNG-SPSA optimizers for an easy QCL problem. Since there was yet no files in the documentation, this PR also adds a
docs/docsutils.py
file with afig_to_html()
function to print images in the docs (same as in the Qadence repo) and adocs/environment.yml
for the python environment (also same as in Qadence).