qrunch.quantum.algorithms.second_quantization.vqes.creators
Protocols and concrete implementations for VQE creators.
Functions
Create an ExcitationGateEstimator configured for BEAST-VQE (recommended default). |
|
Create an ExcitationGateSampler configured for BEAST-VQE (recommended default). |
|
Create an ExcitationGateEstimator configured for FAST-VQE (recommended default). |
|
Create an ExcitationGateSampler configured for FAST-VQE (recommended default). |
|
Create a FAST Gate selector creator, with chemistry defaults. |
|
Start creating a Gate selector. |
|
Create a VQE algorithm creator. |
Classes
|
Builder for the adaptive VQE algorithm. |
Builder for the adaptive VQE algorithm. |
|
creator for all types of VQE algorithms. |
|
creator for all types of VQE algorithms. |
|
Builder for the adaptive VQE algorithm. |
|
Builder for the adaptive VQE algorithm. |
|
Builder for the basic VQE algorithm. |
|
creator for all types of VQE algorithms. |
|
Mixin to add estimator options to a creator that own a vqe_creator. |
|
Mixin to add data persister manager options to a creator that own a vqe_creator. |
|
Mixin to add estimator options to a creator that own a vqe_creator. |
|
Mixin to add final_orbital_optimizer to a creator that own a vqe_creator. |
|
Mixin to add estimator options to a creator that own a vqe_creator. |
|
Mixin to add estimator options to a creator that own a vqe_creator. |
|
Mixin to add minimizer options to a creator that own a vqe_creator. |
|
Mixin to add estimator options to a creator that own a vqe_creator. |
|
Mixin to add minimizer options to a creator that own a vqe_creator. |
|
Mixin to add orbital_optimizer to a creator that own a vqe_creator. |
|
Mixin to add minimizer options to a creator that own a vqe_creator. |
|
Mixin to add minimizer options to a creator that own a vqe_creator. |
|
VQE creator protocol that ensure gate selector interface. |
|
VQE creator protocol that ensure a readable/writable data_persister_manager slot. |
|
VQE creator protocol that ensure estimator interface. |
|
VQE creator protocol that ensure orbital optimizer interface. |
|
VQE creator protocol that ensure gate selector interface. |
|
VQE creator protocol that ensure gate selector interface. |
|
VQE creator protocol that ensure a readable/writable minimizer slot. |
|
VQE creator protocol that ensure options interface. |
|
VQE creator protocol that ensure a readable/writable stopping_criterion slot. |
|
VQE creator protocol that ensure orbital optimizer interface. |
|
VQE creator protocol that ensure a readable/writable reminimizer slot. |
|
VQE creator protocol that ensure a readable/writable stopping_criterion slot. |
- class BeastSecondQuantizationAdaptiveOrbitalOptimizationVqeCreator
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, intermittent_orbital_optimizer_factory: Callable[[Estimator, int | ShotsPerGroup | None], OrbitalOptimizerAlgorithm]) None
Initialize builder for the adaptive VQE.
- Parameters:
gate_selector_builder (FastGateSelectorCreator)
intermittent_orbital_optimizer_factory (Callable[[Estimator, int | ShotsPerGroup | None], OrbitalOptimizerAlgorithm])
- 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_orbital_optimizer_stopping_criterion() StoppingCriterionSubCreator[Self]
Choose an orbital rotation optimization stopping criterion.
Deprecated since version ``choose_orbital_optimizer_stopping_criterion``: is deprecated and will be removed in a future release. Use
with_intermittent_orbital_optimizer_options()instead.- Return type:
- 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() SecondQuantizationAdaptiveOrbitalOptimizationVqe
Create an instance of
SecondQuantizationAdaptiveOrbitalOptimizationVqe.- 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.
This is the number of shots that will be used in each call to the quantum computer or simulator, and not necessarily the total number of shots. The total number of shots will in many cases be much higher.
- 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_final_orbital_optimizer(final_orbital_optimizer: OrbitalOptimizerAlgorithm | None) Self
Provide an explicit final orbital optimizer instance.
- Parameters:
final_orbital_optimizer (OrbitalOptimizerAlgorithm | None) – The orbital optimizer to use for the final optimization step.
- 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_intermittent_orbital_optimizer_options(options: IntermittentOrbitalOptimizerAlgorithmOptions) Self
Configure options for the intermittent orbital optimizer.
- Parameters:
options (IntermittentOrbitalOptimizerAlgorithmOptions) – Options controlling when and how often the intermittent optimizer runs.
- 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
- with_orbital_optimizer(orbital_optimizer: OrbitalOptimizerAlgorithm | None) Self
Provide an explicit intermittent orbital optimizer instance.
- Parameters:
orbital_optimizer (OrbitalOptimizerAlgorithm | None) – The orbital optimizer to use during adaptive iterations.
- Return type:
Self
- with_orbital_optimizer_estimator(estimator: Estimator) Self
Replace the estimator used by the orbital optimizers.
When the creator was obtained from a factory method such as
OrbitalOptimizedIterativeVqeCreator.beast(), the intermittent and final orbital optimizers are built with chemistry-default estimators. This convenience method lets you swap the estimator while keeping all other orbital-optimizer settings (Newton options, basin-hopping options, etc.) unchanged.Note
If you have already called
with_orbital_optimizer()orwith_final_orbital_optimizer()with an explicit optimizer instance, those take precedence and this estimator will not be used for those optimizers.- Parameters:
estimator (Estimator) – The estimator to use inside the orbital optimizers.
- Return type:
Self
- with_orbital_optimizer_shots(shots: int | None) Self
Set the number of shots used by the orbital optimizers.
- Parameters:
shots (int | None) – Number of shots.
Nonemeans exact (statevector) evaluation.- Return type:
Self
- with_total_estimator_shots(shots: int | None) Self
Set the total number of shots to use for each estimator call.
The total number of shots are then distributed across the different groups in the estimator according to the shots per group strategy of the estimator. This ensures better use of the shot budget, and therefore, better use of the quantum resources.
- 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
- 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.
This is the number of shots that will be used in each call to the quantum computer or simulator, and not necessarily the total number of shots. The total number of shots will in many cases be much higher.
- 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
- with_total_estimator_shots(shots: int | None) Self
Set the total number of shots to use for each estimator call.
The total number of shots are then distributed across the different groups in the estimator according to the shots per group strategy of the estimator. This ensures better use of the shot budget, and therefore, better use of the quantum resources.
- 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
- class IterativeVqeCreator
Bases:
objectcreator for all types of VQE algorithms.
- static beast() BeastSecondQuantizationAdaptiveVqeCreator
Narrow the VQE type to BEAST-VQE (without orbital optimization) with chemistry defaults.
- Return type:
- static paired_electron_approximation() SecondQuantizationAdaptiveVqeCreator
Narrow to paired electron approximation version (without orbital optimization).
- Return type:
- static standard() SecondQuantizationAdaptiveVqeCreator
Narrow the VQE type to an adaptive VQE (defaults to FAST-VQE), with chemistry default settings.
An adaptive VQE is a VQE that grows the ansatz during the optimization, by selecting gates from a pool. The difference between FAST-VQE and other adaptive schemes, such as ADAPT-VQE (https://arxiv.org/pdf/1812.11173) is the gate selection strategy. FAST-VQE uses a heuristic strategy to select gates (either a heuristic gradient or heuristic selected CI), while ADAPT-VQE uses the exact gradient.
To use ADAPT-VQE instead of FAST-VQE, use the
with_gate_selector()method with a gate_selector created by following the adapt-path in the gate_selector_creator().- Return type:
- class OrbitalOptimizedIterativeVqeCreator
Bases:
objectcreator for all types of VQE algorithms.
- static beast() BeastSecondQuantizationAdaptiveOrbitalOptimizationVqeCreator
Narrow the VQE type to BEAST-VQE with orbital optimization with chemistry defaults.
BEAST-VQE is an iterative VQE (grows the ansatz during the optimization, by selecting gates from a pool), that is specific to bosonic encoding of paired electrons in molecular ground state energy problems.
In addition, the adaptive orbital optimization VQE also optimizes the molecular orbitals to find a better basis for the problem. This is particularly useful in the bosonic-encoding case, where the orbital optimization can significantly improve the accuracy of the results.
- static paired_electron_approximation() SecondQuantizationAdaptiveOrbitalOptimizationVqeCreator
Narrow to paired electron approximation version with orbital optimization.
It grows the ansatz during the optimization, by selecting gates from a pool, that is specific to bosonic encoding of paired electrons in molecular ground state energy problems. This enables a specialized gate set (only singles, corresponding to paired-excitations, are needed), and a highly simplified Hamiltonian whose expectation value can be measured only using three distinct measurement bases.
In addition, the adaptive orbital optimization VQE also optimizes the molecular orbitals to find a better basis for the problem. This is particularly useful in the bosonic-encoding case, where the orbital optimization can significantly improve the accuracy of the results.
- static standard() SecondQuantizationAdaptiveOrbitalOptimizationVqeCreator
Narrow the VQE type to an adaptive VQE (defaults to FAST-VQE), with chemistry default settings.
An adaptive VQE is a VQE that grows the ansatz during the optimization, by selecting gates from a pool. The difference between FAST-VQE and other adaptive schemes, such as ADAPT-VQE (https://arxiv.org/pdf/1812.11173) is the gate selection strategy. FAST-VQE uses a heuristic strategy to select gates (either a heuristic gradient or heuristic selected CI), while ADAPT-VQE uses the exact gradient.
To use ADAPT-VQE instead of FAST-VQE, use the
with_gate_selector()method with a gate_selector created by following the adapt-path in the gate_selector_creator().
- class SecondQuantizationAdaptiveOrbitalOptimizationVqeCreator
Bases:
VqeCreatorEstimatorMixin[AdaptiveVqeCreator],VqeCreatorMinimizerMixin[AdaptiveVqeCreator],VqeCreatorReminimizerMixin[AdaptiveVqeCreator],VqeCreatorOptionsMixin[AdaptiveVqeCreator],VqeCreatorStoppingCriterionMixin[AdaptiveVqeCreator],VqeCreatorGateSelectorMixin[AdaptiveVqeCreator],VqeCreatorAnalyticalBeastVqeMixin[AdaptiveVqeCreator],VqeCreatorDataPersisterManagerMixin[AdaptiveVqeCreator]Builder for the adaptive VQE algorithm.
- __init__(intermittent_orbital_optimizer_factory: Callable[[Estimator, int | ShotsPerGroup | None], OrbitalOptimizerAlgorithm]) None
Initialize builder for the adaptive VQE.
- Parameters:
intermittent_orbital_optimizer_factory (Callable[[Estimator, int | ShotsPerGroup | None], OrbitalOptimizerAlgorithm])
- 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_orbital_optimizer_stopping_criterion() StoppingCriterionSubCreator[Self]
Choose an orbital rotation optimization stopping criterion.
Deprecated since version ``choose_orbital_optimizer_stopping_criterion``: is deprecated and will be removed in a future release. Use
with_intermittent_orbital_optimizer_options()instead.- Return type:
- 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() SecondQuantizationAdaptiveOrbitalOptimizationVqe
Create an instance of
SecondQuantizationAdaptiveOrbitalOptimizationVqe.- 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.
This is the number of shots that will be used in each call to the quantum computer or simulator, and not necessarily the total number of shots. The total number of shots will in many cases be much higher.
- 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_final_orbital_optimizer(final_orbital_optimizer: OrbitalOptimizerAlgorithm | None) Self
Provide an explicit final orbital optimizer instance.
- Parameters:
final_orbital_optimizer (OrbitalOptimizerAlgorithm | None) – The orbital optimizer to use for the final optimization step.
- 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_intermittent_orbital_optimizer_options(options: IntermittentOrbitalOptimizerAlgorithmOptions) Self
Configure options for the intermittent orbital optimizer.
- Parameters:
options (IntermittentOrbitalOptimizerAlgorithmOptions) – Options controlling when and how often the intermittent optimizer runs.
- 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
- with_orbital_optimizer(orbital_optimizer: OrbitalOptimizerAlgorithm | None) Self
Provide an explicit intermittent orbital optimizer instance.
- Parameters:
orbital_optimizer (OrbitalOptimizerAlgorithm | None) – The orbital optimizer to use during adaptive iterations.
- Return type:
Self
- with_orbital_optimizer_estimator(estimator: Estimator) Self
Replace the estimator used by the orbital optimizers.
When the creator was obtained from a factory method such as
OrbitalOptimizedIterativeVqeCreator.beast(), the intermittent and final orbital optimizers are built with chemistry-default estimators. This convenience method lets you swap the estimator while keeping all other orbital-optimizer settings (Newton options, basin-hopping options, etc.) unchanged.Note
If you have already called
with_orbital_optimizer()orwith_final_orbital_optimizer()with an explicit optimizer instance, those take precedence and this estimator will not be used for those optimizers.- Parameters:
estimator (Estimator) – The estimator to use inside the orbital optimizers.
- Return type:
Self
- with_orbital_optimizer_shots(shots: int | None) Self
Set the number of shots used by the orbital optimizers.
- Parameters:
shots (int | None) – Number of shots.
Nonemeans exact (statevector) evaluation.- Return type:
Self
- with_total_estimator_shots(shots: int | None) Self
Set the total number of shots to use for each estimator call.
The total number of shots are then distributed across the different groups in the estimator according to the shots per group strategy of the estimator. This ensures better use of the shot budget, and therefore, better use of the quantum resources.
- 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
- 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.
This is the number of shots that will be used in each call to the quantum computer or simulator, and not necessarily the total number of shots. The total number of shots will in many cases be much higher.
- 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
- with_total_estimator_shots(shots: int | None) Self
Set the total number of shots to use for each estimator call.
The total number of shots are then distributed across the different groups in the estimator according to the shots per group strategy of the estimator. This ensures better use of the shot budget, and therefore, better use of the quantum resources.
- 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
- class SecondQuantizationBasicVqeCreator
Bases:
VqeCreatorEstimatorMixin[BasicVqeCreator],VqeCreatorMinimizerMixin[BasicVqeCreator]Builder for the basic VQE algorithm.
- __init__() None
Initialize builder for the basic VQE.
- Return type:
None
- choose_minimizer() MinimizerSubCreator[Self]
Choose minimizer to use for the VQE.
- Return type:
MinimizerSubCreator[Self]
- create() SecondQuantizationBasicVqe
Create an instance of
SecondQuantizationBasicVqe.- Return type:
- 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.
This is the number of shots that will be used in each call to the quantum computer or simulator, and not necessarily the total number of shots. The total number of shots will in many cases be much higher.
- 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_total_estimator_shots(shots: int | None) Self
Set the total number of shots to use for each estimator call.
The total number of shots are then distributed across the different groups in the estimator according to the shots per group strategy of the estimator. This ensures better use of the shot budget, and therefore, better use of the quantum resources.
- 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
- class VqeCreator
Bases:
objectcreator for all types of VQE algorithms.
- static fixed_ansatz() SecondQuantizationBasicVqeCreator
Narrow the VQE type to a basic VQE, with chemistry defaults.
A basic VQE is a VQE that does not grow the ansatz, but uses a fixed ansatz provided by the user.
- Return type:
- static iterative() IterativeVqeCreator
Narrow the VQE type to an iterative VQE (defaults to FAST-VQE), with chemistry default settings.
An adaptive VQE is a VQE that grows the ansatz during the optimization, by selecting gates from a pool. The difference between FAST-VQE and other adaptive schemes, such as ADAPT-VQE (https://arxiv.org/pdf/1812.11173) is the gate selection strategy. FAST-VQE uses a heuristic strategy to select gates (either a heuristic gradient or heuristic selected CI), while ADAPT-VQE uses the exact gradient.
To use ADAPT-VQE instead of FAST-VQE, use the
with_gate_selector()method with a gate_selector created by following the adapt-path in the gate_selector_creator().- Return type:
- static iterative_with_orbital_optimization() OrbitalOptimizedIterativeVqeCreator
Narrow to an iterative VQE with orbital optimization.
It defaults to OO-FAST-VQE, with chemistry default settings.
An adaptive VQE is a VQE that grows the ansatz during the optimization, by selecting gates from a pool. The difference between FAST-VQE and other adaptive schemes, such as ADAPT-VQE (https://arxiv.org/pdf/1812.11173) is the gate selection strategy. FAST-VQE uses a heuristic strategy to select gates (either a heuristic gradient or heuristic selected CI), while ADAPT-VQE uses the exact gradient.
To use ADAPT-VQE instead of FAST-VQE, use the
with_gate_selector()method with a gate_selector created by following the adapt-path in the gate_selector_creator().- Return type:
- class VqeCreatorAnalyticalBeastVqeMixin
Bases:
Generic[VqeCreatorWithAnalyticalBeastVqeT],ABCMixin to add estimator options to a creator that own a vqe_creator.
- 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
- class VqeCreatorDataPersisterManagerMixin
Bases:
Generic[VqeCreatorWithDataPersisterManagerT],ABCMixin to add data persister manager options to a creator that own a vqe_creator.
- choose_data_persister_manager() DataPersisterManagerSubCreator[Self]
Choose the data persister manager to use and whether to save and/or load the data.
- Return type:
- class VqeCreatorEstimatorMixin
Bases:
Generic[VqeCreatorWithEstimatorT],ABCMixin to add estimator options to a creator that own a vqe_creator.
- 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.
This is the number of shots that will be used in each call to the quantum computer or simulator, and not necessarily the total number of shots. The total number of shots will in many cases be much higher.
- 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_total_estimator_shots(shots: int | None) Self
Set the total number of shots to use for each estimator call.
The total number of shots are then distributed across the different groups in the estimator according to the shots per group strategy of the estimator. This ensures better use of the shot budget, and therefore, better use of the quantum resources.
- 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
- class VqeCreatorFinalOrbitalOptimizerMixin
Bases:
Generic[VqeCreatorWithFinalOrbitalOptimizerT],ABCMixin to add final_orbital_optimizer to a creator that own a vqe_creator.
- with_final_orbital_optimizer(final_orbital_optimizer: OrbitalOptimizerAlgorithm | None) Self
Configure the final orbital optimizer in adaptive orbital optimization VQE.
- Parameters:
final_orbital_optimizer (OrbitalOptimizerAlgorithm | None)
- Return type:
Self
- class VqeCreatorGateSelectorMixin
Bases:
Generic[VqeCreatorWithGateSelectorT],ABCMixin to add estimator options to a creator that own a vqe_creator.
- 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
- class VqeCreatorGateSelectorSamplerMixin
Bases:
Generic[VqeCreatorWithGateSelectorSamplerT],ABCMixin to add estimator options to a creator that own a vqe_creator.
- 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
- class VqeCreatorMinimizerMixin
Bases:
Generic[VqeCreatorWithMinimizerT],ABCMixin to add minimizer options to a creator that own a vqe_creator.
- choose_minimizer() MinimizerSubCreator[Self]
Choose minimizer to use for the VQE.
- Return type:
MinimizerSubCreator[Self]
- class VqeCreatorOptionsMixin
Bases:
Generic[VqeCreatorWithOptionsT],ABCMixin to add estimator options to a creator that own a vqe_creator.
- with_options(options: IterativeVqeOptions) Self
Set the options to use for the VQE.
- Parameters:
options (IterativeVqeOptions) – Options to use.
- Return type:
Self
- class VqeCreatorOrbitalOptimizationStoppingCriterionMixin
Bases:
Generic[VqeCreatorWithOrbitalOptimizationStoppingCriterionT],ABCMixin to add minimizer options to a creator that own a vqe_creator.
- choose_orbital_optimizer_stopping_criterion() StoppingCriterionSubCreator[Self]
Choose an orbital rotation optimization stopping criterion.
Deprecated since version ``choose_orbital_optimizer_stopping_criterion``: is deprecated and will be removed in a future release. Use
with_intermittent_orbital_optimizer_options()instead.- Return type:
- class VqeCreatorOrbitalOptimizerMixin
Bases:
Generic[VqeCreatorWithOrbitalOptimizerT],ABCMixin to add orbital_optimizer to a creator that own a vqe_creator.
- with_intermittent_orbital_optimizer_options(options: IntermittentOrbitalOptimizerAlgorithmOptions) Self
Configure options for the intermittent orbital optimizer.
- Parameters:
- Return type:
Self
- with_orbital_optimizer(orbital_optimizer: OrbitalOptimizerAlgorithm) Self
Configure the intermittent orbital optimizer in adaptive orbital optimization VQE.
- Parameters:
orbital_optimizer (OrbitalOptimizerAlgorithm)
- Return type:
Self
- with_orbital_optimizer_estimator(estimator: Estimator) Self
Configure the estimator of the intermittent orbital optimizer in adaptive orbital optimization VQE.
- Parameters:
estimator (Estimator)
- Return type:
Self
- with_orbital_optimizer_shots(shots: int | None) Self
Configure the estimator shots of the intermittent orbital optimizer in adaptive orbital optimization VQE.
- Parameters:
shots (int | None)
- Return type:
Self
- class VqeCreatorReminimizerMixin
Bases:
Generic[VqeCreatorWithReminimizerT],ABCMixin to add minimizer options to a creator that own a vqe_creator.
- choose_reminimizer() ReMinimizerSubCreator[Self]
Choose reminimizer to use for the VQE.
- Return type:
ReMinimizerSubCreator[Self]
- class VqeCreatorStoppingCriterionMixin
Bases:
Generic[VqeCreatorWithStoppingCriterionT],ABCMixin to add minimizer options to a creator that own a vqe_creator.
- choose_stopping_criterion() StoppingCriterionSubCreator[Self]
Choose stopping criterion to use for the VQE.
- Return type:
- class VqeCreatorWithAnalyticalBeastVqeProtocol
Bases:
ProtocolVQE creator protocol that ensure gate selector interface.
- __init__(*args, **kwargs)
- 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
- class VqeCreatorWithDataPersisterManagerProtocol
Bases:
ProtocolVQE creator protocol that ensure a readable/writable data_persister_manager slot.
- __init__(*args, **kwargs)
- class VqeCreatorWithEstimatorProtocol
Bases:
ProtocolVQE creator protocol that ensure estimator interface.
- __init__(*args, **kwargs)
- with_estimator(estimator: Estimator) Self
Set estimator on the VQE creator.
- Parameters:
estimator (Estimator)
- Return type:
Self
- with_estimator_shots(shots: int | None) Self
Set the number of shots to use in the estimator.
- Parameters:
shots (int | None)
- Return type:
Self
- with_total_estimator_shots(shots: int | None) Self
Set the total number of shots to use in the estimator.
- Parameters:
shots (int | None)
- Return type:
Self
- class VqeCreatorWithFinalOrbitalOptimizerProtocol
Bases:
ProtocolVQE creator protocol that ensure orbital optimizer interface.
- __init__(*args, **kwargs)
- with_final_orbital_optimizer(final_orbital_optimizer: OrbitalOptimizerAlgorithm | None) Self
Set the final orbital optimizer to use for the VQE creator.
- Parameters:
final_orbital_optimizer (OrbitalOptimizerAlgorithm | None)
- Return type:
Self
- class VqeCreatorWithGateSelectorProtocol
Bases:
ProtocolVQE creator protocol that ensure gate selector interface.
- __init__(*args, **kwargs)
- with_gate_selector(gate_selector: GateSelector) Self
Set the gate selector to use for the VQE creator.
- Parameters:
gate_selector (GateSelector)
- Return type:
Self
- class VqeCreatorWithGateSelectorSamplerProtocol
Bases:
ProtocolVQE creator protocol that ensure gate selector interface.
- __init__(*args, **kwargs)
- 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
- class VqeCreatorWithMinimizerProtocol
Bases:
ProtocolVQE creator protocol that ensure a readable/writable minimizer slot.
- __init__(*args, **kwargs)
- class VqeCreatorWithOptionsProtocol
Bases:
ProtocolVQE creator protocol that ensure options interface.
- __init__(*args, **kwargs)
- with_options(options: IterativeVqeOptions) Self
Options on the VQE creator.
- Parameters:
options (IterativeVqeOptions)
- Return type:
Self
- class VqeCreatorWithOrbitalOptimizationStoppingCriterionProtocol
Bases:
ProtocolVQE creator protocol that ensure a readable/writable stopping_criterion slot.
- __init__(*args, **kwargs)
- class VqeCreatorWithOrbitalOptimizerProtocol
Bases:
ProtocolVQE creator protocol that ensure orbital optimizer interface.
- __init__(*args, **kwargs)
- with_intermittent_orbital_optimizer_options(options: IntermittentOrbitalOptimizerAlgorithmOptions) Self
Configure options for the intermittent orbital optimizer.
- Parameters:
- Return type:
Self
- with_orbital_optimizer(orbital_optimizer: OrbitalOptimizerAlgorithm | None) Self
Set the intermittent orbital optimizer to use for the VQE creator.
- Parameters:
orbital_optimizer (OrbitalOptimizerAlgorithm | None)
- Return type:
Self
- with_orbital_optimizer_estimator(estimator: Estimator) Self
Configure the estimator for the intermittent orbital optimizer.
- Parameters:
estimator (Estimator)
- Return type:
Self
- with_orbital_optimizer_shots(shots: int | None) Self
Set the number of shots used by the orbital optimizers.
- Parameters:
shots (int | None)
- Return type:
Self
- class VqeCreatorWithReminimizerProtocol
Bases:
ProtocolVQE creator protocol that ensure a readable/writable reminimizer slot.
- __init__(*args, **kwargs)
- class VqeCreatorWithStoppingCriterionProtocol
Bases:
ProtocolVQE creator protocol that ensure a readable/writable stopping_criterion slot.
- __init__(*args, **kwargs)
- chemistry_default_boson_estimator() ExcitationGateEstimator
Create an ExcitationGateEstimator configured for BEAST-VQE (recommended default).
- Return type:
- chemistry_default_boson_sampler() ExcitationGateSampler
Create an ExcitationGateSampler configured for BEAST-VQE (recommended default).
- Return type:
- chemistry_default_fermion_estimator() ExcitationGateEstimator
Create an ExcitationGateEstimator configured for FAST-VQE (recommended default).
- Return type:
- chemistry_default_fermion_sampler() ExcitationGateSampler
Create an ExcitationGateSampler configured for FAST-VQE (recommended default).
- Return type:
- fast_gate_selector_creator() FastGateSelectorCreator
Create a FAST Gate selector creator, with chemistry defaults. Configured for FAST-VQE (recommended default).
- Return type:
- gate_selector_creator() GateSelectorCreator
Start creating a Gate selector.
- Return type:
- vqe_creator() VqeCreator
Create a VQE algorithm creator.
- Return type: