-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Variational Quantum Time Evolution algorithm. #8152
Conversation
Updates on Class Documentation
Co-authored-by: Julien Gacon <gaconju@gmail.com>
…rs/evolution_grad_calculator.py Co-authored-by: Julien Gacon <gaconju@gmail.com>
…/gradient_errors/error_calculator.py Co-authored-by: Julien Gacon <gaconju@gmail.com>
Unit test values have been verified for metric tensor and evolution gradient using independent methods. Thank you @Zoufalc for preparing the notebook for that. |
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.
I played with it a little today and it works nicely! I left some comments below that I think are quick to do and would improve the usage a lot. The one thing that didn't work well was using e.g. "RK45" as an ODE solver, which ran forever (even for a 2 qubit problem). But not sure if there's anything we can do about that.
Also I think it would be really important to add the ability to store observables during the time evolution before the 0.22 release 🙂
qiskit/algorithms/evolvers/variational/variational_principles/real_mc_lachlan_principle.py
Outdated
Show resolved
Hide resolved
qiskit/algorithms/evolvers/variational/solvers/ode/var_qte_ode_solver.py
Outdated
Show resolved
Hide resolved
Co-authored-by: Julien Gacon <gaconju@gmail.com>
@@ -72,7 +72,7 @@ def __init__( | |||
self, | |||
ansatz: Union[OperatorBase, QuantumCircuit], | |||
variational_principle: Optional[ImaginaryVariationalPrinciple] = None, | |||
ansatz_init_param_values: Optional[ | |||
initial_parameters: Optional[ |
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.
I was wondering why I did not see this change show up in tests and say example above. In these it seems the parameters are always passed positionally.
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.
I think we are there, all looks good to me - thanks for all the hard work, responding and acting on review comments etc.
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 a lot for all the effort! 🙂
* Fixed requirements-dev.txt * Fixed some pylint. * Fixed some pylint. * Update Documentation variational principles * updates documentation * minor documentation * Added unit tests docs and some package docs. * Code refactoring. * Code refactoring. * Code refactoring. * Update qiskit/opflow/evolutions/pauli_trotter_evolution.py Co-authored-by: Julien Gacon <gaconju@gmail.com> * Renamed the main folder. * Code refactoring. * Update qiskit/algorithms/quantum_time_evolution/variational/calculators/evolution_grad_calculator.py Co-authored-by: Julien Gacon <gaconju@gmail.com> * Code refactoring. * Update qiskit/algorithms/time_evolution/variational/error_calculators/gradient_errors/error_calculator.py Co-authored-by: Julien Gacon <gaconju@gmail.com> * Code refactoring. * Lint fixes. * Code refactoring. * Code refactoring. * Code refactoring. * Code refactoring. * Code refactoring, docs fixed. * Code refactoring, docs fixed. * Code refactoring and docs improved. * Exposed optimizer tolerance as an argument. * Exposed allowed imaginary part as an argument. * Exposed allowed numerical instability as an argument. * Code refactoring. * Introduced evolution_result.py class. * Minor bugfix. * Integrated evolution result to VarQte algorithms. * Code refactoring. * Black formatting fix. * Fixed signatures. * Fixed random seed setup. * Fixed too long lines. * Deleted unnecessary files. * Some fixes in test_gradients.py * Copyright date updated. * Refactored getting rid of flags. * Updated unit tests after refactoring. * Removed a duplicated argument. * Implemented general Quantum Time Evolution Framework interfaces. * Updated docs. * Reno added. * Improved reno. * Code refactoring. * Code refactoring. * Typehints added. * Made variational_principle.py stateless. * Updated copyright years. * Simplified var_qte.py class. * Refactored var_qte_linear_solver.py * Refactored abstract_ode_function_generator.py * Refactored var_qte_linear_solver.py * Refactored var_qte.py * Code formatting. * ODE solvers and optimizers as objects, not strings. * Update qiskit/algorithms/time_evolution/evolution_base.py Co-authored-by: Julien Gacon <gaconju@gmail.com> * Code refactoring. * Introduced evolution problem classes. * Code refactoring. * Apply suggestions from code review Co-authored-by: Julien Gacon <gaconju@gmail.com> * Added unit tests. * Lint fixed. * Code refactoring. * Removed error_based_ode_function_generator.py for MVP. * Code refactoring * Code refactoring * Code refactoring * Code refactoring * Code refactoring * Code review changes. * Removed gradient code for now. * Evolving observable removed. Evaluating observables added. * Improved naming. * Improved folder structure; filled evolvers init file. * Added Evolvers to algorithms init file. * Fixed missing imports. * Code refactoring * Fixed cyclic imports. * Extracted ListOrDict. * Code refactoring. * Code refactoring. * Fixed release note. * Fixed inheritance order. * Code refactoring. * Code refactoring. * Fixed cyclic imports. * Name fix. * Updated the algorithm to the latest version of interfaces. * Code refactoring. * Adapted unit tests to evolution problem. * Implemented aux_ops evaluation. * Fixed position of quantum_instance. * Added algorithms to algorithms init. * Imports refactoring. * Imports refactoring. * Updated code to the latest gradient framework. * Code refactoring. * Imports refactoring. * Added gradient files. * Code review addressed. Fixed tests. * Switched to 1 sampler. * Added unit tests for expected errors. * Improved docs. * Changed folder structure. * Added test_evolution_grad_calculator.py unit test with bases. * Updated interfaces. * Added VarQite unit test with aux ops. * Added VarQite unit test with aux ops. * Added VarQrte unit test with aux ops. * Update releasenotes/notes/add-variational-quantum-time-evolution-112ffeaf62782fea.yaml Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com> * Code refactoring. * Code refactoring. * Code refactoring. * Improved docs of variational principles. * Code refactoring. * Code refactoring. * Simplified var principles folder structure. * Opened VarQte algorithms for field modification. * Improved Sphinx docs. * Code refactoring. * Introduced ode_function_factory.py * Removed hardcoded rcond. * Renamed hamiltonian_value_dict. * Renamed hamiltonian_value_dict. * Extracted lengthy expected results in tests. * Updated unit tests. * Apply suggestions from code review Co-authored-by: Julien Gacon <gaconju@gmail.com> * Apply suggestions from code review * Extended release notes. * Removed dead code. * Improved ode solver types. * Moved evolve method for now. * Shortened Var Principles names. * Updated metric_tensor_calculator.py * Updated docs * Removed ordered_parameters. * Added and corrected code examples. * Extended unit tests. * Extended unit tests. * Extended unit tests. * Improved init files. * Improved init files. * Improved init files. * Improved init files. * Improved docs. * Import fix * Renamed sle to lse. * Code refactoring. * Replaced metric tensor calculator. * Replaced evolution gradient calculator. * Code refactoring. * Removed evolution_grad_calculator.py * Removed evolution_grad_calculator.py * Evolution grad calculator removal; code refactoring; dirty bug fix. * Added docs. * Code refactoring * Improved performance of evolution grad. * Improved performance of evolution grad, code refactoring; bug fixed. * Improved LSE solver handling. * Improved docs. * Unindented reno * Mitigated some cyclic imports. * Unindented reno * Improved docs * Lint resolutions * Fix some line-too-long in tests * Fixed lint. * Fixed lint. * Apply suggestions from code review Co-authored-by: Julien Gacon <gaconju@gmail.com> * Code review changes. * Added reno for a bug fix. * Fixed lint. * Updated docs. * Moved lse_solver to ODE factory. * Made ODE factory optional and defaults set. * Added expectation method argument and set defaults to PauliExpectation. * Limited supported methods for real_time_dependent_principle.py. * Fix imports. * Updated docs. * Implemented the Forward Euler ODE solver. Implemented a unit test. * Set Forward Euler ODE solver as a default. Updated unit tests. * Sync with main. * Exposed ODE number of steps. * Code refactoring * Code refactoring * Code refactoring * Exposed ode_num_t_steps to the user; reduced default ode_num_t_steps; added ForwardEulerSolver to docs. * Updated tests. * Fixed CI. * Fixed docs. * Hides OdeFunction from the user. * Update qiskit/algorithms/evolvers/variational/var_qrte.py Co-authored-by: Julien Gacon <gaconju@gmail.com> * Update releasenotes/notes/add-variational-quantum-time-evolution-112ffeaf62782fea.yaml Co-authored-by: Julien Gacon <gaconju@gmail.com> * Removes unsupported error-based method flag for now. * Switched num time steps to deltas in ODEs. * Code refactoring. * Fixed typhint. * Switched back to num_steps for ODE. * Slow tests and code refactoring. * Code refactoring. * Removed TD variational principle. * Apply suggestions from code review Co-authored-by: Julien Gacon <gaconju@gmail.com> * Code refactoring. * Improved signatures; support for list of parameter values. * Code refactoring. * Improved variable name. * Updated docs. Co-authored-by: CZ <ouf@zurich.ibm.com> Co-authored-by: Julien Gacon <gaconju@gmail.com> Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com> Co-authored-by: woodsp-ibm <woodsp@us.ibm.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* Fixed requirements-dev.txt * Fixed some pylint. * Fixed some pylint. * Update Documentation variational principles * updates documentation * minor documentation * Added unit tests docs and some package docs. * Code refactoring. * Code refactoring. * Code refactoring. * Update qiskit/opflow/evolutions/pauli_trotter_evolution.py Co-authored-by: Julien Gacon <gaconju@gmail.com> * Renamed the main folder. * Code refactoring. * Update qiskit/algorithms/quantum_time_evolution/variational/calculators/evolution_grad_calculator.py Co-authored-by: Julien Gacon <gaconju@gmail.com> * Code refactoring. * Update qiskit/algorithms/time_evolution/variational/error_calculators/gradient_errors/error_calculator.py Co-authored-by: Julien Gacon <gaconju@gmail.com> * Code refactoring. * Lint fixes. * Code refactoring. * Code refactoring. * Code refactoring. * Code refactoring. * Code refactoring, docs fixed. * Code refactoring, docs fixed. * Code refactoring and docs improved. * Exposed optimizer tolerance as an argument. * Exposed allowed imaginary part as an argument. * Exposed allowed numerical instability as an argument. * Code refactoring. * Introduced evolution_result.py class. * Minor bugfix. * Integrated evolution result to VarQte algorithms. * Code refactoring. * Black formatting fix. * Fixed signatures. * Fixed random seed setup. * Fixed too long lines. * Deleted unnecessary files. * Some fixes in test_gradients.py * Copyright date updated. * Refactored getting rid of flags. * Updated unit tests after refactoring. * Removed a duplicated argument. * Implemented general Quantum Time Evolution Framework interfaces. * Updated docs. * Reno added. * Improved reno. * Code refactoring. * Code refactoring. * Typehints added. * Made variational_principle.py stateless. * Updated copyright years. * Simplified var_qte.py class. * Refactored var_qte_linear_solver.py * Refactored abstract_ode_function_generator.py * Refactored var_qte_linear_solver.py * Refactored var_qte.py * Code formatting. * ODE solvers and optimizers as objects, not strings. * Update qiskit/algorithms/time_evolution/evolution_base.py Co-authored-by: Julien Gacon <gaconju@gmail.com> * Code refactoring. * Introduced evolution problem classes. * Code refactoring. * Apply suggestions from code review Co-authored-by: Julien Gacon <gaconju@gmail.com> * Added unit tests. * Lint fixed. * Code refactoring. * Removed error_based_ode_function_generator.py for MVP. * Code refactoring * Code refactoring * Code refactoring * Code refactoring * Code refactoring * Code review changes. * Removed gradient code for now. * Evolving observable removed. Evaluating observables added. * Improved naming. * Improved folder structure; filled evolvers init file. * Added Evolvers to algorithms init file. * Fixed missing imports. * Code refactoring * Fixed cyclic imports. * Extracted ListOrDict. * Code refactoring. * Code refactoring. * Fixed release note. * Fixed inheritance order. * Code refactoring. * Code refactoring. * Fixed cyclic imports. * Name fix. * Updated the algorithm to the latest version of interfaces. * Code refactoring. * Adapted unit tests to evolution problem. * Implemented aux_ops evaluation. * Fixed position of quantum_instance. * Added algorithms to algorithms init. * Imports refactoring. * Imports refactoring. * Updated code to the latest gradient framework. * Code refactoring. * Imports refactoring. * Added gradient files. * Code review addressed. Fixed tests. * Switched to 1 sampler. * Added unit tests for expected errors. * Improved docs. * Changed folder structure. * Added test_evolution_grad_calculator.py unit test with bases. * Updated interfaces. * Added VarQite unit test with aux ops. * Added VarQite unit test with aux ops. * Added VarQrte unit test with aux ops. * Update releasenotes/notes/add-variational-quantum-time-evolution-112ffeaf62782fea.yaml Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com> * Code refactoring. * Code refactoring. * Code refactoring. * Improved docs of variational principles. * Code refactoring. * Code refactoring. * Simplified var principles folder structure. * Opened VarQte algorithms for field modification. * Improved Sphinx docs. * Code refactoring. * Introduced ode_function_factory.py * Removed hardcoded rcond. * Renamed hamiltonian_value_dict. * Renamed hamiltonian_value_dict. * Extracted lengthy expected results in tests. * Updated unit tests. * Apply suggestions from code review Co-authored-by: Julien Gacon <gaconju@gmail.com> * Apply suggestions from code review * Extended release notes. * Removed dead code. * Improved ode solver types. * Moved evolve method for now. * Shortened Var Principles names. * Updated metric_tensor_calculator.py * Updated docs * Removed ordered_parameters. * Added and corrected code examples. * Extended unit tests. * Extended unit tests. * Extended unit tests. * Improved init files. * Improved init files. * Improved init files. * Improved init files. * Improved docs. * Import fix * Renamed sle to lse. * Code refactoring. * Replaced metric tensor calculator. * Replaced evolution gradient calculator. * Code refactoring. * Removed evolution_grad_calculator.py * Removed evolution_grad_calculator.py * Evolution grad calculator removal; code refactoring; dirty bug fix. * Added docs. * Code refactoring * Improved performance of evolution grad. * Improved performance of evolution grad, code refactoring; bug fixed. * Improved LSE solver handling. * Improved docs. * Unindented reno * Mitigated some cyclic imports. * Unindented reno * Improved docs * Lint resolutions * Fix some line-too-long in tests * Fixed lint. * Fixed lint. * Apply suggestions from code review Co-authored-by: Julien Gacon <gaconju@gmail.com> * Code review changes. * Added reno for a bug fix. * Fixed lint. * Updated docs. * Moved lse_solver to ODE factory. * Made ODE factory optional and defaults set. * Added expectation method argument and set defaults to PauliExpectation. * Limited supported methods for real_time_dependent_principle.py. * Fix imports. * Updated docs. * Implemented the Forward Euler ODE solver. Implemented a unit test. * Set Forward Euler ODE solver as a default. Updated unit tests. * Sync with main. * Exposed ODE number of steps. * Code refactoring * Code refactoring * Code refactoring * Exposed ode_num_t_steps to the user; reduced default ode_num_t_steps; added ForwardEulerSolver to docs. * Updated tests. * Fixed CI. * Fixed docs. * Hides OdeFunction from the user. * Update qiskit/algorithms/evolvers/variational/var_qrte.py Co-authored-by: Julien Gacon <gaconju@gmail.com> * Update releasenotes/notes/add-variational-quantum-time-evolution-112ffeaf62782fea.yaml Co-authored-by: Julien Gacon <gaconju@gmail.com> * Removes unsupported error-based method flag for now. * Switched num time steps to deltas in ODEs. * Code refactoring. * Fixed typhint. * Switched back to num_steps for ODE. * Slow tests and code refactoring. * Code refactoring. * Removed TD variational principle. * Apply suggestions from code review Co-authored-by: Julien Gacon <gaconju@gmail.com> * Code refactoring. * Improved signatures; support for list of parameter values. * Code refactoring. * Improved variable name. * Updated docs. Co-authored-by: CZ <ouf@zurich.ibm.com> Co-authored-by: Julien Gacon <gaconju@gmail.com> Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com> Co-authored-by: woodsp-ibm <woodsp@us.ibm.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Summary
This PR introduces Variational Quantum Time Evolution algorithms, imaginary and real, to the algorithms module. It uses variational principles: real McLachlan's, imaginary McLachlan's and real Time Dependent. It is part of the bigger framework for Quantum Time Evolution and implements the relevant interface.
The work is based on the PoC by @Zoufalc which has been significantly redesigned. The correctness has been cross-checked with the PoC.
Relevant papers:
#7349 (comment)
It closes the following epic: #6838 and the following associated issues:
Closes: #6912,
Closes: #6913,
Closes: #6914,
Closes: #6915,
Closes: #6916,
Closes: #6931,
Closes: #7268,
Closes: #7070,
Closes: #7143,
Closes: #7639,
Closes: #7649,
Closes: #7577,
Closes: #7621.
... .
Details and comments
Things that will be addressed in separate PRs: