VQE

VQE

In Divi, we offer two different VQE modes. The first one is a standard single-instance ground-state energy estimation, and the latter is the hyperparameter sweep mode.

Vanilla VQE

For our VQE implementation, we integrate tightly with PennyLane’s qchem module. The VQE constructor accepts a Molecule object (from PennyLane) or a pre-built hamiltonian operator. When using a Molecule, the molecular Hamiltonian is generated automatically.

The constructor also accepts an ansatz (from Divi’s ansatz library), an optimizer, and the maximum number of optimization iterations.

To extract the energy at the end of the optimization step, access the last item of the losses class variable, which stores the losses of each iteration in the form of a dictionary mapping a parameter’s ID to its actual values. For L-BFGS-B, an iteration uses one set of parameters. If using Monte-Carlo sampling, there would be as many losses as sample points.

Ansatze

Divi provides several ansatz choices for VQE:

Ansatz Description
HartreeFockAnsatz Chemistry-inspired Hartree-Fock initial state
UCCSDAnsatz Unitary Coupled Cluster Singles and Doubles
HardwareEfficientAnsatz Hardware-native entangling layers
GenericLayerAnsatz Custom gate sequences repeated in layers

You can also provide a pre-built hamiltonian (PennyLane operator) directly instead of a Molecule object.

VQE Hyperparameter Sweep

By sweeping over physical parameters like bond length and varying the ansatz, this mode enables large-scale quantum chemistry simulations — efficiently distributing the workload across cloud or hybrid backends.

This mode is particularly useful for the study molecular behavior and reaction dynamics. It also allows one to compare ansatz performance and optimizer robustness. All through a single class!

The VQEHyperparameterSweep class runs a parallelized VQE simulation across multiple bond lengths and ansatz types for a given molecule.

What’s Happening?

Step Description
VQEHyperparameterSweep(...) Initializes a batch of VQE programs over a range of bond lengths and ansatz strategies.
symbols=[...] Defines the molecule with its constituent atoms.
bond_lengths=... Sweeps bond distances across a range of values.
ansatze=[...] Runs different quantum circuit models for comparison.
create_programs() Constructs all circuits for each (bond length, ansatz) pair.
run() Executes all VQE circuits — possibly in parallel.
aggregate_results() Collects and merges the final energy values for plotting.
visualize_results() Displays a graph of energy vs. bond length for each ansatz.

Visualization

Divi comes built with visualization tools that allows the user to compare the approaches. This is an ongoing effort, the goal is to provide dashboards for better visualization and a more in-depth comparison.

Parallelized VQE energy levels

The result of running parallelized VQE

Why Parallelize VQE?

  • VQE is an iterative algorithm requiring multiple circuit evaluations per step.
  • Sweeping over bond lengths and ansatze creates hundreds of circuits.
  • Parallelizing execution reduces total compute time and helps saturate available QPU/GPU/CPU resources.

📖 For code examples and detailed API usage, visit the Divi Documentation.