Closed yaelbh closed 4 years ago
We tried (1) and (4) on a few benchmarks, and they were slow. Since (1) is slow, this implies that (2) is expected to improve. We also tried (3) and saw a speed-up, but it may become less important once (2) is done.
The current implementation in the code is (4). When I compared this to the original code, I saw no difference. I preferred this implementation for a few reasons. One of them is that it may allow parallelization of the terms of the expectation value.
Yes, I was wrong: (4) gave the same run time, (1) was much slower. Since (4) is selected, (3) is not relevant anymore.
For a snapshot approach the Pauli expectation value should be able to be computed with an efficient local contraction on the MPS tensor without any copies or swaps.
Starting from one end of the tensor you would take inner product over each qubit tensor index with its conjugate tensor contracting with a Pauli (or just tracing for identity terms). Something like this (but with Pauli's added in)
Here is some documentation for doing it in iTensor: http://itensor.org/docs.cgi?vers=julia&page=formulas/measure_mps
@chriseclectic , thanks for the suggestion, but this is already what we implemented in PR#344. The reason we do a copy of the MPS structure is because computing the expectation value destroys the structure of the MPS. This is needed because we may need to compute several expectation values (as in VQE), or for any case that computing the expectation value is not the last operation on the circuit.
A couple more suggestions for improvement:
The first one is already listed above as (2): Suppose that the Pauli term involves qubits 1 and 3. Currently there is a swap operation that brings them together, which may increase the tensors. Possibly better to insert identity on qubit 2 and calculate the expectation value on qubits 1, 2, 3 together.
I believe this was fixed by #812. Feel free to reopen @yaelbh @merav-aharoni if you think there are further optimizations to implement
Several suggestions to optimize Pauli expectation value in the MPS simulator: