Variational Quantum Eigensolver (VQE) Algorithm Implementation
VQE is a quantum-classical hybrid algorithm for finding the ground state energy of quantum systems. It uses a parameterized quantum circuit (ansatz) to prepare trial states and classical optimization to minimize the energy expectation value.
Key Features:
Algorithm Flow:
This implementation targets production use with real quantum hardware.
Variational Quantum Eigensolver (VQE) Algorithm Implementation VQE is a quantum-classical hybrid algorithm for finding the ground state energy of quantum systems. It uses a parameterized quantum circuit (ansatz) to prepare trial states and classical optimization to minimize the energy expectation value. Key Features: - Multiple ansatz types (hardware-efficient, UCCSD-inspired, symmetry-preserving) - Pau ;; Fallback to standard optimization without convergence monitoring for non-enhanced objectives (va/run-variational-optimization objective-fn initial-parameters options)))) ;; Fallback to standard optimization without convergence monitoring for non-enhanced objectives (va/run-variational-optimization objective-fn initial-parameters options)))) string Hamiltonian representation with measurement grouping - Integration with fastmath optimization for classical optimization - Comprehensive analysis and convergence monitoring - Support for both gate-based and measurement-based implementations Algorithm Flow: 1. Initialize parameterized quantum circuit (ansatz) 2. Prepare trial state |ψ(θ)⟩ with parameters θ 3. Measure expectation value ⟨ψ(θ)|H|ψ(θ)⟩ 4. Use classical optimizer to update parameters 5. Repeat until convergence This implementation targets production use with real quantum hardware.
(heisenberg-hamiltonian num-sites)
(heisenberg-hamiltonian num-sites coupling)
(heisenberg-hamiltonian num-sites coupling periodic)
Create a Heisenberg model Hamiltonian for a 1D chain.
H = J Σᵢ (XᵢXᵢ₊₁ + YᵢYᵢ₊₁ + ZᵢZᵢ₊₁)
Parameters:
Returns: Collection of Pauli terms
Create a Heisenberg model Hamiltonian for a 1D chain. H = J Σᵢ (XᵢXᵢ₊₁ + YᵢYᵢ₊₁ + ZᵢZᵢ₊₁) Parameters: - num-sites: Number of sites in the chain - coupling: Coupling strength J (default: 1.0) - periodic: Whether to use periodic boundary conditions (default: true) Returns: Collection of Pauli terms
(molecular-hydrogen-hamiltonian)
(molecular-hydrogen-hamiltonian bond-distance)
Create the molecular hydrogen (H₂) Hamiltonian in the STO-3G basis using Jordan-Wigner encoding.
This implementation provides the standard H₂ Hamiltonian used in quantum computing literature, mapped to a 4-qubit system via the Jordan-Wigner transformation. The qubit mapping follows the standard convention:
qubit 0: First spin orbital
qubit 1: Second spin orbital
qubit 2: Third spin orbital
qubit 3: Fourth spin orbital
The Hartree-Fock reference states |0011⟩ and |1100⟩ are degenerate in this representation, with the true ground state being a superposition that VQE should discover.
High-precision coefficients from Kandala et al. Nature (2017) ensure:
Parameters:
Returns: Collection of Pauli terms representing the H₂ molecular Hamiltonian with μHa precision
Create the molecular hydrogen (H₂) Hamiltonian in the STO-3G basis using Jordan-Wigner encoding. This implementation provides the standard H₂ Hamiltonian used in quantum computing literature, mapped to a 4-qubit system via the Jordan-Wigner transformation. The qubit mapping follows the standard convention: qubit 0: First spin orbital qubit 1: Second spin orbital qubit 2: Third spin orbital qubit 3: Fourth spin orbital The Hartree-Fock reference states |0011⟩ and |1100⟩ are degenerate in this representation, with the true ground state being a superposition that VQE should discover. High-precision coefficients from Kandala et al. Nature (2017) ensure: - Hartree-Fock energy: EXACTLY -1.117 Ha (μHa precision) - VQE ground state target: ~-1.137 Ha - Accuracy for quantum hardware implementations Parameters: - bond-distance: H-H bond distance in Angstroms (coefficient set is optimized for 0.735 Å) Returns: Collection of Pauli terms representing the H₂ molecular Hamiltonian with μHa precision
(post-optimization-analysis vqe-result analysis-options)
Comprehensive post-optimization analysis using result framework.
This function performs detailed analysis of VQE results, including:
Parameters:
Returns: Comprehensive analysis report
Comprehensive post-optimization analysis using result framework. This function performs detailed analysis of VQE results, including: - Energy landscape analysis around optimal point - Quantum state characterization - Measurement statistics and confidence intervals - Hardware compatibility assessment Parameters: - vqe-result: Complete VQE result map - analysis-options: Options for analysis depth and methods Returns: Comprehensive analysis report
(variational-quantum-eigensolver backend options)
Main VQE algorithm implementation.
This function orchestrates the VQE process, including ansatz creation, optimization, and execution on a quantum backend. It supports various ansatz types and optimization methods, allowing for flexible configuration based on the problem and available resources.
Supported ansatz types:
Supported optimization methods:
Parameters:
Returns: Map containing VQE results and analysis
Example: (variational-quantum-eigensolver backend {:hamiltonian [{:coefficient 1.0 :terms [[0 1]]} {:coefficient -0.5 :terms [[0 0] [1 1]]}] :ansatz-type :hardware-efficient :num-qubits 2 :num-layers 2 :optimization-method :adam :max-iterations 100 :tolerance 1e-5 :shots 2048})
Main VQE algorithm implementation. This function orchestrates the VQE process, including ansatz creation, optimization, and execution on a quantum backend. It supports various ansatz types and optimization methods, allowing for flexible configuration based on the problem and available resources. Supported ansatz types: - :hardware-efficient - Hardware-efficient ansatz with configurable layers and entangling gates - :chemistry-inspired - Chemistry-inspired ansatz with excitation layers - :uccsd - UCCSD ansatz for chemistry problems - :symmetry-preserving - Symmetry-preserving ansatz for fermionic systems - :custom - Custom ansatz function provided in options Supported optimization methods: - :gradient-descent - Basic gradient descent with parameter shift gradients - :adam - Adam optimizer with parameter shift gradients - :quantum-natural-gradient - Quantum Natural Gradient using Fisher Information Matrix - :nelder-mead - Derivative-free Nelder-Mead simplex method - :powell - Derivative-free Powell's method - :cmaes - Covariance Matrix Adaptation Evolution Strategy (robust) - :bobyqa - Bound Optimization BY Quadratic Approximation (handles bounds well) - :gradient - Fastmath gradient-based optimizers (not available in this version) Parameters: - backend: Quantum backend implementing QuantumBackend protocol - options: Additional options map for execution - :optimization-method - Optimization method to use (default: :adam) - :max-iterations - Maximum iterations for optimization (default: 500) - :tolerance - Convergence tolerance (default: 1e-6) - :ansatz-type - Ansatz type to use (default: :hardware-efficient) - :num-qubits - Number of qubits in the circuit (default: 2) - :num-layers - Number of layers for hardware-efficient ansatz (default: 1) - :num-excitation-layers - Number of excitation layers for chemistry-inspired ansatz (default: 1) - :num-excitations - Number of excitations for UCCSD ansatz (default: 2) - :num-particles - Number of particles for symmetry-preserving ansatz (default: 2) - :shots - Number of shots for circuit execution (default: 1024) Returns: Map containing VQE results and analysis Example: (variational-quantum-eigensolver backend {:hamiltonian [{:coefficient 1.0 :terms [[0 1]]} {:coefficient -0.5 :terms [[0 0] [1 1]]}] :ansatz-type :hardware-efficient :num-qubits 2 :num-layers 2 :optimization-method :adam :max-iterations 100 :tolerance 1e-5 :shots 2048})
cljdoc builds & hosts documentation for Clojure/Script libraries
Ctrl+k | Jump to recent docs |
← | Move to previous article |
→ | Move to next article |
Ctrl+/ | Jump to the search field |