151 lines
9.8 KiB
Plaintext
151 lines
9.8 KiB
Plaintext
---
|
||
title: backends (latest version)
|
||
description: API reference for qiskit_addon_mpf.backends in the latest version of qiskit-addon-mpf
|
||
in_page_toc_min_heading_level: 2
|
||
python_api_type: module
|
||
python_api_name: qiskit_addon_mpf.backends
|
||
---
|
||
|
||
<span id="module-qiskit_addon_mpf.backends" />
|
||
|
||
<span id="backends-qiskit-addon-mpf-backends" />
|
||
|
||
# Backends
|
||
|
||
`qiskit_addon_mpf.backends`
|
||
|
||
Optional backends for the [`DynamicMPF`](dynamic#dynamicmpf "qiskit_addon_mpf.dynamic.DynamicMPF") algorithm.
|
||
|
||
## Availability
|
||
|
||
Whether a certain backend can be used depends on the availability of the underlying tensor network library. This can easily be asserted at runtime using the following indicators:
|
||
|
||
### HAS\_QUIMB
|
||
|
||
<Attribute id="qiskit_addon_mpf.backends.HAS_QUIMB">
|
||
Indicates whether the optional [`quimb`](https://quimb.readthedocs.io/en/latest/autoapi/quimb/index.html#module-quimb "(in quimb v1.10)") dependency is installed.
|
||
</Attribute>
|
||
|
||
### HAS\_TENPY
|
||
|
||
<Attribute id="qiskit_addon_mpf.backends.HAS_TENPY">
|
||
Indicates whether the optional [`tenpy`](https://tenpy.readthedocs.io/en/latest/main.html#module-tenpy "(in TeNPy v1.0.5)") dependency is installed.
|
||
</Attribute>
|
||
|
||
## Backends
|
||
|
||
Depending on the availability (see above), the following backends are available:
|
||
|
||
| | |
|
||
| ---------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||
| [`quimb_tebd`](backends-quimb-tebd#module-qiskit_addon_mpf.backends.quimb_tebd "qiskit_addon_mpf.backends.quimb_tebd") | A [`quimb`](https://quimb.readthedocs.io/en/latest/autoapi/quimb/index.html#module-quimb "(in quimb v1.10)")-based TEBD backend. |
|
||
| [`quimb_layers`](backends-quimb-layers#module-qiskit_addon_mpf.backends.quimb_layers "qiskit_addon_mpf.backends.quimb_layers") | A layer-wise time-evolution backend using [`quimb`](https://quimb.readthedocs.io/en/latest/autoapi/quimb/index.html#module-quimb "(in quimb v1.10)"). |
|
||
| [`quimb_circuit`](backends-quimb-circuit#module-qiskit_addon_mpf.backends.quimb_circuit "qiskit_addon_mpf.backends.quimb_circuit") | A circuit-based time-evolution backend using [`quimb`](https://quimb.readthedocs.io/en/latest/autoapi/quimb/index.html#module-quimb "(in quimb v1.10)"). |
|
||
| [`tenpy_tebd`](backends-tenpy-tebd#module-qiskit_addon_mpf.backends.tenpy_tebd "qiskit_addon_mpf.backends.tenpy_tebd") | A [`tenpy`](https://tenpy.readthedocs.io/en/latest/main.html#module-tenpy "(in TeNPy v1.0.5)")-based TEBD backend. |
|
||
| [`tenpy_layers`](backends-tenpy-layers#module-qiskit_addon_mpf.backends.tenpy_layers "qiskit_addon_mpf.backends.tenpy_layers") | A layer-wise time-evolution backend using [`tenpy`](https://tenpy.readthedocs.io/en/latest/main.html#module-tenpy "(in TeNPy v1.0.5)"). |
|
||
|
||
## Interface
|
||
|
||
The interface implemented by any one of these optional backends is made up of the following classes:
|
||
|
||
### Evolver
|
||
|
||
<Class id="qiskit_addon_mpf.backends.Evolver" github="https://github.com/Qiskit/qiskit-addon-mpf/tree/stable/0.3/qiskit_addon_mpf/backends/interface.py#L21-L52" signature="Evolver" modifiers="class">
|
||
Bases: [`ABC`](https://docs.python.org/3/library/abc.html#abc.ABC "(in Python v3.13)")
|
||
|
||
The interface for the time-evolution algorithms used within [`DynamicMPF`](dynamic#dynamicmpf "qiskit_addon_mpf.dynamic.DynamicMPF").
|
||
|
||
This time-evolution interface is used by the [`DynamicMPF.lhs`](dynamic#lhs "qiskit_addon_mpf.dynamic.DynamicMPF.lhs") and [`DynamicMPF.rhs`](dynamic#rhs "qiskit_addon_mpf.dynamic.DynamicMPF.rhs") and should time-evolve a [`State`](#qiskit_addon_mpf.backends.State "qiskit_addon_mpf.backends.State") object under its hood. The exact mechanism of the algorithm is described in more detail in [`DynamicMPF`](dynamic#dynamicmpf "qiskit_addon_mpf.dynamic.DynamicMPF"), [`State`](#qiskit_addon_mpf.backends.State "qiskit_addon_mpf.backends.State"), and [`setup_dynamic_lse()`](dynamic#setup_dynamic_lse "qiskit_addon_mpf.dynamic.setup_dynamic_lse").
|
||
|
||
#### conjugate
|
||
|
||
<Attribute id="qiskit_addon_mpf.backends.Evolver.conjugate" attributeTypeHint="bool" modifiers="abstract property">
|
||
Returns whether this time-evolver instance acts on the right-hand side.
|
||
</Attribute>
|
||
|
||
#### evolved\_time
|
||
|
||
<Attribute id="qiskit_addon_mpf.backends.Evolver.evolved_time" attributeTypeHint="float" modifiers="abstract property">
|
||
Returns the current evolution time.
|
||
</Attribute>
|
||
|
||
#### step
|
||
|
||
<Function id="qiskit_addon_mpf.backends.Evolver.step" github="https://github.com/Qiskit/qiskit-addon-mpf/tree/stable/0.3/qiskit_addon_mpf/backends/interface.py#L30-L38" signature="step()" modifiers="abstract">
|
||
Perform a single time step of this time-evolution algorithm.
|
||
|
||
This should act on the internally referenced [`State`](#qiskit_addon_mpf.backends.State "qiskit_addon_mpf.backends.State") object (for which no name is prescribed by this interface). Whether this time-evolution algorithm instance should evolve the [`State`](#qiskit_addon_mpf.backends.State "qiskit_addon_mpf.backends.State") from the left- or right-hand side, depends on the value of [`conjugate`](#qiskit_addon_mpf.backends.Evolver.conjugate "qiskit_addon_mpf.backends.Evolver.conjugate").
|
||
|
||
**Return type**
|
||
|
||
None
|
||
</Function>
|
||
</Class>
|
||
|
||
### State
|
||
|
||
<Class id="qiskit_addon_mpf.backends.State" github="https://github.com/Qiskit/qiskit-addon-mpf/tree/stable/0.3/qiskit_addon_mpf/backends/interface.py#L55-L117" signature="State" modifiers="class">
|
||
Bases: [`ABC`](https://docs.python.org/3/library/abc.html#abc.ABC "(in Python v3.13)")
|
||
|
||
The interface for the [`DynamicMPF.evolution_state`](dynamic#evolution_state "qiskit_addon_mpf.dynamic.DynamicMPF.evolution_state").
|
||
|
||
This time-evolution state is shared between the LHS and RHS [`Evolver`](#qiskit_addon_mpf.backends.Evolver "qiskit_addon_mpf.backends.Evolver") instances of the [`DynamicMPF`](dynamic#dynamicmpf "qiskit_addon_mpf.dynamic.DynamicMPF") instance. In most cases where a concrete backend implementing this interface is based on tensor networks, this state will be a matrix product operator (MPO). This is because most time-evolution algorithms would normally evolve a matrix product state (MPS) as shown pictorially below, where time evolution blocks (`U#`) are successively applied to a 1-dimensional MPS (`S#`). Here, the tensor network grows towards the right as time goes on.
|
||
|
||
```python
|
||
MPS Evolution
|
||
|
||
S0┄┄┲━━━━┱┄┄┄┄┄┄┄┄┲━━━━┱┄
|
||
│ ┃ U1 ┃ ┃ U5 ┃
|
||
S1┄┄┺━━━━┹┄┲━━━━┱┄┺━━━━┹┄
|
||
│ ┃ U3 ┃
|
||
S2┄┄┲━━━━┱┄┺━━━━┹┄┲━━━━┱┄ ...
|
||
│ ┃ U2 ┃ ┃ U6 ┃
|
||
S3┄┄┺━━━━┹┄┲━━━━┱┄┺━━━━┹┄
|
||
│ ┃ U4 ┃
|
||
S4┄┄┄┄┄┄┄┄┄┺━━━━┹┄┄┄┄┄┄┄┄
|
||
```
|
||
|
||
However, in our case, we want two time-evolution engines to share a single state. In order to achieve that, we can have one of them evolve the state from the right (just as before, `U#`), but have the second one evolve the state from the left (`V#`). This requires the state to also have bonds going of in that direction, rendering it a 2-dimensional MPO (`M#`) rather than the 1-dimensional MPS from before.
|
||
|
||
```python
|
||
MPO Evolution
|
||
|
||
┄┲━━━━┱┄┄┄┄┄┄┄┄┲━━━━┱┄┄M0┄┄┲━━━━┱┄┄┄┄┄┄┄┄┲━━━━┱┄
|
||
┃ V5 ┃ ┃ V1 ┃ │ ┃ U1 ┃ ┃ U5 ┃
|
||
┄┺━━━━┹┄┲━━━━┱┄┺━━━━┹┄┄M1┄┄┺━━━━┹┄┲━━━━┱┄┺━━━━┹┄
|
||
┃ V3 ┃ │ ┃ U3 ┃
|
||
... ┄┲━━━━┱┄┺━━━━┹┄┲━━━━┱┄┄M2┄┄┲━━━━┱┄┺━━━━┹┄┲━━━━┱┄ ...
|
||
┃ V6 ┃ ┃ V2 ┃ │ ┃ U2 ┃ ┃ U6 ┃
|
||
┄┺━━━━┹┄┲━━━━┱┄┺━━━━┹┄┄M3┄┄┺━━━━┹┄┲━━━━┱┄┺━━━━┹┄
|
||
┃ V4 ┃ │ ┃ U4 ┃
|
||
┄┄┄┄┄┄┄┄┺━━━━┹┄┄┄┄┄┄┄┄┄M4┄┄┄┄┄┄┄┄┄┺━━━━┹┄┄┄┄┄┄┄┄
|
||
```
|
||
|
||
#### overlap
|
||
|
||
<Function id="qiskit_addon_mpf.backends.State.overlap" github="https://github.com/Qiskit/qiskit-addon-mpf/tree/stable/0.3/qiskit_addon_mpf/backends/interface.py#L101-L117" signature="overlap(initial_state)" modifiers="abstract">
|
||
Compute the overlap of this state with the provided initial state.
|
||
|
||
<Admonition title="Warning" type="caution">
|
||
A concrete implementation of this method should raise a [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.13)") if the provided `initial_state` object is not supported by the implementing backend.
|
||
</Admonition>
|
||
|
||
**Parameters**
|
||
|
||
**initial\_state** ([*Any*](https://docs.python.org/3/library/typing.html#typing.Any "(in Python v3.13)")) – the initial state with which to compute the overlap.
|
||
|
||
**Raises**
|
||
|
||
[**TypeError**](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.13)") – if the provided initial state has an incompatible type.
|
||
|
||
**Returns**
|
||
|
||
The overlap of this state with the provided one.
|
||
|
||
**Return type**
|
||
|
||
[complex](https://docs.python.org/3/library/functions.html#complex "(in Python v3.13)")
|
||
</Function>
|
||
</Class>
|
||
|