-
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
Support for time-dependent Hamiltonians and observable evaluation in TrotterQRTE
#9565
Conversation
…erization.TrotterQRTE with synthesis LieTrotter
…ormula-classes unchanged wrt main. Also added evaluation of auxiliary_operators at every time-step of TrotterQRTE
…ormula-classes unchanged wrt main. Also added evaluation of auxiliary_operators at every time-step of TrotterQRTE
Thank you for opening a new pull request. Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient. While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone. One or more of the the following people are requested to review this:
|
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.
Overall looks good, I left some comments below. The main suggestions are
- keeping
aux_ops_evaluated
as is and instead introduceobservables
- don't change the product formula but apply it as the user supplied it
Could also add a releasenote for this new feature? 🙂
) | ||
estimator = Estimator() | ||
|
||
expected_evolved_state = Statevector([0.90201212+0.12857871j, 0.05815816+0.40799421j]) |
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.
Where are these numbers coming from? 🙂 Would it be possible to have a manual calculation as reference? 😄
One more of a procedural comment is that ideally the copyright dates on these changed files should be updated for 2023, Eg |
…l calculation of reference values
Co-authored-by: Julien Gacon <gaconju@gmail.com>
Co-authored-by: Julien Gacon <gaconju@gmail.com>
Co-authored-by: Julien Gacon <gaconju@gmail.com>
Co-authored-by: Julien Gacon <gaconju@gmail.com>
…lse, copies parameter array and returns new bound array leaving the passed array untouched
TrotterQRTE
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.
LGTM, thanks for adding these features!
Pull Request Test Coverage Report for Build 4164041180
💛 - Coveralls |
…``TrotterQRTE`` (Qiskit#9565) * added support for t-dep Hamiltonian to algorithms.time_evolvers.trotterization.TrotterQRTE with synthesis LieTrotter * added support for t-dep Hamiltonians to TrotterQRTE, leaving ProductFormula-classes unchanged wrt main. Also added evaluation of auxiliary_operators at every time-step of TrotterQRTE * added support for t-dep Hamiltonians to TrotterQRTE, leaving ProductFormula-classes unchanged wrt main. Also added evaluation of auxiliary_operators at every time-step of TrotterQRTE * removed note that t-dep Hamiltonians are not supported * modified and added tests for t-dependent Hamiltonians in TrotterQRTE * added documentation * adapted code according to PR comments, refined tests to include manual calculation of reference values * rename new test * Update qiskit/algorithms/time_evolvers/trotterization/trotter_qrte.py Co-authored-by: Julien Gacon <gaconju@gmail.com> * Update qiskit/algorithms/time_evolvers/trotterization/trotter_qrte.py Co-authored-by: Julien Gacon <gaconju@gmail.com> * Update qiskit/algorithms/time_evolvers/trotterization/trotter_qrte.py Co-authored-by: Julien Gacon <gaconju@gmail.com> * Update qiskit/algorithms/time_evolvers/trotterization/trotter_qrte.py Co-authored-by: Julien Gacon <gaconju@gmail.com> * added inplace argument to assign_parameters._assign_parameters. If False, copies parameter array and returns new bound array leaving the passed array untouched * fixing ValueErrors in TimeEvolutionProblme and formatting * added release note * fix lint suggestions --------- Co-authored-by: Julien Gacon <gaconju@gmail.com>
i need i code about trotterization |
…``TrotterQRTE`` (Qiskit#9565) * added support for t-dep Hamiltonian to algorithms.time_evolvers.trotterization.TrotterQRTE with synthesis LieTrotter * added support for t-dep Hamiltonians to TrotterQRTE, leaving ProductFormula-classes unchanged wrt main. Also added evaluation of auxiliary_operators at every time-step of TrotterQRTE * added support for t-dep Hamiltonians to TrotterQRTE, leaving ProductFormula-classes unchanged wrt main. Also added evaluation of auxiliary_operators at every time-step of TrotterQRTE * removed note that t-dep Hamiltonians are not supported * modified and added tests for t-dependent Hamiltonians in TrotterQRTE * added documentation * adapted code according to PR comments, refined tests to include manual calculation of reference values * rename new test * Update qiskit/algorithms/time_evolvers/trotterization/trotter_qrte.py Co-authored-by: Julien Gacon <gaconju@gmail.com> * Update qiskit/algorithms/time_evolvers/trotterization/trotter_qrte.py Co-authored-by: Julien Gacon <gaconju@gmail.com> * Update qiskit/algorithms/time_evolvers/trotterization/trotter_qrte.py Co-authored-by: Julien Gacon <gaconju@gmail.com> * Update qiskit/algorithms/time_evolvers/trotterization/trotter_qrte.py Co-authored-by: Julien Gacon <gaconju@gmail.com> * added inplace argument to assign_parameters._assign_parameters. If False, copies parameter array and returns new bound array leaving the passed array untouched * fixing ValueErrors in TimeEvolutionProblme and formatting * added release note * fix lint suggestions --------- Co-authored-by: Julien Gacon <gaconju@gmail.com>
…``TrotterQRTE`` (Qiskit/qiskit#9565) * added support for t-dep Hamiltonian to algorithms.time_evolvers.trotterization.TrotterQRTE with synthesis LieTrotter * added support for t-dep Hamiltonians to TrotterQRTE, leaving ProductFormula-classes unchanged wrt main. Also added evaluation of auxiliary_operators at every time-step of TrotterQRTE * added support for t-dep Hamiltonians to TrotterQRTE, leaving ProductFormula-classes unchanged wrt main. Also added evaluation of auxiliary_operators at every time-step of TrotterQRTE * removed note that t-dep Hamiltonians are not supported * modified and added tests for t-dependent Hamiltonians in TrotterQRTE * added documentation * adapted code according to PR comments, refined tests to include manual calculation of reference values * rename new test * Update qiskit/algorithms/time_evolvers/trotterization/trotter_qrte.py Co-authored-by: Julien Gacon <gaconju@gmail.com> * Update qiskit/algorithms/time_evolvers/trotterization/trotter_qrte.py Co-authored-by: Julien Gacon <gaconju@gmail.com> * Update qiskit/algorithms/time_evolvers/trotterization/trotter_qrte.py Co-authored-by: Julien Gacon <gaconju@gmail.com> * Update qiskit/algorithms/time_evolvers/trotterization/trotter_qrte.py Co-authored-by: Julien Gacon <gaconju@gmail.com> * added inplace argument to assign_parameters._assign_parameters. If False, copies parameter array and returns new bound array leaving the passed array untouched * fixing ValueErrors in TimeEvolutionProblme and formatting * added release note * fix lint suggestions --------- Co-authored-by: Julien Gacon <gaconju@gmail.com>
Summary
This PR adds two features to the TrotterQRTE class.
Details and comments
The above is achieved by constructing the full circuit of a Trotterized time evolution within TrotterQRTE instead of (as was previously the case) in PauliEvolutionGate.
Previously, the number of timesteps was passed to the
ProductFormula
through thereps
argument.PauliEvolutionGate
was then called fromTrotterQRTE
to construct the full circuit corresponding to the full time evolution.Instead, now
TrotterQRTE
accepts the argumentnum_timesteps
(analogous toVarQTE
). ThePauliEvolutionGate
is only used to construct a single repetition of a product formula circuit and these single-step evolution gates are chained together inTrotterQRTE.evolve
.This has two benefits:
aux_operators
can be evaluated at every timestep, which is the natural application for any time evolution algorithm.Since
SparsePauliOp
does not yet support parameter-assignments, parameter values are assigned to the Hamiltonian at each time step through the helper function_assign_parameters
. For this purpose, this helper function was moved to a higher level in the hierarchy of the Algorithms module and the import inVarQTE
was adapted.In the future, a method
SparsePauliOp.assign_parameters
should be added.