Hardware Efficient Ansatz
The hardware efficient ansatz (HEA, HardwareEfficientAnsatz
)
[48] is a lower-depth alternative to
chemistry-inspired ansatzes, such as UCCSD. It is “physics-agnostic” in the sense that
couplings/entanglements between qubits do not take into account chemical/physical information.
Rather, the circuit structure consists of layers of rotations and entangling operations; each layer contains
blocks of single qubit rotation gates separated by a block of 2-qubit entanglers.
While this leads to circuits that are more efficient in depth compared to UCC, the HEA ansatz does not consider
spin or particle number symmetries, so unwanted symmetry breaking is more likely for HEA during a variational
algorithm. Hence, this ansatz should be used with caution.
The unitary operator corresponding to HEA, with one block of \(R_x\) rotations per layer, can be expressed as:
where \(N_{\text{q}}\) is the number of qubits, \(N_{\text{L}}\) is the number of layers, and index \(l\) labels the layers (indexing is in reverse order). The final layer (\(l=1\)) is terminated with another set of single qubit rotations (the \(\text{cap}\) or “capping” block).
Here, a parameter \(\theta_{i, l}\) corresponds to a single qubit rotation applied to the \(i^{\text{th}}\) qubit in the \(l^{\text{th}}\) HEA layer (the capping block also has independent rotation angles).
Each rotation block can consist of \(R_x\), \(R_y\), and/or, \(R_z\) rotations (hence each layer can have up to 3 blocks of rotations - the selection of which is also reflected in the number of capping blocks at the end of the circuit), while each entangling block consists of controlled-\(X\) (CNOT) 2-qubit gates. The following example shows how to create a HEA ansatz using InQuanto. This example is for 2 HEA layers, each one consisting of a block of \(R_x\) rotations, a block of \(R_y\) rotations, and a block of CNOT 2-qubit entanglers (with the final capping blocks of \(R_x\) and \(R_y\) rotations applied after the second HEA layer)
from inquanto.ansatzes import HardwareEfficientAnsatz
from inquanto.states import QubitState
from pytket.circuit import OpType
ansatz = HardwareEfficientAnsatz(
[OpType.Rx, OpType.Ry], reference=QubitState([1, 1, 0, 0]), n_layers=2
)
report_hea = ansatz.generate_report()
print("Number of parameters: {}".format(
report_hea['n_parameters'])
)
print("Number of qubits: {}".format(
report_hea['n_qubits'])
)
print("Ansatz circuit depth: {}".format(
report_hea['ansatz_circuit_depth'])
)
hea_circuit = ansatz.get_circuit(
ansatz.state_symbols.construct_random()
)
Number of parameters: 24
Number of qubits: 4
Ansatz circuit depth: 12
As with all other InQuanto Ansatz objects, the generate_report()
method can be used to extract information
about the quantum circuit representing the HEA ansatz, and the circuit object itself can be accessed
by the get_circuit()
method. Unlike UCC, this is an ansatz that is built at the
circuit level directly, hence a fermion-to-qubit mapping is not needed to construct the HEA ansatz
object.