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
DynamicMPFalgorithm 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 thestaticMPF 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 thecostsmodule. 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
DynamicMPFalgorithm 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 thebackendsmodule.Below, we provide an example using the
quimb_tebdbackend. 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
DynamicMPFalgorithm for computing every element of \(M_{ij}\) and \(L_i\), we must provide factory methods for initializing the input arguments of theDynamicMPFinstances. 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_statefor more details). This constructor function may not take any positional or keyword arguments and must return aStateobject.>>> 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.lhsandDynamicMPF.rhsfor more details). These functions should follow theExactEvolverFactoryandApproxEvolverFactoryprotocols, respectively.The
ExactEvolverFactoryfunction should take aStateobject as its only positional argument and should return aEvolverobject, 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
ApproxEvolverFactoryfunction should also take aStateobject as its only positional argument and additionally a keyword argument calleddtto specify the time step of the time-evolution. It should also return aEvolverobject 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 theLSEdescribed 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
Stateobject.exact_evolver_factory (ExactEvolverFactory) – a function to initialize the
Evolverinstance which produces the exact time-evolution state, \(\rho(t)\).approx_evolver_factory (ApproxEvolverFactory) – a function to initialize the
Evolverinstance 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.Aand \(L_i\) ofLSE.b. The type of this object must match the tensor network backend chosen for the previous arguments.
- Returns:
The
LSEto 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:
ProtocolThe factory function protocol for constructing an identity
Stateinstance.As explained in more detail in
setup_dynamic_lse(), this factory function is called to initialize theDynamicMPF.evolution_statewith an identity or empty state. This function should not take any arguments and return aStateinstance.
- class ExactEvolverFactory(*args, **kwargs)[source]¶
Bases:
ProtocolThe factory function protocol for constructing an exact
Evolverinstance.As explained in more detail in
setup_dynamic_lse(), this factory function is called to initialize theDynamicMPF.lhsinstances ofEvolverwhich produce the exact time-evolution state, \(\rho(t)\), when computing the elements \(L_i\).
- class ApproxEvolverFactory(*args, **kwargs)[source]¶
Bases:
ProtocolThe factory function protocol for constructing an approximate
Evolverinstance.As explained in more detail in
setup_dynamic_lse(), this factory function is called to initialize either theDynamicMPF.rhsinstances ofEvolverwhen computing the elements \(L_i\) or both sides (DynamicMPF.lhsandDynamicMPF.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:
objectThe dynamic MPF algorithm.
Instantiated with a LHS and RHS
Evolverthis algorithm willevolve()a sharedStateup to a target evolution time. Afterwards, theDynamicMPF.overlap()of the time-evolvedStatewith 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 theLSEof 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
DynamicMPFinstance.- Parameters:
- TIME_DECIMALS: int = 8¶
The number of decimal places used for rounding the evolution times.
During the time evolution of the
evolution_state, we often compare the evolved times of the LHS and RHS engines against each other as well as the target evolution time. These checks compare floating point numbers and this setting specifies the number of decimal places to which we round.
- 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_stateup to the specified time using the LHS and RHSEvolverinstances.- 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_statewith the provided state.Warning
The type of the provided
initial_statewill depend on the chosen backend used for theStateandEvolverinstances provided to thisDynamicMPFinstance. In other words, a backend may only support a specific type ofinitial_stateobjects for this overlap computation. See also the explanations of theinitial_stateargument 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_statewith the provided one.- Return type:
- rhs¶
The RHS time-evolution engine.