This repository was archived by the owner on Dec 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 376
Excited States algorithms and support for Chemistry #1354
Merged
woodsp-ibm
merged 226 commits into
qiskit-community:master
from
pbark:excited_states_interface
Oct 16, 2020
Merged
Excited States algorithms and support for Chemistry #1354
woodsp-ibm
merged 226 commits into
qiskit-community:master
from
pbark:excited_states_interface
Oct 16, 2020
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fetch qiskit master
This properly implements the AdaptVQEGroundStateCalculation class. The idea of this class is to allow easy use of the VQEAdapt algorithm which was previously extended to support the MinimumEigensolver interface. This Calculation class is solely for the use with this algorithm which is why it does not support setting a different solver. Instead, it requires setting a QuantumInstance object through its initializer. The changes which this requires include the following: - fixing the GroundStateCalculation class - fixing the MinEigensolverGroundStateCalculation class Furthermore, a very basic unittest for this change was added.
…ult working with mineigensolver result
This reverts commit 362843b.
There is no release note for this. Is the intent that the Bosonic release note would cover what is here? |
mrossinek
reviewed
Oct 15, 2020
woodsp-ibm
previously approved these changes
Oct 15, 2020
Since we opted to make the default filter criterion of the fermionic case filter non-singlet states this kind of misses the point in the excirted states cases. Thus we now provide a custom filter in the test. For the backlog we should consider a better implementation of the default filter which can handle this automatically.
pbark
previously approved these changes
Oct 15, 2020
stefan-woerner
approved these changes
Oct 15, 2020
pbark
approved these changes
Oct 15, 2020
woodsp-ibm
approved these changes
Oct 16, 2020
mtreinish
pushed a commit
to mtreinish/qiskit-core
that referenced
this pull request
Nov 20, 2020
…/qiskit-aqua#1354) * ground state min eigensolver interface * fix small things style * added the molecule object with the right properties * minor fix molecule * excited state calculation added * EOMvqe added * ground state interface minimum eigensolver * Add MinimumEigensolver interface to VQEAdapt * Implement the AdaptVQEGroundStateCalculation class This properly implements the AdaptVQEGroundStateCalculation class. The idea of this class is to allow easy use of the VQEAdapt algorithm which was previously extended to support the MinimumEigensolver interface. This Calculation class is solely for the use with this algorithm which is why it does not support setting a different solver. Instead, it requires setting a QuantumInstance object through its initializer. The changes which this requires include the following: - fixing the GroundStateCalculation class - fixing the MinEigensolverGroundStateCalculation class Furthermore, a very basic unittest for this change was added. * comments * initial bopes sampler * naming * compute eigenvalue MinEigensolver works * return raw results until I make the GroundStateResult * now the fermionic transformation returns a molecular ground state result working with mineigensolver result * added TODOs * rename GSC files * add init to qubit_transformations * fix lint in bosonic_trafo and qubit_op_trafo * update (MES)GSC to new structure * rm empty orbital optimization file * Fix init * Implement returns_groundstate and fix some lints * Rewrite AdaptVQEGSCalc. deriving from MESGSCalc. * Add TODO about deprecating qiskit.chemistry.algorithms module * Revert "Add MinimumEigensolver interface to VQEAdapt" This reverts commit 362843b19ff199e1b824b4318b14eee1d5c3da66. * Properly deprecate VQEAdapt * Port VQEAdapt to AdaptVQE (based on a GroundStateCalculation) This properly refactors the old qiskit.chemistry.algorithms.minimum_eigen_solver.VQEAdapt into the new qiskit.chemistry.ground_state_calculation.AdaptVQE class which implements the new GroundStateCalculation interface. The name change is intentional because the new name is in-line with the literature on AdaptVQE. The old name was presumably intentional to highlight its relation to VQE. The unittests for VQEAdapt are ported accordingly. * Some minor corrections/updates * Rename AdaptVQE files * Add optional custom_excitation_pool argument to AdaptVQE computation method * Work on FermionicTransformation and related objs - add interpet method to QubitOperatorTransformation and FermionicTransformation - remove deprecated method `_process_..._deprecated` - deprecate Hamiltonian and ChemistryOperator * documentation added * fixes in ground state * patch MES result to GSC result instead of returning a tuple * files fixes for GSC interface * rm utf8 headers * fix spell, lint, mypy * Remove `custom_excitation_pool` from AdaptVQE `compute_ground_state` function Rather than ignoring the arguments given by the interface, we can remove this additional argument in favor of enabling the user to set this custom excitation pool through the `MESFactory`. An example on how to achieve such a thing can be seen in the corresponding unittest. * fix mypy * fix lint * Re-enable DeprecationWarnings after VQEAdapt has been initialized * Fixes several minor nit-picks - copyright years - faulty renames - faulty merge side-effects - missing setters * make MESFactory an interface only * fix copyright years * derive from MESFactory and update docs * update docstrings and add molecule_info * consistent naming in ``ground(_)state`` * fix spell * more spell, deprecate MGSE * fix deprecation * more style * test fixes * fixes * [WIP] basic Result-interfaces This adds the following interfaces: - qiskit.chemistry.ChemistryResult(AlgorithmResult) - qiskit.chemistry.ground_state_calculation.GroundStateResult(ChemistryResult) - qiskit.chemistry.ground_state_calculation.FermionicGroundStateResult(GroundStateResult) The logic is as follows: ChemistryResult and GroundStateResult are empty interfaces which define a hierarchy for the result classes. They provide a useful granularity for type checking. Once more subclasses are added we can extract common functionality up into the stack as needed. The FermionicGroundStateResult currently is just a port of the old MolecularChemistryResult and MolecularGroundStateResult. Both of these classes are deprecated in this commit. Since this class is currently specific to the GroundStateCalculation it is part of that module. This is, however, subject to change. * Remove BosonicTransformation from this PR The BosonicTransformation will be added in a separate PR aiming to refactor the respective modules. * AdaptVQE actually supports aux_operators * [wip] resolve cyclic import problems Having a `Result` class in either the `ground_state_calculations` or `qubit_operator_transformations` modules leads to a coupling of the two modules that is too tight. I.e. we run into cyclic imports whenever we try to run any code because the `QubitOpTransformation` class needs to load the `Result` class while at the same time it needs to be available in the `GroundStateCalculation` class. Thus, when an additional coupling in between these two modules is created, we have cyclic import. Thus, we drop one level of granularity and only provide a single result-interface on the `qiskit.chemistry` level, here, called `ChemistryResult` (open for discussion). I also moved the `DipoleTuple` to this level to simplify its usage in the other classes. * Make AdaptVQE use the FermionicGSResult * Use FermionicGroundStateResult in MinimumEigensolverGroundStateCalculation * Fix mypy * Filter DeprecationWarnings in unittests This filters all of the DeprecationWarnigns introduced in this PR. In 3 months from now we can remove these tests once the corresponding code is also removed. This commit also adds TODO labels to all of these unittest files which will have to be migrated to work within the new framework. * Add TODO in AdaptVQE unittest * Add missing unittest imports I noticed that in some test files the unittest module is not imported and the `__main__` is not set accordingly. If we do not want to mix these changes into this PR, we can simply revert this commit. * mypy fix * unused code * Create qiskit.chemistry.results module * Replace interpret() with add_context() in QubitOperatorTransformations Instead of an interpret() function, the QubitOperatorTransformation interface defines an add_context() function which is used to augment the given StateResult object with information based on the transformation's context. * Fix GroundStateCalculation classes to work with the results interface * Revert faulty change in github workflow * unitests WIP first commit * remove deprecation suppressing from new tests * support additional aux ops and conv to dict * fix aux_ops=None * lint, style * more test * fixes in test * fix style * fix mypy * fix mypy * fixes in fermionic trafo * remove editor created redundant file * resolved tests * docstring fix * fix error & specify type hint * change typehint Any -> FermionicOp * add missing imports * spell * suggestions from code review * consistent use in .keys() * type hints, minor improvements * Rethink the qiskit.chemistry.results After some discussion we decided to rethink parts of the qiskit.chemistry.results interfaces. We want to minimize the differentiation between grround and excited states and let only the concrete `QubitOperatorTransformation` handle the fermionic and bosonic differentiation. Thus, I apply the following changes: * provide a single `EigenstateResult` which can be either a ground or excited state * derive `ElectronicStructureResult` (prev. `FermionicResult`) from this * use the `FermionicTransformation.interpret()` method to map a general `EigenstateResult` to the type specific for the transformation With the last change we also align the `qiskit.chemistry` module further with the `qiskit.optimization` module where we also use `interpret()` rather than `add_context()` methods (which was the name we intended to use prior to this commit). * Remove unneeded DeprecationWarning from AdaptVQEResult * Update some docstrings * fix lint * revert back to lists of aux_ops * Update qiskit/chemistry/ground_state_calculation/adapt_vqe.py Co-authored-by: Max Rossmannek <[email protected]> * apply suggestions from code review * change typehint to List[float] * Update qiskit/chemistry/core/hamiltonian.py Co-authored-by: Steve Wood <[email protected]> * test fixes after code review * excited state interface for matching the ground state interface and handling both electronic and vibrational states * Rename aux_values to aux_operator_eigenvalues This naming is consistent with the EigensolverResult and MinimumEigensolverResult classes. * Remove leftover from dict-style aux_operators * Add an `evaluate_operators` method to the GroundStateCalculation This method can be used to evaluate any additional auxiliary operators after the GSC has finished. This will be necessary especially in the excited state calculations and is in general a nice option for the user to have. The method is similar to how the `VQE` evaluates auxiliary operators internally. However, it can also deal with `MinimumEigensolver`s which do not use a `QuantumInstance`. A curiousity arose because the `VQE` appears to wrap the auxiliary operator results into lists multiple times. In order to ensure interoperability the same is done here. The `AdaptVQE` now derives off of the `MinimumEigensolverGSC` because there was no obvious drawback to this and the benefit of reusing this new method was welcome. Unittests have been added to test the new functionality. * fix lint * Remove erronous TODO * Enforce a FermionicTransformation in the VQEUCCSDFactory * Do not enforce VQEUCCSDFactory type in AdaptVQE Since we check for the VQE and UCCSD types anyways we shouldn't force the user to subclass this factory. * Reuse the VQE object during AdaptVQE * Expose molecule_info and qubit_mapping publicly * fix lint * fixes in tests * fixes in tests and revert to molecule_methods * remove two duplicate tests * Expose some VQE arguments in the VQEUCCSDFactory As discussed, we now expose some of the VQE arguments through this factory in order to allow greater flexibility for the user. * test commit * fix spell * fix bugs qeom code and first version of test for numerical qeom * added the build_hopping_operator capability in the transformation * modified results to take excited states components * reverted due to missing part of the test uccsd_HF * remove test EOM todos * lint * more lint * more lint * Prepare EigenstateResult to handle ground and excited states * Deprecate the Enums in the chemistry.core module * Also populate eigenstates in ground state calculations * Add factory for NumPyMinimumEigensolver * Implement `_filter_criterion` in FermionicTransformation * Extract default filter_criterion into interface Rather than checking for a private method being implemented we can obtain the default filter_criterion cleanly. This makes sense because any transformation in theory could implement a default filter. However, we return None in case it is not implemented. * fixing qeom code * Make use of default filter criterion configurable * Check state's type before making at a StateFn * Use `supports_aux_ops` in `returns_groundstate` * Replace Any type-hint where not really necessary The reason for making it a union of lists rather than a list of a union is to ensure that no mixed lists are allowed. * Do not use legacy Operator in new interface The WeightedPauliOp is a legacy operator and should not be used in this new interface. Instead, we now convert the operators to the OperatorFlow before returning them to ensure we only use the new operator types. * fix the eigenstate_result and electronic_structure_result to work with excited states and test eom with Numpy eigensolver for the ground state * clean qeom code * tests for numerical qeom * change of the ExcitedStatesCalculation init so that it does not have a GSC * Except (Minimum)EigensolverResults in interpret() To provide more user-flexibility and better compatibility with the Aqua result classes, the interpret() method is able to handle (Minimum)EigensolverResult classes as well as the EigenstateResult. * Fix tests to work with OperatorBase rather than WeightedPauliOperator * fix es_factory and additional information in FermionicTransformation for Analytical qEOM * rm WPO support in trafo, add test for aux_ops * Fix docstring * Fix aux_op particle-hole conversion * Extend ElectronicStructureResult to work with excited state calculations Since an electronic structure can consist of multiple states and during excited state calculations we obtain energies and auxiliary operator evaluations for each investigated state we expose all finally interpreted result properties as Lists where the first entry should always reflect the ground state properties. * fix auxiliary operators * reformatting of electronic structure results print * fix linting * fix mypy * Restructure excited states code - moving modules - renaming classes - adapting tests * more mypy fixes * final mypy fixes * add use_default_filter_criterion argument to NumPyEigensolverFactory * fix tests * fix lint and spell * fix lint * fix unittests * fix test * Fix typos in reno * added a release note * Do not use the default_filter_criterion for excited states Since we opted to make the default filter criterion of the fermionic case filter non-singlet states this kind of misses the point in the excirted states cases. Thus we now provide a custom filter in the test. For the backlog we should consider a better implementation of the default filter which can handle this automatically. * Fix test * Do not append line to README * Fix some docstrings and copyright years * Fix test * Use aqua_globals.random_seed in bopes test * Fix lint Co-authored-by: Panagiotis Barkoutsos <[email protected]> Co-authored-by: Panagiotis Barkoutsos <[email protected]> Co-authored-by: Max Rossmannek <[email protected]> Co-authored-by: Stefan Woerner <[email protected]> Co-authored-by: Cryoris <[email protected]> Co-authored-by: Julien Gacon <[email protected]> Co-authored-by: Manoel Marques <[email protected]> Co-authored-by: Anton Dekusar <[email protected]> Co-authored-by: Anton Dekusar <[email protected]> Co-authored-by: Max Rossmannek <[email protected]> Co-authored-by: Steve Wood <[email protected]> Co-authored-by: Mario Motta <[email protected]> Co-authored-by: Stefan Woerner <[email protected]>
manoelmarques
added a commit
to manoelmarques/qiskit-terra
that referenced
this pull request
Dec 2, 2020
…/qiskit-aqua#1354) * ground state min eigensolver interface * fix small things style * added the molecule object with the right properties * minor fix molecule * excited state calculation added * EOMvqe added * ground state interface minimum eigensolver * Add MinimumEigensolver interface to VQEAdapt * Implement the AdaptVQEGroundStateCalculation class This properly implements the AdaptVQEGroundStateCalculation class. The idea of this class is to allow easy use of the VQEAdapt algorithm which was previously extended to support the MinimumEigensolver interface. This Calculation class is solely for the use with this algorithm which is why it does not support setting a different solver. Instead, it requires setting a QuantumInstance object through its initializer. The changes which this requires include the following: - fixing the GroundStateCalculation class - fixing the MinEigensolverGroundStateCalculation class Furthermore, a very basic unittest for this change was added. * comments * initial bopes sampler * naming * compute eigenvalue MinEigensolver works * return raw results until I make the GroundStateResult * now the fermionic transformation returns a molecular ground state result working with mineigensolver result * added TODOs * rename GSC files * add init to qubit_transformations * fix lint in bosonic_trafo and qubit_op_trafo * update (MES)GSC to new structure * rm empty orbital optimization file * Fix init * Implement returns_groundstate and fix some lints * Rewrite AdaptVQEGSCalc. deriving from MESGSCalc. * Add TODO about deprecating qiskit.chemistry.algorithms module * Revert "Add MinimumEigensolver interface to VQEAdapt" This reverts commit 362843b19ff199e1b824b4318b14eee1d5c3da66. * Properly deprecate VQEAdapt * Port VQEAdapt to AdaptVQE (based on a GroundStateCalculation) This properly refactors the old qiskit.chemistry.algorithms.minimum_eigen_solver.VQEAdapt into the new qiskit.chemistry.ground_state_calculation.AdaptVQE class which implements the new GroundStateCalculation interface. The name change is intentional because the new name is in-line with the literature on AdaptVQE. The old name was presumably intentional to highlight its relation to VQE. The unittests for VQEAdapt are ported accordingly. * Some minor corrections/updates * Rename AdaptVQE files * Add optional custom_excitation_pool argument to AdaptVQE computation method * Work on FermionicTransformation and related objs - add interpet method to QubitOperatorTransformation and FermionicTransformation - remove deprecated method `_process_..._deprecated` - deprecate Hamiltonian and ChemistryOperator * documentation added * fixes in ground state * patch MES result to GSC result instead of returning a tuple * files fixes for GSC interface * rm utf8 headers * fix spell, lint, mypy * Remove `custom_excitation_pool` from AdaptVQE `compute_ground_state` function Rather than ignoring the arguments given by the interface, we can remove this additional argument in favor of enabling the user to set this custom excitation pool through the `MESFactory`. An example on how to achieve such a thing can be seen in the corresponding unittest. * fix mypy * fix lint * Re-enable DeprecationWarnings after VQEAdapt has been initialized * Fixes several minor nit-picks - copyright years - faulty renames - faulty merge side-effects - missing setters * make MESFactory an interface only * fix copyright years * derive from MESFactory and update docs * update docstrings and add molecule_info * consistent naming in ``ground(_)state`` * fix spell * more spell, deprecate MGSE * fix deprecation * more style * test fixes * fixes * [WIP] basic Result-interfaces This adds the following interfaces: - qiskit.chemistry.ChemistryResult(AlgorithmResult) - qiskit.chemistry.ground_state_calculation.GroundStateResult(ChemistryResult) - qiskit.chemistry.ground_state_calculation.FermionicGroundStateResult(GroundStateResult) The logic is as follows: ChemistryResult and GroundStateResult are empty interfaces which define a hierarchy for the result classes. They provide a useful granularity for type checking. Once more subclasses are added we can extract common functionality up into the stack as needed. The FermionicGroundStateResult currently is just a port of the old MolecularChemistryResult and MolecularGroundStateResult. Both of these classes are deprecated in this commit. Since this class is currently specific to the GroundStateCalculation it is part of that module. This is, however, subject to change. * Remove BosonicTransformation from this PR The BosonicTransformation will be added in a separate PR aiming to refactor the respective modules. * AdaptVQE actually supports aux_operators * [wip] resolve cyclic import problems Having a `Result` class in either the `ground_state_calculations` or `qubit_operator_transformations` modules leads to a coupling of the two modules that is too tight. I.e. we run into cyclic imports whenever we try to run any code because the `QubitOpTransformation` class needs to load the `Result` class while at the same time it needs to be available in the `GroundStateCalculation` class. Thus, when an additional coupling in between these two modules is created, we have cyclic import. Thus, we drop one level of granularity and only provide a single result-interface on the `qiskit.chemistry` level, here, called `ChemistryResult` (open for discussion). I also moved the `DipoleTuple` to this level to simplify its usage in the other classes. * Make AdaptVQE use the FermionicGSResult * Use FermionicGroundStateResult in MinimumEigensolverGroundStateCalculation * Fix mypy * Filter DeprecationWarnings in unittests This filters all of the DeprecationWarnigns introduced in this PR. In 3 months from now we can remove these tests once the corresponding code is also removed. This commit also adds TODO labels to all of these unittest files which will have to be migrated to work within the new framework. * Add TODO in AdaptVQE unittest * Add missing unittest imports I noticed that in some test files the unittest module is not imported and the `__main__` is not set accordingly. If we do not want to mix these changes into this PR, we can simply revert this commit. * mypy fix * unused code * Create qiskit.chemistry.results module * Replace interpret() with add_context() in QubitOperatorTransformations Instead of an interpret() function, the QubitOperatorTransformation interface defines an add_context() function which is used to augment the given StateResult object with information based on the transformation's context. * Fix GroundStateCalculation classes to work with the results interface * Revert faulty change in github workflow * unitests WIP first commit * remove deprecation suppressing from new tests * support additional aux ops and conv to dict * fix aux_ops=None * lint, style * more test * fixes in test * fix style * fix mypy * fix mypy * fixes in fermionic trafo * remove editor created redundant file * resolved tests * docstring fix * fix error & specify type hint * change typehint Any -> FermionicOp * add missing imports * spell * suggestions from code review * consistent use in .keys() * type hints, minor improvements * Rethink the qiskit.chemistry.results After some discussion we decided to rethink parts of the qiskit.chemistry.results interfaces. We want to minimize the differentiation between grround and excited states and let only the concrete `QubitOperatorTransformation` handle the fermionic and bosonic differentiation. Thus, I apply the following changes: * provide a single `EigenstateResult` which can be either a ground or excited state * derive `ElectronicStructureResult` (prev. `FermionicResult`) from this * use the `FermionicTransformation.interpret()` method to map a general `EigenstateResult` to the type specific for the transformation With the last change we also align the `qiskit.chemistry` module further with the `qiskit.optimization` module where we also use `interpret()` rather than `add_context()` methods (which was the name we intended to use prior to this commit). * Remove unneeded DeprecationWarning from AdaptVQEResult * Update some docstrings * fix lint * revert back to lists of aux_ops * Update qiskit/chemistry/ground_state_calculation/adapt_vqe.py Co-authored-by: Max Rossmannek <[email protected]> * apply suggestions from code review * change typehint to List[float] * Update qiskit/chemistry/core/hamiltonian.py Co-authored-by: Steve Wood <[email protected]> * test fixes after code review * excited state interface for matching the ground state interface and handling both electronic and vibrational states * Rename aux_values to aux_operator_eigenvalues This naming is consistent with the EigensolverResult and MinimumEigensolverResult classes. * Remove leftover from dict-style aux_operators * Add an `evaluate_operators` method to the GroundStateCalculation This method can be used to evaluate any additional auxiliary operators after the GSC has finished. This will be necessary especially in the excited state calculations and is in general a nice option for the user to have. The method is similar to how the `VQE` evaluates auxiliary operators internally. However, it can also deal with `MinimumEigensolver`s which do not use a `QuantumInstance`. A curiousity arose because the `VQE` appears to wrap the auxiliary operator results into lists multiple times. In order to ensure interoperability the same is done here. The `AdaptVQE` now derives off of the `MinimumEigensolverGSC` because there was no obvious drawback to this and the benefit of reusing this new method was welcome. Unittests have been added to test the new functionality. * fix lint * Remove erronous TODO * Enforce a FermionicTransformation in the VQEUCCSDFactory * Do not enforce VQEUCCSDFactory type in AdaptVQE Since we check for the VQE and UCCSD types anyways we shouldn't force the user to subclass this factory. * Reuse the VQE object during AdaptVQE * Expose molecule_info and qubit_mapping publicly * fix lint * fixes in tests * fixes in tests and revert to molecule_methods * remove two duplicate tests * Expose some VQE arguments in the VQEUCCSDFactory As discussed, we now expose some of the VQE arguments through this factory in order to allow greater flexibility for the user. * test commit * fix spell * fix bugs qeom code and first version of test for numerical qeom * added the build_hopping_operator capability in the transformation * modified results to take excited states components * reverted due to missing part of the test uccsd_HF * remove test EOM todos * lint * more lint * more lint * Prepare EigenstateResult to handle ground and excited states * Deprecate the Enums in the chemistry.core module * Also populate eigenstates in ground state calculations * Add factory for NumPyMinimumEigensolver * Implement `_filter_criterion` in FermionicTransformation * Extract default filter_criterion into interface Rather than checking for a private method being implemented we can obtain the default filter_criterion cleanly. This makes sense because any transformation in theory could implement a default filter. However, we return None in case it is not implemented. * fixing qeom code * Make use of default filter criterion configurable * Check state's type before making at a StateFn * Use `supports_aux_ops` in `returns_groundstate` * Replace Any type-hint where not really necessary The reason for making it a union of lists rather than a list of a union is to ensure that no mixed lists are allowed. * Do not use legacy Operator in new interface The WeightedPauliOp is a legacy operator and should not be used in this new interface. Instead, we now convert the operators to the OperatorFlow before returning them to ensure we only use the new operator types. * fix the eigenstate_result and electronic_structure_result to work with excited states and test eom with Numpy eigensolver for the ground state * clean qeom code * tests for numerical qeom * change of the ExcitedStatesCalculation init so that it does not have a GSC * Except (Minimum)EigensolverResults in interpret() To provide more user-flexibility and better compatibility with the Aqua result classes, the interpret() method is able to handle (Minimum)EigensolverResult classes as well as the EigenstateResult. * Fix tests to work with OperatorBase rather than WeightedPauliOperator * fix es_factory and additional information in FermionicTransformation for Analytical qEOM * rm WPO support in trafo, add test for aux_ops * Fix docstring * Fix aux_op particle-hole conversion * Extend ElectronicStructureResult to work with excited state calculations Since an electronic structure can consist of multiple states and during excited state calculations we obtain energies and auxiliary operator evaluations for each investigated state we expose all finally interpreted result properties as Lists where the first entry should always reflect the ground state properties. * fix auxiliary operators * reformatting of electronic structure results print * fix linting * fix mypy * Restructure excited states code - moving modules - renaming classes - adapting tests * more mypy fixes * final mypy fixes * add use_default_filter_criterion argument to NumPyEigensolverFactory * fix tests * fix lint and spell * fix lint * fix unittests * fix test * Fix typos in reno * added a release note * Do not use the default_filter_criterion for excited states Since we opted to make the default filter criterion of the fermionic case filter non-singlet states this kind of misses the point in the excirted states cases. Thus we now provide a custom filter in the test. For the backlog we should consider a better implementation of the default filter which can handle this automatically. * Fix test * Do not append line to README * Fix some docstrings and copyright years * Fix test * Use aqua_globals.random_seed in bopes test * Fix lint Co-authored-by: Panagiotis Barkoutsos <[email protected]> Co-authored-by: Panagiotis Barkoutsos <[email protected]> Co-authored-by: Max Rossmannek <[email protected]> Co-authored-by: Stefan Woerner <[email protected]> Co-authored-by: Cryoris <[email protected]> Co-authored-by: Julien Gacon <[email protected]> Co-authored-by: Manoel Marques <[email protected]> Co-authored-by: Anton Dekusar <[email protected]> Co-authored-by: Anton Dekusar <[email protected]> Co-authored-by: Max Rossmannek <[email protected]> Co-authored-by: Steve Wood <[email protected]> Co-authored-by: Mario Motta <[email protected]> Co-authored-by: Stefan Woerner <[email protected]>
manoelmarques
added a commit
to manoelmarques/qiskit-terra
that referenced
this pull request
Dec 7, 2020
…/qiskit-aqua#1354) * ground state min eigensolver interface * fix small things style * added the molecule object with the right properties * minor fix molecule * excited state calculation added * EOMvqe added * ground state interface minimum eigensolver * Add MinimumEigensolver interface to VQEAdapt * Implement the AdaptVQEGroundStateCalculation class This properly implements the AdaptVQEGroundStateCalculation class. The idea of this class is to allow easy use of the VQEAdapt algorithm which was previously extended to support the MinimumEigensolver interface. This Calculation class is solely for the use with this algorithm which is why it does not support setting a different solver. Instead, it requires setting a QuantumInstance object through its initializer. The changes which this requires include the following: - fixing the GroundStateCalculation class - fixing the MinEigensolverGroundStateCalculation class Furthermore, a very basic unittest for this change was added. * comments * initial bopes sampler * naming * compute eigenvalue MinEigensolver works * return raw results until I make the GroundStateResult * now the fermionic transformation returns a molecular ground state result working with mineigensolver result * added TODOs * rename GSC files * add init to qubit_transformations * fix lint in bosonic_trafo and qubit_op_trafo * update (MES)GSC to new structure * rm empty orbital optimization file * Fix init * Implement returns_groundstate and fix some lints * Rewrite AdaptVQEGSCalc. deriving from MESGSCalc. * Add TODO about deprecating qiskit.chemistry.algorithms module * Revert "Add MinimumEigensolver interface to VQEAdapt" This reverts commit 362843b19ff199e1b824b4318b14eee1d5c3da66. * Properly deprecate VQEAdapt * Port VQEAdapt to AdaptVQE (based on a GroundStateCalculation) This properly refactors the old qiskit.chemistry.algorithms.minimum_eigen_solver.VQEAdapt into the new qiskit.chemistry.ground_state_calculation.AdaptVQE class which implements the new GroundStateCalculation interface. The name change is intentional because the new name is in-line with the literature on AdaptVQE. The old name was presumably intentional to highlight its relation to VQE. The unittests for VQEAdapt are ported accordingly. * Some minor corrections/updates * Rename AdaptVQE files * Add optional custom_excitation_pool argument to AdaptVQE computation method * Work on FermionicTransformation and related objs - add interpet method to QubitOperatorTransformation and FermionicTransformation - remove deprecated method `_process_..._deprecated` - deprecate Hamiltonian and ChemistryOperator * documentation added * fixes in ground state * patch MES result to GSC result instead of returning a tuple * files fixes for GSC interface * rm utf8 headers * fix spell, lint, mypy * Remove `custom_excitation_pool` from AdaptVQE `compute_ground_state` function Rather than ignoring the arguments given by the interface, we can remove this additional argument in favor of enabling the user to set this custom excitation pool through the `MESFactory`. An example on how to achieve such a thing can be seen in the corresponding unittest. * fix mypy * fix lint * Re-enable DeprecationWarnings after VQEAdapt has been initialized * Fixes several minor nit-picks - copyright years - faulty renames - faulty merge side-effects - missing setters * make MESFactory an interface only * fix copyright years * derive from MESFactory and update docs * update docstrings and add molecule_info * consistent naming in ``ground(_)state`` * fix spell * more spell, deprecate MGSE * fix deprecation * more style * test fixes * fixes * [WIP] basic Result-interfaces This adds the following interfaces: - qiskit.chemistry.ChemistryResult(AlgorithmResult) - qiskit.chemistry.ground_state_calculation.GroundStateResult(ChemistryResult) - qiskit.chemistry.ground_state_calculation.FermionicGroundStateResult(GroundStateResult) The logic is as follows: ChemistryResult and GroundStateResult are empty interfaces which define a hierarchy for the result classes. They provide a useful granularity for type checking. Once more subclasses are added we can extract common functionality up into the stack as needed. The FermionicGroundStateResult currently is just a port of the old MolecularChemistryResult and MolecularGroundStateResult. Both of these classes are deprecated in this commit. Since this class is currently specific to the GroundStateCalculation it is part of that module. This is, however, subject to change. * Remove BosonicTransformation from this PR The BosonicTransformation will be added in a separate PR aiming to refactor the respective modules. * AdaptVQE actually supports aux_operators * [wip] resolve cyclic import problems Having a `Result` class in either the `ground_state_calculations` or `qubit_operator_transformations` modules leads to a coupling of the two modules that is too tight. I.e. we run into cyclic imports whenever we try to run any code because the `QubitOpTransformation` class needs to load the `Result` class while at the same time it needs to be available in the `GroundStateCalculation` class. Thus, when an additional coupling in between these two modules is created, we have cyclic import. Thus, we drop one level of granularity and only provide a single result-interface on the `qiskit.chemistry` level, here, called `ChemistryResult` (open for discussion). I also moved the `DipoleTuple` to this level to simplify its usage in the other classes. * Make AdaptVQE use the FermionicGSResult * Use FermionicGroundStateResult in MinimumEigensolverGroundStateCalculation * Fix mypy * Filter DeprecationWarnings in unittests This filters all of the DeprecationWarnigns introduced in this PR. In 3 months from now we can remove these tests once the corresponding code is also removed. This commit also adds TODO labels to all of these unittest files which will have to be migrated to work within the new framework. * Add TODO in AdaptVQE unittest * Add missing unittest imports I noticed that in some test files the unittest module is not imported and the `__main__` is not set accordingly. If we do not want to mix these changes into this PR, we can simply revert this commit. * mypy fix * unused code * Create qiskit.chemistry.results module * Replace interpret() with add_context() in QubitOperatorTransformations Instead of an interpret() function, the QubitOperatorTransformation interface defines an add_context() function which is used to augment the given StateResult object with information based on the transformation's context. * Fix GroundStateCalculation classes to work with the results interface * Revert faulty change in github workflow * unitests WIP first commit * remove deprecation suppressing from new tests * support additional aux ops and conv to dict * fix aux_ops=None * lint, style * more test * fixes in test * fix style * fix mypy * fix mypy * fixes in fermionic trafo * remove editor created redundant file * resolved tests * docstring fix * fix error & specify type hint * change typehint Any -> FermionicOp * add missing imports * spell * suggestions from code review * consistent use in .keys() * type hints, minor improvements * Rethink the qiskit.chemistry.results After some discussion we decided to rethink parts of the qiskit.chemistry.results interfaces. We want to minimize the differentiation between grround and excited states and let only the concrete `QubitOperatorTransformation` handle the fermionic and bosonic differentiation. Thus, I apply the following changes: * provide a single `EigenstateResult` which can be either a ground or excited state * derive `ElectronicStructureResult` (prev. `FermionicResult`) from this * use the `FermionicTransformation.interpret()` method to map a general `EigenstateResult` to the type specific for the transformation With the last change we also align the `qiskit.chemistry` module further with the `qiskit.optimization` module where we also use `interpret()` rather than `add_context()` methods (which was the name we intended to use prior to this commit). * Remove unneeded DeprecationWarning from AdaptVQEResult * Update some docstrings * fix lint * revert back to lists of aux_ops * Update qiskit/chemistry/ground_state_calculation/adapt_vqe.py Co-authored-by: Max Rossmannek <[email protected]> * apply suggestions from code review * change typehint to List[float] * Update qiskit/chemistry/core/hamiltonian.py Co-authored-by: Steve Wood <[email protected]> * test fixes after code review * excited state interface for matching the ground state interface and handling both electronic and vibrational states * Rename aux_values to aux_operator_eigenvalues This naming is consistent with the EigensolverResult and MinimumEigensolverResult classes. * Remove leftover from dict-style aux_operators * Add an `evaluate_operators` method to the GroundStateCalculation This method can be used to evaluate any additional auxiliary operators after the GSC has finished. This will be necessary especially in the excited state calculations and is in general a nice option for the user to have. The method is similar to how the `VQE` evaluates auxiliary operators internally. However, it can also deal with `MinimumEigensolver`s which do not use a `QuantumInstance`. A curiousity arose because the `VQE` appears to wrap the auxiliary operator results into lists multiple times. In order to ensure interoperability the same is done here. The `AdaptVQE` now derives off of the `MinimumEigensolverGSC` because there was no obvious drawback to this and the benefit of reusing this new method was welcome. Unittests have been added to test the new functionality. * fix lint * Remove erronous TODO * Enforce a FermionicTransformation in the VQEUCCSDFactory * Do not enforce VQEUCCSDFactory type in AdaptVQE Since we check for the VQE and UCCSD types anyways we shouldn't force the user to subclass this factory. * Reuse the VQE object during AdaptVQE * Expose molecule_info and qubit_mapping publicly * fix lint * fixes in tests * fixes in tests and revert to molecule_methods * remove two duplicate tests * Expose some VQE arguments in the VQEUCCSDFactory As discussed, we now expose some of the VQE arguments through this factory in order to allow greater flexibility for the user. * test commit * fix spell * fix bugs qeom code and first version of test for numerical qeom * added the build_hopping_operator capability in the transformation * modified results to take excited states components * reverted due to missing part of the test uccsd_HF * remove test EOM todos * lint * more lint * more lint * Prepare EigenstateResult to handle ground and excited states * Deprecate the Enums in the chemistry.core module * Also populate eigenstates in ground state calculations * Add factory for NumPyMinimumEigensolver * Implement `_filter_criterion` in FermionicTransformation * Extract default filter_criterion into interface Rather than checking for a private method being implemented we can obtain the default filter_criterion cleanly. This makes sense because any transformation in theory could implement a default filter. However, we return None in case it is not implemented. * fixing qeom code * Make use of default filter criterion configurable * Check state's type before making at a StateFn * Use `supports_aux_ops` in `returns_groundstate` * Replace Any type-hint where not really necessary The reason for making it a union of lists rather than a list of a union is to ensure that no mixed lists are allowed. * Do not use legacy Operator in new interface The WeightedPauliOp is a legacy operator and should not be used in this new interface. Instead, we now convert the operators to the OperatorFlow before returning them to ensure we only use the new operator types. * fix the eigenstate_result and electronic_structure_result to work with excited states and test eom with Numpy eigensolver for the ground state * clean qeom code * tests for numerical qeom * change of the ExcitedStatesCalculation init so that it does not have a GSC * Except (Minimum)EigensolverResults in interpret() To provide more user-flexibility and better compatibility with the Aqua result classes, the interpret() method is able to handle (Minimum)EigensolverResult classes as well as the EigenstateResult. * Fix tests to work with OperatorBase rather than WeightedPauliOperator * fix es_factory and additional information in FermionicTransformation for Analytical qEOM * rm WPO support in trafo, add test for aux_ops * Fix docstring * Fix aux_op particle-hole conversion * Extend ElectronicStructureResult to work with excited state calculations Since an electronic structure can consist of multiple states and during excited state calculations we obtain energies and auxiliary operator evaluations for each investigated state we expose all finally interpreted result properties as Lists where the first entry should always reflect the ground state properties. * fix auxiliary operators * reformatting of electronic structure results print * fix linting * fix mypy * Restructure excited states code - moving modules - renaming classes - adapting tests * more mypy fixes * final mypy fixes * add use_default_filter_criterion argument to NumPyEigensolverFactory * fix tests * fix lint and spell * fix lint * fix unittests * fix test * Fix typos in reno * added a release note * Do not use the default_filter_criterion for excited states Since we opted to make the default filter criterion of the fermionic case filter non-singlet states this kind of misses the point in the excirted states cases. Thus we now provide a custom filter in the test. For the backlog we should consider a better implementation of the default filter which can handle this automatically. * Fix test * Do not append line to README * Fix some docstrings and copyright years * Fix test * Use aqua_globals.random_seed in bopes test * Fix lint Co-authored-by: Panagiotis Barkoutsos <[email protected]> Co-authored-by: Panagiotis Barkoutsos <[email protected]> Co-authored-by: Max Rossmannek <[email protected]> Co-authored-by: Stefan Woerner <[email protected]> Co-authored-by: Cryoris <[email protected]> Co-authored-by: Julien Gacon <[email protected]> Co-authored-by: Manoel Marques <[email protected]> Co-authored-by: Anton Dekusar <[email protected]> Co-authored-by: Anton Dekusar <[email protected]> Co-authored-by: Max Rossmannek <[email protected]> Co-authored-by: Steve Wood <[email protected]> Co-authored-by: Mario Motta <[email protected]> Co-authored-by: Stefan Woerner <[email protected]>
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Interface for excited states calculation.
Details and comments
contains high level wrappers as well as algorithms/factories (qeom, numpy_eigensover_factory), results...