Hamiltonian Variational Ansatz (HVA)¶
The Hamiltonian Variational ansatz (HVA) was inspired from 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]: Defines whether to evolve the operator naively
- parameter_prefix: str - Prefix for the generated parameters
Example¶
First the circuit is initialized to the Hartree-Fock state, then the HVA function is applied.
{
"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"
}
]
}
}
Synthesizing the ansatz circuit using the textual interface is done by opening the Command Palette (Ctrl+Shift+P / Command+Shift+P on Windows/Mac, respectively) and choosing the "Generate Ansatz" command.
from classiq import ModelDesigner
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_designer = ModelDesigner()
hf_params = HartreeFock(gs_problem=gs_problem)
output_dict = model_designer.HartreeFock(params=hf_params)
hf_output = output_dict["OUT"]
hva_params = HVA(gs_problem=gs_problem, reps=1)
model_designer.HVA(params=hva_params, in_wires={"IN": hf_output})
generation_result = model_designer.synthesize()
The output Circuit is:
[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)