Four Dials and an Energy Meter

variational eigensolver · ansatz · black-box optimization · evaluation budget · coordinate descent

A two-qubit chip has four dials t_0, t_1, t_2, t_3 (angles in radians). Starting from |00\rangle it applies

  1. R_y(t_0) to qubit 0 and R_y(t_1) to qubit 1,
  2. CNOT(0, 1) (flips qubit 1 when qubit 0 is 1),
  3. R_y(t_2) to qubit 0 and R_y(t_3) to qubit 1,

with R_y(\theta)=\begin{pmatrix}\cos\frac\theta2&-\sin\frac\theta2\\\sin\frac\theta2&\cos\frac\theta2\end{pmatrix}. A meter reads the energy \langle H\rangle = \sum_k c_k\langle\psi|P_k|\psi\rangle of the resulting state for a hidden two-qubit H, a list of terms (coefficient, Pauli string) such as [(1, "ZZ"), (0.5, "XI"), (0.5, "IX")] (leftmost letter = qubit 0). Your job, the variational eigensolver: turn the dials to make the energy as small as possible.

Write find_ground(energy, budget) that returns your best setting as a list of 4 angles.

  • energy(params) takes a list of 4 angles and returns \langle H\rangle for that setting. Every call counts.
  • You may call energy at most budget times. One more call raises BudgetExceeded.
  • Your function never sees H; the meter is its only window. Every string of H has an even number of Ys, so the matrix of H is real, and for such H these four dials can reach its smallest eigenvalue exactly.

The tests run run_vqe(find_ground, terms, budget), which hands your function the meter for terms, then reads the energy at the angles you return (that last reading is free). Try it with Run, for example print(run_vqe(find_ground, [(1, "ZZ"), (0.5, "XI"), (0.5, "IX")], 120)), and compare with np.linalg.eigvalsh of the 4 \times 4 matrix of H.

How this problem is scored

Your answer passes if its energy is at most that of the best of budget random settings (each angle uniform in [0, 2\pi), drawn by the checker). Its quality (0 to 100) measures how much of the way you get from random search to the smallest eigenvalue E_0 of H on a logarithmic scale: with g your gap E - E_0 and g_r the gap of random search, the quality is 100\cdot\frac{\log_{10} g_r - \log_{10} g}{\log_{10} g_r + 8}, and 100 once g \le 10^{-8}. Every factor of ten closer counts the same.

Examples

Input:  run_vqe(find_ground, [(1, "ZZ"), (0.5, "XI"), (0.5, "IX")], 120)
Output: {"energy": ..., "evaluations": ..., "terms": ..., "budget": 120}
        smallest eigenvalue -1.4142135623730951; passes when energy <= random search

Constraints

  • 100 <= budget <= 250; H has 3 to 7 terms with coefficients between -2 and 2.
  • Bound your loops by the budget, never by time. random is seeded for every test, so your result is the same on every run.

Goals

  • Minimise the energy of a two-qubit ansatz when every evaluation counts
  • Use the shape of the energy along one dial to choose the next setting
  • Compare the result with the true smallest eigenvalue
Starting Python…