Parallelized VQE
This example demonstrates how to use Divi’s VQEHyperparameterSweep
class to run a parallelized VQE simulation across multiple bond lengths and ansatz types for a hydrogen molecule (H₂).
By sweeping over physical parameters like bond length and varying the ansatz, this approach enables large-scale quantum chemistry simulations — efficiently distributing the workload across cloud or hybrid backends.
Code Example
from divi.qprog import VQEAnsatze, VQEHyperparameterSweep
from divi.qprog.optimizers import Optimizers
from divi.services import QoroService
q_service = QoroService(QORO_API_KEY)
vqe_problem = VQEHyperparameterSweep(
symbols=["H", "H"],
bond_lengths=list(np.linspace(0.1, 2.7, 15)),
ansatze=[VQEAnsatze.HARTREE_FOCK, VQEAnsatze.UCCSD],
coordinate_structure=[(0, 0, 0), (0, 0, 1)],
max_iterations=1,
optimizer=Optimizers.MONTE_CARLO,
shots=5000,
qoro_service=q_service,
)
vqe_problem.create_programs()
vqe_problem.run()
vqe_problem.aggregate_results()
print(f"Total circuits: {vqe_problem.total_circuit_count}")
print(f"Simulation time: {vqe_problem.total_run_time}")
vqe_problem.visualize_results()
What’s Happening?
Step | Description |
---|---|
VQEHyperparameterSweep(...) |
Initializes a batch of VQE programs over a range of bond lengths and ansatz strategies. |
symbols=["H", "H"] |
Defines a hydrogen molecule with two atoms. |
bond_lengths=... |
Sweeps bond distances from 0.1 to 2.7 Å in 15 steps. |
ansatze=[HARTREE_FOCK, UCCSD] |
Runs two 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. The above example produces this plot for example. This is an ongoing effort, the goal is to provide dashboards for better visualization and a more in-depth comparison.

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.
Applications
- Quantum chemistry: Study molecular behavior and reaction dynamics.
- Algorithm benchmarking: Compare ansatz performance and optimizer robustness.
- Hardware evaluation: Benchmark backend execution time and error rates under workload stress.