Dynamic MPFs (qiskit_addon_mpf.dynamic
)¶
Dynamic MPF coefficients.
This module provides the generator function for the linear system of equations (LSE
) for
computing dynamic (that is, time-dependent) MPF coefficients.
- setup_dynamic_lse(trotter_steps, time, identity_factory, exact_evolver_factory, approx_evolver_factory, initial_state)[source]¶
Return the linear system of equations for computing dynamic MPF coefficients.
This function uses the
DynamicMPF
algorithm to compute the components of the Gram matrix (LSE.A
, \(M\) in [1] and [2]) and the overlap vector (LSE.b
, \(L\) in [1] and [2]) for the provided time-evolution parameters.The elements of the Gram matrix, \(M_{ij}\), and overlap vector, \(L_i\), are defined as
\[\begin{split}M_{ij} &= \text{Tr}(\rho_{k_i}(t)\rho_{k_j}(t)) \, , \\ L_i &= \text{Tr}(\rho(t)\rho_{k_i}(t)) \, ,\end{split}\]where \(\rho(t)\) is the exact time-evolution state at time \(t\) and \(\rho_{k_i}(t)\) is the time-evolution state approximated using \(k_i\) Trotter steps.
Computing the dynamic (that is, time-dependent) MPF coefficients from \(M\) and \(L\) amounts to finding a solution to the
LSE
(similarly to how thestatic
MPF coefficients are computed) while enforcing the constraint that all coefficients must sum to 1 (\(\sum_i x_i = 1\)), which is not enforced as part of this LSE (unlike in the static case). Optimization problems which include this additional constraint are documented in thecosts
module. The one suggested by [1] and [2] is thesetup_frobenius_problem()
.Evaluating every element \(M_{ij}\) and \(L_i\) requires computing the overlap between two time-evolution states. The
DynamicMPF
algorithm does so by means of tensor network calculations, provided by one of the optional dependencies. The available backends are listed and explained in more detail in thebackends
module.Below, we provide an example using the
quimb_tebd
backend. We briefly explain each element.First, we initialize a simple Heisenberg Hamiltonian which we would like to time-evolve. Since we are using a time-evolver based on
quimb
, we also initialize the Hamiltonian using that library.>>> from quimb.tensor import ham_1d_heis >>> num_qubits = 10 >>> hamil = ham_1d_heis(num_qubits, 0.8, 0.3, cyclic=False)
Next, we define the number of Trotter steps to make up our MPF, the target evolution time as well as the initial state (\(\psi_{in}\) in [1] and \(\psi_0\) in [2], resp.) with respect to which we compute the overlap between the time-evolution states. Here, we simply use the Néel state which we also construct using
quimb
:>>> trotter_steps = [3, 4] >>> time = 0.9
>>> from quimb.tensor import MPS_neel_state >>> initial_state = MPS_neel_state(num_qubits)
Since we must run the full
DynamicMPF
algorithm for computing every element of \(M_{ij}\) and \(L_i\), we must provide factory methods for initializing the input arguments of theDynamicMPF
instances. To this end, we must provide three functions. To construct these, we will use thefunctools.partial()
function.>>> from functools import partial
First, we need a function to initialize an empty time-evolution state (see also
DynamicMPF.evolution_state
for more details). This constructor function may not take any positional or keyword arguments and must return aState
object.>>> from qiskit_addon_mpf.backends.quimb_tebd import MPOState >>> from quimb.tensor import MPO_identity >>> identity_factory = lambda: MPOState(MPO_identity(num_qubits))
The second and third function must construct the left- and right-hand side time-evolution engines (see also
DynamicMPF.lhs
andDynamicMPF.rhs
for more details). These functions should follow theExactEvolverFactory
andApproxEvolverFactory
protocols, respectively.The
ExactEvolverFactory
function should take aState
object as its only positional argument and should return aEvolver
object, which will be used for computing the LHS of the \(L_i\) elements (i.e. it should produce the exact time-evolution state, \(\rho(t)\)).Here, we approximate the exact time-evolved state with a fourth-order Suzuki-Trotter formula using a small time step of 0.05. We also specify some
quimb
-specific truncation options to bound the maximum bond dimension of the underlying tensor network as well as the minimum singular values of the split tensor network bonds.>>> from qiskit_addon_mpf.backends.quimb_tebd import TEBDEvolver >>> exact_evolver_factory = partial( ... TEBDEvolver, ... H=hamil, ... dt=0.05, ... order=4, ... split_opts={"max_bond": 10, "cutoff": 1e-5}, ... )
The
ApproxEvolverFactory
function should also take aState
object as its only positional argument and additionally a keyword argument calleddt
to specify the time step of the time-evolution. It should also return aEvolver
object which produces the approximate time-evolution states, \(\rho_{k_i}(t)\), where \(k_i\) is determined by the chosen time step,dt
. As such, these instances will be used for computing the RHS of the \(L_i\) as well as both sides of the \(M_{ij}\) elements.Here, we use a second-order Suzuki-Trotter formula with the same truncation settings as before.
>>> approx_evolver_factory = partial( ... TEBDEvolver, ... H=hamil, ... order=2, ... split_opts={"max_bond": 10, "cutoff": 1e-5}, ... )
Finally, we can initialize and run the
setup_dynamic_lse()
function to obtain theLSE
described at the top.>>> from qiskit_addon_mpf.dynamic import setup_dynamic_lse >>> lse = setup_dynamic_lse( ... trotter_steps, ... time, ... identity_factory, ... exact_evolver_factory, ... approx_evolver_factory, ... initial_state, ... ) >>> print(lse.A) [[1. 0.99998513] [0.99998513 1. ]] >>> print(lse.b) [1.00001585 0.99998955]
- Parameters:
trotter_steps (list[int]) – the sequence of trotter steps to be used.
time (float) – the total target evolution time.
identity_factory (IdentityStateFactory) – a function to generate an empty
State
object.exact_evolver_factory (ExactEvolverFactory) – a function to initialize the
Evolver
instance which produces the exact time-evolution state, \(\rho(t)\).approx_evolver_factory (ApproxEvolverFactory) – a function to initialize the
Evolver
instance which produces the approximate time-evolution state, \(\rho_{k_i}(t)\), for different values of \(k_i\) depending on the provided time step,dt
.initial_state (Any) – the initial state (\(\psi_{in}\) or \(\psi_0\)) with respect to which to compute the elements \(M_{ij}\) of
LSE.A
and \(L_i\) ofLSE.b
. The type of this object must match the tensor network backend chosen for the previous arguments.
- Returns:
The
LSE
to find the dynamic MPF coefficients as described above.- Return type:
References
- [1]: S. Zhuk et al., Phys. Rev. Research 6, 033309 (2024).
https://journals.aps.org/prresearch/abstract/10.1103/PhysRevResearch.6.033309
- [2]: N. Robertson et al., arXiv:2407.17405v2 (2024).
Factory Protocols¶
The following protocols define the function signatures for the various object factory arguments.
- class IdentityStateFactory(*args, **kwargs)[source]¶
Bases:
Protocol
The factory function protocol for constructing an identity
State
instance.As explained in more detail in
setup_dynamic_lse()
, this factory function is called to initialize theDynamicMPF.evolution_state
with an identity or empty state. This function should not take any arguments and return aState
instance.
- class ExactEvolverFactory(*args, **kwargs)[source]¶
Bases:
Protocol
The factory function protocol for constructing an exact
Evolver
instance.As explained in more detail in
setup_dynamic_lse()
, this factory function is called to initialize theDynamicMPF.lhs
instances ofEvolver
which produce the exact time-evolution state, \(\rho(t)\), when computing the elements \(L_i\).
- class ApproxEvolverFactory(*args, **kwargs)[source]¶
Bases:
Protocol
The factory function protocol for constructing an approximate
Evolver
instance.As explained in more detail in
setup_dynamic_lse()
, this factory function is called to initialize either theDynamicMPF.rhs
instances ofEvolver
when computing the elements \(L_i\) or both sides (DynamicMPF.lhs
andDynamicMPF.rhs
) when computing elements \(M_{ij}\). Since these approximate time evolution states depend on the Trotter step (\(\rho_{k_i}(t)\)), this function requires the time step of the time evolution to be provided as a keyword argument calleddt
.
Core algorithm¶
- class DynamicMPF(evolution_state, lhs, rhs)[source]¶
Bases:
object
The dynamic MPF algorithm.
Instantiated with a LHS and RHS
Evolver
this algorithm willevolve()
a sharedState
up to a target evolution time. Afterwards, theDynamicMPF.overlap()
of the time-evolvedState
with some initial state can be computed. Seesetup_dynamic_lse()
for a more detailed explanation on how this is used to compute the elements \(M_{ij}\) and \(L_i\) making up theLSE
of the dynamic MPF coefficients.References
- [1]: S. Zhuk et al., Phys. Rev. Research 6, 033309 (2024).
https://journals.aps.org/prresearch/abstract/10.1103/PhysRevResearch.6.033309
- [2]: N. Robertson et al., arXiv:2407.17405 (2024).
Construct a
DynamicMPF
instance.- Parameters:
- evolution_state¶
The state shared between the LHS and RHS time-evolution engines.
- evolve(time)[source]¶
Evolve the dynamic MPF algorithm up to the provided time.
This actually runs the dynamic MPF algorithm by time-evolving
DynamicMPF.evolution_state
up to the specified time using the LHS and RHSEvolver
instances.- Parameters:
time (float) – the total target evolution time.
- Raises:
RuntimeError – if the LHS and RHS evolved times are not equal at the end.
- Return type:
None
- lhs¶
The LHS time-evolution engine.
- overlap(initial_state)[source]¶
Compute the overlap of
DynamicMPF.evolution_state
with the provided state.Warning
The type of the provided
initial_state
will depend on the chosen backend used for theState
andEvolver
instances provided to thisDynamicMPF
instance. In other words, a backend may only support a specific type ofinitial_state
objects for this overlap computation. See also the explanations of theinitial_state
argument to thesetup_dynamic_lse()
for more details.- Parameters:
initial_state (Any) – the initial state with which to compute the overlap.
- Raises:
TypeError – if the provided initial state has an incompatible type.
- Returns:
The overlap of
DynamicMPF.evolution_state
with the provided one.- Return type:
- rhs¶
The RHS time-evolution engine.