Skip to content
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

Merged
merged 566 commits into from
Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
566 commits
Select commit Hold shift + click to select a range
1b73d17
Fixed requirements-dev.txt
Dec 10, 2021
6b34b7b
Merge branch 'varqte' of https://github.com/dlasecki/qiskit-terra int…
Dec 10, 2021
3cf948f
Merge branch 'main' into varqte
Dec 10, 2021
41f3347
Fixed some pylint.
Dec 10, 2021
0ee0d7f
Merge remote-tracking branch 'origin/varqte' into varqte
Dec 10, 2021
d90262d
Fixed some pylint.
Dec 10, 2021
49402ec
Update Documentation variational principles
Zoufalc Dec 13, 2021
565e06b
updates documentation
Zoufalc Dec 13, 2021
1e19a9a
minor documentation
Zoufalc Dec 14, 2021
d12c086
Merge pull request #6 from Zoufalc/dal_varqte
Dec 14, 2021
9db8777
Added unit tests docs and some package docs.
Dec 14, 2021
6626244
Code refactoring.
Dec 14, 2021
0853b63
Code refactoring.
Dec 15, 2021
df31b7d
Code refactoring.
Dec 15, 2021
7f75894
Merge branch 'main' into varqte
Jan 3, 2022
998c059
Update qiskit/opflow/evolutions/pauli_trotter_evolution.py
Jan 10, 2022
35c2bb5
Renamed the main folder.
Jan 10, 2022
b58c325
Code refactoring.
Jan 10, 2022
96a6739
Update qiskit/algorithms/quantum_time_evolution/variational/calculato…
Jan 10, 2022
dd2dbe3
Code refactoring.
Jan 10, 2022
70dd674
Merge remote-tracking branch 'origin/varqte' into varqte
Jan 10, 2022
8c5cd26
Update qiskit/algorithms/time_evolution/variational/error_calculators…
Jan 14, 2022
af9c0cd
Code refactoring.
Jan 17, 2022
2226f7a
Lint fixes.
Jan 17, 2022
7da0b4e
Code refactoring.
Jan 17, 2022
d6a503b
Code refactoring.
Jan 18, 2022
8781473
Code refactoring.
Jan 18, 2022
b097ccb
Merge branch 'main' into varqte
Jan 18, 2022
0652516
Code refactoring.
Jan 18, 2022
7f188a2
Code refactoring, docs fixed.
Jan 21, 2022
69a2429
Code refactoring, docs fixed.
Jan 21, 2022
f7c5a6d
Code refactoring and docs improved.
Jan 24, 2022
ebd1c7e
Exposed optimizer tolerance as an argument.
Jan 26, 2022
5f32d42
Exposed allowed imaginary part as an argument.
Jan 26, 2022
3864040
Exposed allowed numerical instability as an argument.
Jan 26, 2022
c20d819
Code refactoring.
Jan 27, 2022
92e48d2
Introduced evolution_result.py class.
Jan 27, 2022
79b3c4b
Minor bugfix.
Jan 27, 2022
b2c1119
Integrated evolution result to VarQte algorithms.
Jan 27, 2022
75ebc12
Code refactoring.
Jan 27, 2022
b4c6bb2
Black formatting fix.
Feb 1, 2022
4087f47
Merge branch 'main' into varqte
Feb 1, 2022
62c0121
Fixed signatures.
Feb 1, 2022
4efccdf
Fixed random seed setup.
Feb 1, 2022
6dc1329
Fixed too long lines.
Feb 1, 2022
4f23764
Deleted unnecessary files.
Feb 1, 2022
512416f
Some fixes in test_gradients.py
Feb 1, 2022
37eda0a
Copyright date updated.
Feb 4, 2022
d5e8767
Merge branch 'main' into varqte
Feb 8, 2022
66396ad
Merge branch 'main' into varqte
Feb 9, 2022
319db10
Refactored getting rid of flags.
Feb 10, 2022
c207176
Updated unit tests after refactoring.
Feb 10, 2022
210b8ef
Removed a duplicated argument.
Feb 11, 2022
2701ef7
Implemented general Quantum Time Evolution Framework interfaces.
Feb 16, 2022
d67b0c9
Updated docs.
Feb 16, 2022
5e1065e
Reno added.
Feb 16, 2022
9c041ed
Improved reno.
Feb 16, 2022
5582d32
Code refactoring.
Feb 16, 2022
582b959
Code refactoring.
Feb 16, 2022
a710b3f
Typehints added.
Feb 18, 2022
8ab37d9
Made variational_principle.py stateless.
Feb 18, 2022
6a8eef1
Updated copyright years.
Feb 18, 2022
2f619ba
Simplified var_qte.py class.
Feb 18, 2022
0b5ca3a
Refactored var_qte_linear_solver.py
Feb 21, 2022
9917e54
Refactored abstract_ode_function_generator.py
Feb 21, 2022
f7b6f6a
Refactored var_qte_linear_solver.py
Feb 21, 2022
3f1d209
Refactored var_qte.py
Feb 21, 2022
043d73b
Code formatting.
Feb 21, 2022
ed78561
ODE solvers and optimizers as objects, not strings.
Feb 22, 2022
c0e4bdd
Update qiskit/algorithms/time_evolution/evolution_base.py
Feb 22, 2022
d9dbcba
Code refactoring.
Feb 22, 2022
05172e9
Introduced evolution problem classes.
Feb 22, 2022
2c655d2
Merge remote-tracking branch 'origin/time-evo-framework' into time-ev…
Feb 22, 2022
1ecf5b6
Code refactoring.
Feb 22, 2022
8669094
Apply suggestions from code review
Feb 22, 2022
f55d38f
Added unit tests.
Feb 23, 2022
27c69ae
Lint fixed.
Feb 23, 2022
e12dd43
Merge branch 'main' into time-evo-framework
Feb 23, 2022
5058283
Code refactoring.
Feb 23, 2022
2e4c513
Removed error_based_ode_function_generator.py for MVP.
Feb 24, 2022
9b0692c
Code refactoring
Feb 24, 2022
a30b726
Code refactoring
Feb 24, 2022
fc3590e
Merge branch 'main' into varqte-mvp
Feb 24, 2022
1c93aa0
Code refactoring
Feb 25, 2022
43e0084
Code refactoring
Feb 28, 2022
32c8750
Merge remote-tracking branch 'origin/time-evo-framework' into time-ev…
Feb 28, 2022
ea83dd0
Code refactoring
Feb 28, 2022
e40b0ca
Code review changes.
Mar 1, 2022
ed8f26a
Removed gradient code for now.
Mar 1, 2022
cba5911
Evolving observable removed. Evaluating observables added.
Mar 1, 2022
94574b8
Improved naming.
Mar 3, 2022
6b93f03
Improved folder structure; filled evolvers init file.
Mar 3, 2022
5014c61
Added Evolvers to algorithms init file.
Mar 3, 2022
d1cd3e0
Fixed missing imports.
Mar 3, 2022
d605119
Code refactoring
Mar 3, 2022
c6a04e0
Fixed cyclic imports.
Mar 4, 2022
6708db1
Extracted ListOrDict.
Mar 4, 2022
22f886c
Code refactoring.
Mar 4, 2022
ede8ef1
Merge branch 'main' into time-evo-framework
Mar 4, 2022
eb9ef89
Code refactoring.
Mar 7, 2022
897ac19
Fixed release note.
Mar 7, 2022
e0e2919
Fixed inheritance order.
Mar 7, 2022
33d7d4c
Code refactoring.
Mar 7, 2022
94dc0d0
Code refactoring.
Mar 7, 2022
b48d9fb
Fixed cyclic imports.
Mar 8, 2022
2340448
Name fix.
Mar 8, 2022
b7e7585
Merge branch 'time-evo-framework' into varqte-mvp
Mar 8, 2022
4723b42
Updated the algorithm to the latest version of interfaces.
Mar 8, 2022
ffd61fb
Code refactoring.
Mar 8, 2022
4487614
Merge branch 'main' into varqte-mvp
Mar 15, 2022
0d980eb
Merge branch 'main' into varqte-mvp
Mar 21, 2022
c1cf3f7
Adapted unit tests to evolution problem.
Mar 21, 2022
a2e69fb
Implemented aux_ops evaluation.
Mar 21, 2022
ccf875a
Fixed position of quantum_instance.
Mar 22, 2022
e79388d
Added algorithms to algorithms init.
Mar 22, 2022
fac4a44
Imports refactoring.
Mar 22, 2022
55091d6
Imports refactoring.
Mar 22, 2022
b90deb7
Merge branch 'main' into varqte-mvp
Mar 30, 2022
4d2e410
Updated code to the latest gradient framework.
Mar 30, 2022
744cb67
Code refactoring.
Mar 30, 2022
3ebbf67
Imports refactoring.
Mar 30, 2022
011667a
Merge branch 'main' into varqte-mvp
Mar 30, 2022
f1f6109
Added gradient files.
Mar 30, 2022
eec1a20
Code review addressed. Fixed tests.
Mar 31, 2022
82e6629
Switched to 1 sampler.
Mar 31, 2022
1bf1308
Added unit tests for expected errors.
Apr 1, 2022
50fabab
Improved docs.
Apr 4, 2022
88fceba
Changed folder structure.
Apr 4, 2022
b6af31f
Added test_evolution_grad_calculator.py unit test with bases.
Apr 4, 2022
398b9c3
Merge branch 'main' into varqte-mvp
Apr 7, 2022
2694458
Updated interfaces.
Apr 7, 2022
8426b25
Added VarQite unit test with aux ops.
Apr 8, 2022
5ed3bca
Added VarQite unit test with aux ops.
Apr 8, 2022
d753764
Added VarQrte unit test with aux ops.
Apr 8, 2022
c5aa6a5
Update releasenotes/notes/add-variational-quantum-time-evolution-112f…
May 9, 2022
8a0e157
Merge.
May 9, 2022
d8de06c
Code refactoring.
May 9, 2022
1c7bec7
Code refactoring.
May 9, 2022
270e2fc
Code refactoring.
May 10, 2022
2fc069e
Improved docs of variational principles.
May 10, 2022
3626f97
Code refactoring.
May 10, 2022
ce45b49
Code refactoring.
May 10, 2022
c782cbc
Simplified var principles folder structure.
May 11, 2022
de9b9ea
Opened VarQte algorithms for field modification.
May 11, 2022
154c3d8
Improved Sphinx docs.
May 11, 2022
7224d60
Code refactoring.
May 11, 2022
17813d1
Introduced ode_function_factory.py
May 18, 2022
af47b01
Removed hardcoded rcond.
May 18, 2022
08ccd0e
Renamed hamiltonian_value_dict.
May 18, 2022
1236b41
Renamed hamiltonian_value_dict.
May 18, 2022
0fdc348
Extracted lengthy expected results in tests.
May 19, 2022
c76f3da
Updated unit tests.
May 19, 2022
64f159c
Apply suggestions from code review
May 23, 2022
59d9cbe
Apply suggestions from code review
May 23, 2022
0be12ff
Extended release notes.
May 24, 2022
687c02c
Removed dead code.
May 25, 2022
1e8f02a
Improved ode solver types.
May 25, 2022
64f5d47
Moved evolve method for now.
May 25, 2022
aa70a2e
Shortened Var Principles names.
May 25, 2022
fc6ca4c
Updated metric_tensor_calculator.py
May 25, 2022
36fdb06
Updated docs
May 25, 2022
5aeeded
Removed ordered_parameters.
May 27, 2022
1d10a87
Added and corrected code examples.
May 27, 2022
8e78f8b
Extended unit tests.
May 27, 2022
a0e203d
Extended unit tests.
May 27, 2022
0343d19
Extended unit tests.
May 30, 2022
e3d1f81
Improved init files.
May 30, 2022
7aa6747
Improved init files.
May 30, 2022
81f9762
Improved init files.
May 30, 2022
d46cff0
Improved init files.
May 30, 2022
dbf1765
Improved docs.
May 31, 2022
66fcfbd
Import fix
Jun 1, 2022
7fd1e55
Renamed sle to lse.
Jun 1, 2022
f42a42a
Code refactoring.
Jun 1, 2022
763d457
Replaced metric tensor calculator.
Jun 2, 2022
9cd152c
Replaced evolution gradient calculator.
Jun 3, 2022
f4bef7d
Code refactoring.
Jun 3, 2022
a9d7720
Removed evolution_grad_calculator.py
Jun 7, 2022
06b235a
Removed evolution_grad_calculator.py
Jun 7, 2022
7ff0c77
Evolution grad calculator removal; code refactoring; dirty bug fix.
Jun 8, 2022
c30891b
Added docs.
Jun 8, 2022
c3a06d7
Merge branch 'varqte-mvp' into varqte-mvp-2
Jun 8, 2022
98e0c3a
Merge branch 'main' into varqte-mvp-2
Jun 8, 2022
30b32e6
Code refactoring
Jun 9, 2022
be30caf
Improved performance of evolution grad.
Jun 10, 2022
4b39c14
Improved performance of evolution grad, code refactoring; bug fixed.
Jun 10, 2022
9ff706f
Improved LSE solver handling.
Jun 13, 2022
48c4fde
Improved docs.
Jun 14, 2022
291e55c
Unindented reno
Jun 15, 2022
51ade10
Mitigated some cyclic imports.
Jun 15, 2022
b1bec9f
Unindented reno
Jun 15, 2022
0736277
Improved docs
Jun 17, 2022
b9813b3
Lint resolutions
woodsp-ibm Jun 18, 2022
83a6d27
Fix some line-too-long in tests
woodsp-ibm Jun 18, 2022
e69eedb
Fixed lint.
Jun 20, 2022
09235d3
Fixed lint.
Jun 20, 2022
5d384d8
Apply suggestions from code review
Jun 20, 2022
c34d4e1
Code review changes.
Jun 20, 2022
b2487cd
Merge branch 'main' into varqte-mvp-2
Jun 20, 2022
1d7ff87
Added reno for a bug fix.
Jun 20, 2022
56c81c7
Fixed lint.
Jun 20, 2022
ebc721e
Updated docs.
Jun 21, 2022
30b73d4
Moved lse_solver to ODE factory.
Jun 21, 2022
103486c
Made ODE factory optional and defaults set.
Jun 21, 2022
ac073e7
Added expectation method argument and set defaults to PauliExpectation.
Jun 21, 2022
ab24a8a
Limited supported methods for real_time_dependent_principle.py.
Jun 21, 2022
0bcfe67
Fix imports.
Jun 22, 2022
33b765f
Updated docs.
Jun 22, 2022
b7432a5
Implemented the Forward Euler ODE solver. Implemented a unit test.
Jun 22, 2022
2acab3d
Set Forward Euler ODE solver as a default. Updated unit tests.
Jun 23, 2022
3ebbc16
Merge branch 'main' into varqte-mvp-2
Jun 23, 2022
4ad9b6a
Sync with main.
Jun 23, 2022
2bc511f
Exposed ODE number of steps.
Jun 23, 2022
b276fd7
Code refactoring
Jun 23, 2022
03957c9
Code refactoring
Jun 23, 2022
595b6cf
Merge branch 'main' into varqte-mvp-2
Jun 23, 2022
7588d65
Code refactoring
Jun 23, 2022
cf355a9
Merge remote-tracking branch 'origin/varqte-mvp-2' into varqte-mvp-2
Jun 23, 2022
33fc041
Exposed ode_num_t_steps to the user; reduced default ode_num_t_steps;…
Jun 27, 2022
097f61b
Updated tests.
Jun 27, 2022
b112828
Merge branch 'main' into varqte-mvp-2
Jun 27, 2022
4c0d0de
Fixed CI.
Jun 27, 2022
bcdb8c6
Fixed docs.
Jun 29, 2022
a7be19f
Hides OdeFunction from the user.
Jul 19, 2022
0b9a04e
Update qiskit/algorithms/evolvers/variational/var_qrte.py
Jul 19, 2022
895eefd
Update releasenotes/notes/add-variational-quantum-time-evolution-112f…
Jul 19, 2022
d84f39f
Removes unsupported error-based method flag for now.
Jul 19, 2022
ad71840
Switched num time steps to deltas in ODEs.
Jul 29, 2022
ea60943
Code refactoring.
Jul 29, 2022
133aab8
Merge branch 'main' into varqte-mvp-2
Aug 1, 2022
c9cb9d3
Merge branch 'main' into varqte-mvp-2
Aug 2, 2022
feaa933
Merge remote-tracking branch 'origin/varqte-mvp-2' into varqte-mvp-2
Aug 2, 2022
13ac037
Fixed typhint.
Aug 2, 2022
cd11ade
Switched back to num_steps for ODE.
Aug 5, 2022
e930d1c
Slow tests and code refactoring.
Aug 5, 2022
8ea3182
Code refactoring.
Aug 5, 2022
a6224d3
Merge branch 'main' into varqte-mvp-2
Aug 5, 2022
77f30ca
Removed TD variational principle.
Aug 5, 2022
4fc27a1
Apply suggestions from code review
Aug 11, 2022
4566012
Code refactoring.
Aug 11, 2022
adc557d
Merge branch 'main' into varqte-mvp-2
Aug 11, 2022
23c0de2
Improved signatures; support for list of parameter values.
Aug 12, 2022
364a323
Merge branch 'main' into varqte-mvp-2
Aug 12, 2022
c48217a
Code refactoring.
Aug 14, 2022
2529599
Merge remote-tracking branch 'origin/varqte-mvp-2' into varqte-mvp-2
Aug 14, 2022
762806d
Improved variable name.
Aug 15, 2022
b85aeab
Updated docs.
Aug 15, 2022
525ff59
Merge branch 'main' into varqte-mvp-2
Aug 15, 2022
08543cd
Merge branch 'main' into varqte-mvp-2
Aug 17, 2022
4d5502e
Merge branch 'main' into varqte-mvp-2
mergify[bot] Aug 23, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions qiskit/algorithms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,17 @@
VQD


Variational Quantum Time Evolution
----------------------------------

Classes used by variational quantum time evolution algorithms - VarQITE and VarQRTE.

.. autosummary::
:toctree: ../stubs/

evolvers.variational


Evolvers
--------

Expand All @@ -108,11 +119,14 @@
RealEvolver
ImaginaryEvolver
TrotterQRTE
VarQITE
VarQRTE
PVQD
PVQDResult
EvolutionResult
EvolutionProblem


Factorizers
-----------

Expand Down Expand Up @@ -248,6 +262,8 @@
from .exceptions import AlgorithmError
from .aux_ops_evaluator import eval_observables
from .evolvers.trotterization import TrotterQRTE
from .evolvers.variational.var_qite import VarQITE
from .evolvers.variational.var_qrte import VarQRTE
from .evolvers.pvqd import PVQD, PVQDResult

__all__ = [
Expand All @@ -273,6 +289,8 @@
"RealEvolver",
"ImaginaryEvolver",
"TrotterQRTE",
"VarQITE",
"VarQRTE",
"EvolutionResult",
"EvolutionProblem",
"LinearSolverResult",
Expand Down
12 changes: 6 additions & 6 deletions qiskit/algorithms/evolvers/evolution_problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(
aux_operators: Optional[ListOrDict[OperatorBase]] = None,
truncation_threshold: float = 1e-12,
t_param: Optional[Parameter] = None,
hamiltonian_value_dict: Optional[Dict[Parameter, complex]] = None,
param_value_dict: Optional[Dict[Parameter, complex]] = None,
dlasecki marked this conversation as resolved.
Show resolved Hide resolved
):
"""
Args:
Expand All @@ -50,15 +50,15 @@ def __init__(
Used when ``aux_operators`` is provided.
t_param: Time parameter in case of a time-dependent Hamiltonian. This
free parameter must be within the ``hamiltonian``.
hamiltonian_value_dict: If the Hamiltonian contains free parameters, this
dictionary maps all these parameters to values.
param_value_dict: Maps free parameters in the problem to values. Depending on the
algorithm, it might refer to e.g. a Hamiltonian or an initial state.

Raises:
ValueError: If non-positive time of evolution is provided.
"""

self.t_param = t_param
self.hamiltonian_value_dict = hamiltonian_value_dict
self.param_value_dict = param_value_dict
self.hamiltonian = hamiltonian
self.time = time
self.initial_state = initial_state
Expand Down Expand Up @@ -95,9 +95,9 @@ def validate_params(self) -> None:
if self.t_param is not None:
t_param_set.add(self.t_param)
hamiltonian_dict_param_set = set()
if self.hamiltonian_value_dict is not None:
if self.param_value_dict is not None:
hamiltonian_dict_param_set = hamiltonian_dict_param_set.union(
set(self.hamiltonian_value_dict.keys())
set(self.param_value_dict.keys())
)
params_set = t_param_set.union(hamiltonian_dict_param_set)
hamiltonian_param_set = set(self.hamiltonian.parameters)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def evolve(self, evolution_problem: EvolutionProblem) -> EvolutionResult:
f"PauliSumOp | SummedOp, {type(hamiltonian)} provided."
)
if isinstance(hamiltonian, OperatorBase):
hamiltonian = hamiltonian.bind_parameters(evolution_problem.hamiltonian_value_dict)
hamiltonian = hamiltonian.bind_parameters(evolution_problem.param_value_dict)
if isinstance(hamiltonian, SummedOp):
hamiltonian = self._summed_op_to_pauli_sum_op(hamiltonian)
# the evolution gate
Expand Down
139 changes: 139 additions & 0 deletions qiskit/algorithms/evolvers/variational/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2021, 2022.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
"""
Variational Quantum Time Evolutions (:mod:`qiskit.algorithms.evolvers.variational`)
===================================================================================

Algorithms for performing Variational Quantum Time Evolution of quantum states,
which can be tailored to near-term devices.
:class:`~qiskit.algorithms.evolvers.variational.VarQTE` base class exposes an interface, compliant
with the Quantum Time Evolution Framework in Qiskit Terra, that is implemented by
:class:`~qiskit.algorithms.VarQRTE` and :class:`~qiskit.algorithms.VarQITE` classes for real and
imaginary time evolution respectively. The variational approach is taken according to a variational
principle chosen by a user.

Examples:

.. code-block::
dlasecki marked this conversation as resolved.
Show resolved Hide resolved

from qiskit import BasicAer
from qiskit.circuit.library import EfficientSU2
from qiskit.opflow import SummedOp, I, Z, Y, X
from qiskit.algorithms.evolvers.variational import (
ImaginaryMcLachlanPrinciple,
)
from qiskit.algorithms import EvolutionProblem
from qiskit.algorithms import VarQITE

# define a Hamiltonian
observable = SummedOp(
dlasecki marked this conversation as resolved.
Show resolved Hide resolved
[
0.2252 * (I ^ I),
0.5716 * (Z ^ Z),
0.3435 * (I ^ Z),
-0.4347 * (Z ^ I),
0.091 * (Y ^ Y),
0.091 * (X ^ X),
]
).reduce()

# define a parametrized initial state to be evolved

ansatz = EfficientSU2(observable.num_qubits, reps=1)
parameters = ansatz.parameters

# define values of initial parameters
init_param_values = np.zeros(len(ansatz.parameters))
for i in range(len(ansatz.parameters)):
init_param_values[i] = np.pi / 2
param_dict = dict(zip(parameters, init_param_values))

# define a variational principle
var_principle = ImaginaryMcLachlanPrinciple()

# optionally define a backend
backend = BasicAer.get_backend("statevector_simulator")

# define evolution time
time = 1

# define evolution problem
evolution_problem = EvolutionProblem(observable, time)

# instantiate the algorithm
var_qite = VarQITE(ansatz, var_principle, param_dict, quantum_instance=backend)

# run the algorithm/evolve the state
evolution_result = var_qite.evolve(evolution_problem)

.. currentmodule:: qiskit.algorithms.evolvers.variational

Variational Principles
----------------------

Variational principles can be used to simulate quantum time evolution by propagating the parameters
of a parameterized quantum circuit.

They can be divided into two categories:

1) Variational Quantum Imaginary Time Evolution
Given a Hamiltonian, a time and a variational ansatz, the variational principle describes a
variational principle according to the normalized Wick-rotated Schroedinger equation.

2) Variational Quantum Real Time Evolution
Given a Hamiltonian, a time and a variational ansatz, the variational principle describes a
variational principle according to the Schroedinger equation.

.. autosummary::
:toctree: ../stubs/
:template: autosummary/class_no_inherited_members.rst

VariationalPrinciple
RealVariationalPrinciple
ImaginaryVariationalPrinciple
RealMcLachlanPrinciple
ImaginaryMcLachlanPrinciple

ODE solvers
-----------
ODE solvers that implement the SciPy ODE Solver interface. The Forward Euler Solver is
a preferred choice in the presence of noise. One might also use solvers provided by SciPy directly,
e.g. RK45.

.. autosummary::
:toctree: ../stubs/
:template: autosummary/class_no_inherited_members.rst

ForwardEulerSolver
woodsp-ibm marked this conversation as resolved.
Show resolved Hide resolved

"""
from .solvers.ode.forward_euler_solver import ForwardEulerSolver
from .var_qte import VarQTE
from .variational_principles.variational_principle import VariationalPrinciple
from .variational_principles import RealVariationalPrinciple, ImaginaryVariationalPrinciple
from .variational_principles.imaginary_mc_lachlan_principle import (
ImaginaryMcLachlanPrinciple,
)
from .variational_principles.real_mc_lachlan_principle import (
RealMcLachlanPrinciple,
)


__all__ = [
"ForwardEulerSolver",
"VarQTE",
"VariationalPrinciple",
"RealVariationalPrinciple",
"ImaginaryVariationalPrinciple",
"RealMcLachlanPrinciple",
"ImaginaryMcLachlanPrinciple",
]
44 changes: 44 additions & 0 deletions qiskit/algorithms/evolvers/variational/solvers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2021, 2022.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

"""
Solvers (:mod:`qiskit.algorithms.evolvers.variational.solvers`)
dlasecki marked this conversation as resolved.
Show resolved Hide resolved
===============================================================

This package contains the necessary classes to solve systems of equations arising in the
Variational Quantum Time Evolution. They include ordinary differential equations (ODE) which
describe ansatz parameter propagation and systems of linear equations.


Systems of Linear Equations Solver
----------------------------------

.. autosummary::
:toctree: ../stubs/
:template: autosummary/class_no_inherited_members.rst

VarQTELinearSolver


ODE Solver
----------
.. autosummary::
:toctree: ../stubs/
:template: autosummary/class_no_inherited_members.rst

VarQTEOdeSolver
"""

from qiskit.algorithms.evolvers.variational.solvers.ode.var_qte_ode_solver import VarQTEOdeSolver
from qiskit.algorithms.evolvers.variational.solvers.var_qte_linear_solver import VarQTELinearSolver

__all__ = ["VarQTELinearSolver", "VarQTEOdeSolver"]
13 changes: 13 additions & 0 deletions qiskit/algorithms/evolvers/variational/solvers/ode/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2021, 2022.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

"""ODE Solvers"""
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2021, 2022.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

"""Abstract class for generating ODE functions."""

from abc import ABC, abstractmethod
from typing import Iterable, Dict, Optional
from qiskit.circuit import Parameter
from ..var_qte_linear_solver import (
VarQTELinearSolver,
)


class AbstractOdeFunction(ABC):
"""Abstract class for generating ODE functions."""

def __init__(
self,
varqte_linear_solver: VarQTELinearSolver,
error_calculator,
param_dict: Dict[Parameter, complex],
t_param: Optional[Parameter] = None,
) -> None:

self._varqte_linear_solver = varqte_linear_solver
self._error_calculator = error_calculator
self._param_dict = param_dict
self._t_param = t_param

@abstractmethod
def var_qte_ode_function(self, time: float, parameters_values: Iterable) -> Iterable:
"""
Evaluates an ODE function for a given time and parameter values. It is used by an ODE
solver.

Args:
time: Current time of evolution.
parameters_values: Current values of parameters.

Returns:
ODE gradient arising from solving a system of linear equations.
"""
pass
Loading