Skip to content

Hamiltonian Variational Ansatz (HVA)

The Hamiltonian Variational Ansatz (HVA) was inspired by the quantum approximate optimization algorithm [1] , [2] .

Syntax

Function: HVA

Parameters:

  • gs_problem: [MoleculeProblem] – MoleculeProblem object describing the molecule.
  • reps: [int] – Number of layers in the ansatz.
  • use_naive_evolution: [bool] – Determines whether to evolve the operator naively.
  • parameter_prefix: str – Prefix for the generated parameters.

Example

Initialize the circuit to the Hartree-Fock state and then apply the HVA function.

{
    "ground_state_problem": {
        "molecule": {
            "atoms": [["H", [0, 0, 0]], ["H", [0, 0, 0.735]]]
        },
        "basis": "sto3g",
        "mapping": "jordan_wigner",
        "num_qubits": 4
    },
    "model": {
        "logic_flow": [
            {
               "function": "HartreeFock",
               "function_params": {"gs_problem": "ground_state_problem"},
               "outputs": "hf_out"
            },
            {
                "function": "HVA",
                "function_params": {
                    "gs_problem": "ground_state_problem",
                    "reps": 1
                },
                "inputs": "hf_out"
            }
        ]
    }
}

Synthesize the ansatz circuit using the textual interface by opening the Command Palette (Ctrl+Shift+P / Command+Shift+P on Windows/Mac, respectively) and choosing the "Generate Ansatz" command.

from classiq import Model
from classiq.builtin_functions import HartreeFock, HVA
from classiq.applications.chemistry import Molecule, MoleculeProblem


molecule = Molecule(
    atoms=[("H", (0.0, 0.0, 0.0)), ("H", (0.0, 0.0, 0.735))],
)
gs_problem = MoleculeProblem(
    molecule=molecule,
    mapping="jordan_wigner",
)
gs_problem = gs_problem.update_problem()

model = Model()

hf_params = HartreeFock(gs_problem=gs_problem)
output_dict = model.HartreeFock(params=hf_params)
hf_output = output_dict["OUT"]

hva_params = HVA(gs_problem=gs_problem, reps=1)

model.HVA(params=hva_params, in_wires={"IN": hf_output})
generation_result = model.synthesize()

The output circuit:

alt text

[1] Dave Wecker, Matthew B. Hastings, and Matthias Troye Towards Practical Quantum Variational Algorithms. Phys. Rev. A 92, 042303 (2015).

[2] Roeland Wiersema, Cunlu Zhou, Yvette de Sereville, Juan Felipe Carrasquilla, Yong Baek Kim, Henry Yuen Exploring entanglement and optimization within the Hamiltonian Variational Ansatz . PRX Quantum 1, 020319 (2020).