## Approximate Quantum Compilation via MPS Sequential Encoding

### Preliminary: What is an MPS?

Matrix Product States (MPS) are 1D tensor networks which are used to approximate dense tensors, such as statevectors, using a product of matrices and significantly
less parameters.

For instance, assume we want to represent the statevector for an N qubit circuit. Traditionally, you would need $O(2^N)$ parameters. However, with MPS we can
closely approximate the very same statevector using $O(N \chi^2)$ where $\chi$ is the bond dimension. Given a modest and constant bond dimension as we increase
$N$, we achieve an exponential reducion in the number of parameters to represent the state.

MPS is a great fit for states with a certain entanglement structure called "area-law entangled". There are rigorous definitions, but we have an easier way to
assess this. If we calculate the entanglement entropy of the subsystems of the state using density operators, and gradually increase the size of the subsystems,
we can form a line plot:

- If the plot is curved and the slope decays as we increase the size of the subsystem, this is **area-law entangled**.
- If the plot is a straight line with a slope of 1.0, this is **volume-law entangled**.

The higher the decay and lower the maximum entropy, the fewer layers required as the entanglement is weaker. With this, we can easily assess what type of states are
a good for MPS, and what may not be approximated with high fidelity. This is a bitter-sweet note about MPS as it limits the type of states it can represent faithfully,
and also the reason why we use quantum computers to be able to work with such complex states.

### How to compile an MPS to a circuit?

The best known and widely adopted algorithm for compiling MPS to a quantum circuit is the staircase approach by Shiju Ran [[1]]. We can exactly compile an MPS to a
circuit via a single layer, however, we would need $log_2(\chi) + 1$ qubits for each tensor depending on its bond dimension. This leads to having to synthesize multi-qubit
unitaries. What Ran approach proposes instead is to truncate the MPS bond dimension to 2, thus getting only one and two qubit gates, and to accommodate the fidelity issue
by using multiple layers ([[2]] Figure 1).

Ran's approach iteratively generates unitary layers that gradually disentangle the target state, and once disentangled enough it applies the layers in reverse order to prepare
the target state ([[2]] Section A, Algorithm 1).

### Qmprs Compiler

`qmprs` [[3]] is a state-of-the-art approximate quantum compiler which provides approximate quantum compilation via MPS/MPO representations. Compared to Ran's approach which is implemented in `mps_sequential.py`, `qmprs` provides higher fidelity truncations, as well as utilization of environment tensor updates to variationally optimize the layers generated by Ran to improve fidelity without changing circuit depth [[2]]. This provides consistently better fidelity which means less depth to achieve similar fidelities.

The current MPS compiler is analogous to an approximate state preparation algorithm, and assumes the initial state of the circuit to be in all zeros.

[1]: https://arxiv.org/pdf/1908.07958
[2]: https://arxiv.org/pdf/2209.00595
[3]: https://github.com/Qualition/qmprs
