Disclaimer: most of my comprehension of VQE comes from Musty Thoughts, and I highly recommend his articles to get a deeper explanation of VQE.
- The VQE uses as many qubits in parallel as terms in the Hamiltonian
No, for a sum of $2^n\times2^n$ Hamiltonians, $n$ qubits are used. The number of terms in this sum is irrelevant.
The principle in VQE is that you want to find the smallest eigenvalue of a sum of Hamiltonian that can be written as Pauli strings. For instance, let's say that for the $2$-qubit case the Hamiltonian is:
$$H=3XY -2ZX$$
(Note: here the product is the tensor product $XY=X\otimes Y$)
What VQE does is:
- Prepare a state accordingly to the ansatz and the current parameters (initially chosen randomly)
- For each Pauli string in the sum, you will measure the state in the appropriate basis: $\left\{|0\rangle,|1\rangle\right\}$ for $Z$, $\left\{|+\rangle,|-\rangle\right\}$ for $X$, $\left\{|i\rangle,|-i\rangle\right\}$ for $Y$ (and no measure for $I$, we assume we always measure $1$). You will do this process enough times to get a good approximate of these expectation values, and once per Pauli strings in the sum.
- You update the parameters accordingly to the results you got, and you repeat.
Thus, you can see that the number of qubits is linked to the length of the Pauli strings in our Hamiltonian. The number of terms in the sum is rather the number of iterations needed to make a step within the algorithm.
- To obtain the expectation value for each Hamiltonian term you need to perform the blue background algorithm part several times, each time starting with the same ansatz parameters
You're right about this.
- Once expectation values are all estimated for the first used ansatz parameters, the expectation value of Hamiltonian can be classically computed from Eq. 1. To optimize the ansatz parameters, the previous steps need to be performed again with a priori other random ansatz parameters until one retrieves a map of ⟨H⟩
with respect to ansatz parameters and is able to numerically approach ⟨H⟩
partial derivative with respect to these ansatz parameters.
You're almost right. You can indeed compute $\langle\psi(\theta)|H|\psi(\theta)\rangle$ once you got all the $\langle\psi(\theta)|H_i|\psi(\theta)\rangle$, but the parameters are not randomly selected. The point is to use a classical optimization algorithm that will tell us which parameters we should try next.
Basically, most of these algorithms work like this: we give them a number of parameters and the bounds for these parameters, and the function to optimize. Here, the function is $\langle\psi(\theta)|H|\psi(\theta)\rangle$ and the parameters are $\theta$. So, we launch the optimizer, they tell us "ok, give me the value of $\langle\psi\left(\theta_1\right)|H|\psi\left(\theta_1\right)\rangle$", we compute it on the Quantum Computer, we give it back to the optimizer, and they give us back another value which should be a little bit better.
The way these optimizers work is however way out-of-scope of this question (and probably of this site).
Don't hesitate to tell me whether something's not clear!