Skip to content

Quantum Ansatz Circuits

Anton Lokhmotov edited this page Dec 24, 2018 · 7 revisions

The Ansatz circuit in VQE

Introduction

In VQE, each time you run a circuit on the quantum computer you are discovering the energy for a particular quantum state. This state is created by the ansatz circuit.

When a quantum computer first starts up, it is in the all zeros state. This is written as either |00...00> or simply |0>, and means if you measure any qubit you will get the result 0. This is like when you start your laptop, all RAM cells are off.

The job of the ansatz circuit is to transform this state to the state that represents the ground state of the molecule. In order to do this, most ansatz circuits are parametric, and you will run the circuit many times with different parameters looking for the lowest energy. Details on this part of VQE are available here.

Example ansatz circuits

The simplest ansatz circuit for Hydrogen is known as tiny1. Within QCK, you can look at any of the provided (IBM-compatible) ansatz circuits by following the instructions here.

For atomic Hydrogen is has been shown that for any bond length the ground state energy is purely a superposition of the $\ket{00}  + \ket{11}$1 basis set elements. The tiny1 ansatz controls the relative amount of each basis set element with its single parameter. Using Quirk, we can visualize this circuit now:

tiny1 circuit showing the final state in a superposition of 00 and 11 states.

The rightmost block on this circuit shows the amplitudes of observing the |00> or |11> states. The spheres on each wire show the angle of the qubit in the Bloch sphere - a way of representing the 2 degrees of freedom of a single qubit as a point on a ball. By looking at this sphere we can see that X, Y, and Z gates rotate the qubit. This is shown vary clearly in an animated version with a changing parameter here. In this view we can see the classically counterintuitive behavior of the second CNOT gate - it has changed the state of the first qubit! Despite the first qubit being called the control, a CNOT gate actually entangles both qubits.

If you are more interested in investigating classical optimisation methods, you can simply try several ansatz circuits provided by the QCK framework. Or read on if you want to learn more about the Hardware Efficient Ansatz, but be warned: it is a dense topic and not required for exploring the QCK challenge!

Research proposal: investigate the hardware efficient ansatz

The hardware efficient ansatz is composed of rotations and entangling gates. It is so called because both the rotations and the entangling gates can efficiently run on Noisy Intermediate Scale Quantum (NISQ) computers. NISQ computers have gate fidelities from 99% and better, but this level of precision is not high enough to run a long computation without any errors. Algorithms for NISQ computers must mitigate this to provide correct results. Shorter circuits have fewer opportunities for errors to occur.

The hardware efficient ansatz, used by Kandala et al for VQE in a recent paper and introduced by Farhi, is a minimal general ansatz. It alternates rotations and entangling gates as shown here for a 2-qubit problem:

A depth 2, 2 qubit hw efficient ansatz circuit with all parameters described as theta of i, acting on the zero state.

This circuit takes |0> to |P(thetas)> where thetas is the list of parameters on the gates in square boxes (rotation gates). |P(thetas)> will be our best guess for the lowest energy state of the molecule. The circled plus with a dot above is a Controlled-NOT gate (CNOT).

The circuit consists of a repeating section of 2-3 rotations on each qubit followed by an entangling gate, the CNOT. Given sufficient levels of depth, this circuit can construct arbitrary states, but the number of parameters it takes grows quickly. Read on to learn more about the rotation and entangling gates!

For the IBM experiments on real hardware the "drift Hamiltonian", the ambient interactions of qubits when no gate was actively applied, was used as an entangler. For a superconducting quantum computer, the strength of qubit interactions can be set as part of applying a gate. For the "drift Hamiltonian" gate, the interactions are turned on between all qubits and an external field is applied. This causes all qubits to interact in a semi-controllable manner.

Rotation gates

The first part of the HW ansatz is a sequence of rotation gates on each qubit. The state of a single qubit, not entangled with any other, corresponds to a point on the Bloch sphere:

Bloch sphere for a qubit: drawn by Glosser.ca under CC BY-SA 3.0

For a physical system like an electron in a magnetic field, the directions on the Bloch sphere are physically meaningful: they correspond to the direction of the spin. For qubits, in general, we do not know the physical architecture of the computer, and so we assign |0> and |1> and the Z direction to the basis we measure in. The Rx, Ry, and Rz gates acting on a qubit will rotate the qubit's state by the given angles around the Bloch sphere.

The system starts in |0>, so rotations about Rz will have no effect. This is why the first set of Rz gates is absent from the HW ansatz shown above.

Rotation gates are required for moving in state space, but cannot generate a superposition of states by themselves as each qubit is separate. For this, we need an entangling gate.

The entangling gate

A simple state that is not separable in the computational basis is the Bell state $\ket{00}  + \ket{11}$1.

In order to generate this state from $\ket{00}$ we first apply a Hadamard gate on the first qubit to get the state $\ket{00}  + \ket{01}$. Then applying a CNOT gate controlled by the first qubit on the second qubit will generate $\ket{00} + \ket{11}$ as desired. But without the 2 qubit gate there is no way to produce states that have this mutual information - the state of the second qubit has become linked to the state of the first.

In a molecular context, this often appears as electron correlation. When one electron is in a particular location other electrons will tend to be repelled and so the positions of the electrons become correlated just like the bell state. The ability to create correlated states means that VQE solutions are equivalent in quality to full configuration interaction (FCI) solutions from existing quantum chemistry packages but with far lower resource requirements.

Avenues for improvements

The hardware efficient ansatz, as written, uses CNOT gates. In fact, you can replace the CNOT gate with any other many-qubit entangling gate. By using many-qubit gates optimally supported by your chosen hardware provider, the resource usage of the circuit could be reduced. For IBM the drift "gate" is very practical and acts over all the qubits. Alternatively, Righetti has provided a very general 2 qubit gate as described here. This requires many more gates but a parameterised 2 qubit gate may provide faster convergence for complex molecules.

Other groups have suggested that it might be best to prepare states from your knowledge of the chemistry problem, as opposed to using gates that can be efficiently run on your chosen quantum computer. A recent review gives detail on the space of ansatz circuits people have tried so far.

footnotes

1: A quick note on normalisation: for any physical state, the squares of the absolute values of the factors before the kets (i.e. the $1.0$ in $1.0 \ket{0}$) must add to one. This is because the probability of seeing a state when you measure a state must be 1. The factors in the bell state $\ket{00} + \ket{11}$ add to $\sqrt{1.0*1.0 + 1.0*1.0} = \sqrt{2}$, and so to be properly correct a factor of $\frac{1}{\sqrt{2}}$ should be present. This clutters the notation and so we omit this as you can work out the normalisation factors from the state.

Clone this wiki locally