qrunch.quantum.algorithms.second_quantization.vqes.adaptive_vqe
Module containing adaptive VQE.
Classes
Builder for the adaptive VQE algorithm. |
|
VQE that takes an adaptive VQE as the underlying algorithm. |
|
Builder for the adaptive VQE algorithm. |
- class BeastSecondQuantizationAdaptiveVqeCreator
Bases:
VqeCreatorEstimatorMixin[AdaptiveVqeCreator],VqeCreatorMinimizerMixin[AdaptiveVqeCreator],VqeCreatorReminimizerMixin[AdaptiveVqeCreator],VqeCreatorOptionsMixin[AdaptiveVqeCreator],VqeCreatorStoppingCriterionMixin[AdaptiveVqeCreator],VqeCreatorAnalyticalBeastVqeMixin[AdaptiveVqeCreator],VqeCreatorDataPersisterManagerMixin[AdaptiveVqeCreator]Builder for the adaptive VQE algorithm.
- __init__(gate_selector_builder: FastGateSelectorCreator) None
Initialize builder for the adaptive VQE.
- Parameters:
gate_selector_builder (FastGateSelectorCreator)
- Return type:
None
- choose_data_persister_manager() DataPersisterManagerSubCreator[Self]
Choose the data persister manager to use and whether to save and/or load the data.
- Return type:
- choose_minimizer() MinimizerSubCreator[Self]
Choose minimizer to use for the VQE.
- Return type:
MinimizerSubCreator[Self]
- choose_reminimizer() ReMinimizerSubCreator[Self]
Choose reminimizer to use for the VQE.
- Return type:
ReMinimizerSubCreator[Self]
- choose_stopping_criterion() StoppingCriterionSubCreator[Self]
Choose stopping criterion to use for the VQE.
- Return type:
- create() SecondQuantizationAdaptiveVqe
Create an instance of
SecondQuantizationAdaptiveVqe.- Return type:
- with_analytical_beast_basic_vqe(*, active: bool = True) Self
Choose to use the analytical basic vqe inside each adaptive iteration, which only works for BEAST.
Instead of having the minimizer call the estimator directly, the estimator is first called to make an analytical expression for the energy as a function of the gate parameter. This expression is then passed to the minimizer, requiring no more measurements.
Note: This feature only works with BEAST with last parameter optimization.
If a reminimizer is chosen, it will be paired with the normal Basic vqe since, only it, supports multiple parameters at once.
- Parameters:
active (bool) – Whether to use the analytical beast basic vqe or not.
- Return type:
Self
- with_estimator(estimator: Estimator) Self
Set the estimator to use for the VQE.
- Parameters:
estimator (Estimator) – Estimator to use. Can be created using the
estimator_creator()builder.- Return type:
Self
- with_estimator_shots(shots: int | None) Self
Set the number of shots to use in the estimator.
- Parameters:
shots (int | None) – Number of shots to use in the estimator. If None is given, the estimator is assumed to be exact
simulator). ((e.g. the excitation gate)
- Return type:
Self
- with_gate_selector_sampler(sampler: Sampler) Self
Set the sampler for the gate selector to use for the VQE.
- Parameters:
sampler (Sampler) – The sampler to use. Can be created using the
sampler_creator().- Return type:
Self
- with_gate_selector_shots(shots: int | None) Self
Set the shots on the gate selector to use for the VQE.
- Parameters:
shots (int | None) – The number of shots to use in the Gate selector.
- Return type:
Self
- with_options(options: IterativeVqeOptions) Self
Set the options to use for the VQE.
- Parameters:
options (IterativeVqeOptions) – Options to use.
- Return type:
Self
- class SecondQuantizationAdaptiveVqe
Bases:
SecondQuantizationAdaptiveVqeAlgorithmVQE that takes an adaptive VQE as the underlying algorithm.
- __init__(vqe: PauliAdaptiveVqeAlgorithm, mapper: Mapper | None = None) None
Initialize adaptive VQE.
- Parameters:
vqe (PauliAdaptiveVqeAlgorithm) – VQE to use.
mapper (Mapper | None) – Mapper to use for creating qubit Hamiltonian.
- Return type:
None
- clear_cache() None
Clear the cache of the underlying VQE.
- Return type:
None
- classmethod persistence_checkpoints() list[str]
Define the persistence checkpoints used during the adaptive vqe.
These checkpoints specify computational stages where intermediate results can be saved and loaded to optimize computations and ensure reproducibility.
- Return type:
list[str]
- run(second_quantized_operator: T, gate_pool: GatePool, initial_ansatz: Circuit, callback: AdaptiveIterationCallback | None = None, input_result: SecondQuantizationAdaptiveVqeResult[T] | None = None) SecondQuantizationAdaptiveVqeResult[T]
Run the VQE and find the eigenvalue.
- Parameters:
second_quantized_operator (T) – The operator whose expectation value should be minimized.
gate_pool (GatePool) – The set of gates to choose from when building the ansatz.
initial_ansatz (Circuit) – The starting ansatz circuit. Gates from the gate_pool is appended to this.
callback (AdaptiveIterationCallback | None) – An optional callback function that is called at each minimizer iteration.
input_result (SecondQuantizationAdaptiveVqeResult[T] | None) – A prior results that should be refined.
- Return type:
- class SecondQuantizationAdaptiveVqeCreator
Bases:
VqeCreatorEstimatorMixin[AdaptiveVqeCreator],VqeCreatorMinimizerMixin[AdaptiveVqeCreator],VqeCreatorReminimizerMixin[AdaptiveVqeCreator],VqeCreatorOptionsMixin[AdaptiveVqeCreator],VqeCreatorStoppingCriterionMixin[AdaptiveVqeCreator],VqeCreatorGateSelectorMixin[AdaptiveVqeCreator],VqeCreatorAnalyticalBeastVqeMixin[AdaptiveVqeCreator],VqeCreatorDataPersisterManagerMixin[AdaptiveVqeCreator]Builder for the adaptive VQE algorithm.
- __init__() None
Initialize builder for the adaptive VQE.
- Return type:
None
- choose_data_persister_manager() DataPersisterManagerSubCreator[Self]
Choose the data persister manager to use and whether to save and/or load the data.
- Return type:
- choose_minimizer() MinimizerSubCreator[Self]
Choose minimizer to use for the VQE.
- Return type:
MinimizerSubCreator[Self]
- choose_reminimizer() ReMinimizerSubCreator[Self]
Choose reminimizer to use for the VQE.
- Return type:
ReMinimizerSubCreator[Self]
- choose_stopping_criterion() StoppingCriterionSubCreator[Self]
Choose stopping criterion to use for the VQE.
- Return type:
- create() SecondQuantizationAdaptiveVqe
Create an instance of
SecondQuantizationAdaptiveVqe.- Return type:
- with_analytical_beast_basic_vqe(*, active: bool = True) Self
Choose to use the analytical basic vqe inside each adaptive iteration, which only works for BEAST.
Instead of having the minimizer call the estimator directly, the estimator is first called to make an analytical expression for the energy as a function of the gate parameter. This expression is then passed to the minimizer, requiring no more measurements.
Note: This feature only works with BEAST with last parameter optimization.
If a reminimizer is chosen, it will be paired with the normal Basic vqe since, only it, supports multiple parameters at once.
- Parameters:
active (bool) – Whether to use the analytical beast basic vqe or not.
- Return type:
Self
- with_estimator(estimator: Estimator) Self
Set the estimator to use for the VQE.
- Parameters:
estimator (Estimator) – Estimator to use. Can be created using the
estimator_creator()builder.- Return type:
Self
- with_estimator_shots(shots: int | None) Self
Set the number of shots to use in the estimator.
- Parameters:
shots (int | None) – Number of shots to use in the estimator. If None is given, the estimator is assumed to be exact
simulator). ((e.g. the excitation gate)
- Return type:
Self
- with_gate_selector(gate_selector: GateSelector) Self
Choose the gate selector to use for the VQE.
- Parameters:
gate_selector (GateSelector) – Gate selector to use. Can be created using the
gate_selector_creator().- Return type:
Self
- with_options(options: IterativeVqeOptions) Self
Set the options to use for the VQE.
- Parameters:
options (IterativeVqeOptions) – Options to use.
- Return type:
Self