qrunch.quantum.algorithms.second_quantization.vqes.creators

Protocols and concrete implementations for VQE creators.

Functions

chemistry_default_boson_estimator()

Create an ExcitationGateEstimator configured for BEAST-VQE (recommended default).

chemistry_default_boson_sampler()

Create an ExcitationGateSampler configured for BEAST-VQE (recommended default).

chemistry_default_fermion_estimator()

Create an ExcitationGateEstimator configured for FAST-VQE (recommended default).

chemistry_default_fermion_sampler()

Create an ExcitationGateSampler configured for FAST-VQE (recommended default).

fast_gate_selector_creator()

Create a FAST Gate selector creator, with chemistry defaults.

gate_selector_creator()

Start creating a Gate selector.

vqe_creator()

Create a VQE algorithm creator.

Classes

BeastSecondQuantizationAdaptiveOrbitalOptimizationVqeCreator

Builder for the adaptive VQE algorithm.

BeastSecondQuantizationAdaptiveVqeCreator

Builder for the adaptive VQE algorithm.

IterativeVqeCreator

creator for all types of VQE algorithms.

OrbitalOptimizedIterativeVqeCreator

creator for all types of VQE algorithms.

SecondQuantizationAdaptiveOrbitalOptimizationVqeCreator

Builder for the adaptive VQE algorithm.

SecondQuantizationAdaptiveVqeCreator

Builder for the adaptive VQE algorithm.

SecondQuantizationBasicVqeCreator

Builder for the basic VQE algorithm.

VqeCreator

creator for all types of VQE algorithms.

VqeCreatorAnalyticalBeastVqeMixin

Mixin to add estimator options to a creator that own a vqe_creator.

VqeCreatorDataPersisterManagerMixin

Mixin to add data persister manager options to a creator that own a vqe_creator.

VqeCreatorEstimatorMixin

Mixin to add estimator options to a creator that own a vqe_creator.

VqeCreatorFinalOrbitalOptimizerMixin

Mixin to add final_orbital_optimizer to a creator that own a vqe_creator.

VqeCreatorGateSelectorMixin

Mixin to add estimator options to a creator that own a vqe_creator.

VqeCreatorGateSelectorSamplerMixin

Mixin to add estimator options to a creator that own a vqe_creator.

VqeCreatorMinimizerMixin

Mixin to add minimizer options to a creator that own a vqe_creator.

VqeCreatorOptionsMixin

Mixin to add estimator options to a creator that own a vqe_creator.

VqeCreatorOrbitalOptimizationStoppingCriterionMixin

Mixin to add minimizer options to a creator that own a vqe_creator.

VqeCreatorOrbitalOptimizerMixin

Mixin to add orbital_optimizer to a creator that own a vqe_creator.

VqeCreatorReminimizerMixin

Mixin to add minimizer options to a creator that own a vqe_creator.

VqeCreatorStoppingCriterionMixin

Mixin to add minimizer options to a creator that own a vqe_creator.

VqeCreatorWithAnalyticalBeastVqeProtocol

VQE creator protocol that ensure gate selector interface.

VqeCreatorWithDataPersisterManagerProtocol

VQE creator protocol that ensure a readable/writable data_persister_manager slot.

VqeCreatorWithEstimatorProtocol

VQE creator protocol that ensure estimator interface.

VqeCreatorWithFinalOrbitalOptimizerProtocol

VQE creator protocol that ensure orbital optimizer interface.

VqeCreatorWithGateSelectorProtocol

VQE creator protocol that ensure gate selector interface.

VqeCreatorWithGateSelectorSamplerProtocol

VQE creator protocol that ensure gate selector interface.

VqeCreatorWithMinimizerProtocol

VQE creator protocol that ensure a readable/writable minimizer slot.

VqeCreatorWithOptionsProtocol

VQE creator protocol that ensure options interface.

VqeCreatorWithOrbitalOptimizationStoppingCriterionProtocol

VQE creator protocol that ensure a readable/writable stopping_criterion slot.

VqeCreatorWithOrbitalOptimizerProtocol

VQE creator protocol that ensure orbital optimizer interface.

VqeCreatorWithReminimizerProtocol

VQE creator protocol that ensure a readable/writable reminimizer slot.

VqeCreatorWithStoppingCriterionProtocol

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:
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:

DataPersisterManagerSubCreator[Self]

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:

StoppingCriterionSubCreator[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:

StoppingCriterionSubCreator[Self]

create() SecondQuantizationAdaptiveOrbitalOptimizationVqe

Create an instance of SecondQuantizationAdaptiveOrbitalOptimizationVqe.

Return type:

SecondQuantizationAdaptiveOrbitalOptimizationVqe

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() or with_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. None means 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:

DataPersisterManagerSubCreator[Self]

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:

StoppingCriterionSubCreator[Self]

create() SecondQuantizationAdaptiveVqe

Create an instance of SecondQuantizationAdaptiveVqe.

Return type:

SecondQuantizationAdaptiveVqe

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: object

creator for all types of VQE algorithms.

static beast() BeastSecondQuantizationAdaptiveVqeCreator

Narrow the VQE type to BEAST-VQE (without orbital optimization) with chemistry defaults.

Return type:

BeastSecondQuantizationAdaptiveVqeCreator

static paired_electron_approximation() SecondQuantizationAdaptiveVqeCreator

Narrow to paired electron approximation version (without orbital optimization).

Return type:

SecondQuantizationAdaptiveVqeCreator

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:

SecondQuantizationAdaptiveVqeCreator

class OrbitalOptimizedIterativeVqeCreator

Bases: object

creator 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.

Return type:

BeastSecondQuantizationAdaptiveOrbitalOptimizationVqeCreator

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.

Return type:

SecondQuantizationAdaptiveOrbitalOptimizationVqeCreator

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().

Return type:

SecondQuantizationAdaptiveOrbitalOptimizationVqeCreator

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:

DataPersisterManagerSubCreator[Self]

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:

StoppingCriterionSubCreator[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:

StoppingCriterionSubCreator[Self]

create() SecondQuantizationAdaptiveOrbitalOptimizationVqe

Create an instance of SecondQuantizationAdaptiveOrbitalOptimizationVqe.

Return type:

SecondQuantizationAdaptiveOrbitalOptimizationVqe

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() or with_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. None means 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:

DataPersisterManagerSubCreator[Self]

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:

StoppingCriterionSubCreator[Self]

create() SecondQuantizationAdaptiveVqe

Create an instance of SecondQuantizationAdaptiveVqe.

Return type:

SecondQuantizationAdaptiveVqe

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:

SecondQuantizationBasicVqe

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: object

creator 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:

SecondQuantizationBasicVqeCreator

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:

IterativeVqeCreator

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:

OrbitalOptimizedIterativeVqeCreator

class VqeCreatorAnalyticalBeastVqeMixin

Bases: Generic[VqeCreatorWithAnalyticalBeastVqeT], ABC

Mixin 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], ABC

Mixin 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:

DataPersisterManagerSubCreator[Self]

class VqeCreatorEstimatorMixin

Bases: Generic[VqeCreatorWithEstimatorT], ABC

Mixin 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], ABC

Mixin 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], ABC

Mixin 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], ABC

Mixin 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], ABC

Mixin 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], ABC

Mixin 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], ABC

Mixin 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:

StoppingCriterionSubCreator[Self]

class VqeCreatorOrbitalOptimizerMixin

Bases: Generic[VqeCreatorWithOrbitalOptimizerT], ABC

Mixin 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:

options (IntermittentOrbitalOptimizerAlgorithmOptions)

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], ABC

Mixin 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], ABC

Mixin 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:

StoppingCriterionSubCreator[Self]

class VqeCreatorWithAnalyticalBeastVqeProtocol

Bases: Protocol

VQE 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: Protocol

VQE creator protocol that ensure a readable/writable data_persister_manager slot.

__init__(*args, **kwargs)
class VqeCreatorWithEstimatorProtocol

Bases: Protocol

VQE 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: Protocol

VQE 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: Protocol

VQE 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: Protocol

VQE 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: Protocol

VQE creator protocol that ensure a readable/writable minimizer slot.

__init__(*args, **kwargs)
class VqeCreatorWithOptionsProtocol

Bases: Protocol

VQE 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: Protocol

VQE creator protocol that ensure a readable/writable stopping_criterion slot.

__init__(*args, **kwargs)
class VqeCreatorWithOrbitalOptimizerProtocol

Bases: Protocol

VQE 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:

options (IntermittentOrbitalOptimizerAlgorithmOptions)

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: Protocol

VQE creator protocol that ensure a readable/writable reminimizer slot.

__init__(*args, **kwargs)
class VqeCreatorWithStoppingCriterionProtocol

Bases: Protocol

VQE 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:

ExcitationGateEstimator

chemistry_default_boson_sampler() ExcitationGateSampler

Create an ExcitationGateSampler configured for BEAST-VQE (recommended default).

Return type:

ExcitationGateSampler

chemistry_default_fermion_estimator() ExcitationGateEstimator

Create an ExcitationGateEstimator configured for FAST-VQE (recommended default).

Return type:

ExcitationGateEstimator

chemistry_default_fermion_sampler() ExcitationGateSampler

Create an ExcitationGateSampler configured for FAST-VQE (recommended default).

Return type:

ExcitationGateSampler

fast_gate_selector_creator() FastGateSelectorCreator

Create a FAST Gate selector creator, with chemistry defaults. Configured for FAST-VQE (recommended default).

Return type:

FastGateSelectorCreator

gate_selector_creator() GateSelectorCreator

Start creating a Gate selector.

Return type:

GateSelectorCreator

vqe_creator() VqeCreator

Create a VQE algorithm creator.

Return type:

VqeCreator