Qiskit Nature 0.4.0
Changelog
New Features
- Adds Hartree-Fock (HF) and vibrational self-consistent field (VSCF) initial point classes. HFInitialPoint and VSCFInitialPoint, are to be used with UCC, and UVCC, respectively.
This follows the introduction of MP2InitialPoint for computing the initial point using the Møller-Plesset 2nd Order (MP2) corrections.
MP2InitialPoint, HFInitialPoint, and VSCFInitialPoint all inherit from the abstract base class InitialPoint.
These initial points are intended to be used as starting VQE parameters when using a UCC ansatz (cluster operator coefficients). This should introduce an initial point that is closer to the ground state point, leading to fewer overall evaluations for VQE.
Instances of the appropriate classes are now the default initial_point arguments in VQEUCCFactory and VQEUVCCFactory. Additionally, one may pass an explicit InitialPoint instance to the factories.
- Added logging utility functions accessible through qiskit_nature.logging.
- Added Support for Bohr unit in Molecule Class:
- Adds BogoliubovTransform. This class constructs a circuit that performs a Bogoliubov transform, which is a single-particle basis change that may or may not conserve particle number. See the Quadratic Hamiltonians and Slater determinants tutorial for a demonstration of how to use this class.
- The new setting qiskit_nature.settings.optimize_einsum was added which allows enabling the optimize argument in numpy.einsum calls with more than 2 operands. This is known to yield significant computational efficiency increases at the expense of higher memory consumption. The setting defaults to True.
- Adds qiskit_nature.operators.second_quantization.FermionicOp.terms(). This returns an iterable of (term, coefficient) pairs describing the terms contained in the operator. Each term is a list of tuples of the form (action, index), where the action is either “+” or “-” and the index is the integer index of the factor in the term.
- Added Qiskit Terra’s Gradient Functionality to calculate gradients in AdaptVQE. You can choose the gradient method and input it while calling AdaptVQE.
- The HDF5Driver has been refactored to leverage the new HDF5-integration protocol of Qiskit Nature. The driver still supports loading legacy QMolecule HDF5 files and also provides a conversion utilit
- Adds a new HDF5-integration to support storing and loading of (mostly) Property objects using HDF5 files. A similar feature existed in the legacy QMolecule object but the new implementation is handled more general to enable leveraging this integration throughout more parts of the stack in the future.
- Support the initialization of FermionicOp with tuple as label. FermionicOp can be initialized using a tuple of integers, (action, index)
- Add the option to initialize a Lattice from a networkx.Graph object, which will be internally converted to a retworkx.PyGraph for performance.
- Adds a new problem class, qiskit_nature.problems.second_quantization.lattice.LatticeModelProblem, for lattice models. It can create second quantized operators from a lattice model. We can use the Ground State Eigensolver with it to calculate the ground state energy.
- Adds qiskit_nature.mappers.second_quantization.LogarithmicMapper. This class is a mapper for Logarithmic spin-to-qubit mapping. In this local encoding transformation, each individual spin S system is represented via the lowest lying 2S+1 states in a qubit system with the minimal number of qubits needed to represent >= 2S+1 distinct states.
- Adds a class to compute the Møller-Plesset 2nd Order (MP2) corrections. The corresponding double-excitation coefficients are intended to be used as an initial point for the VQE parameters (cluster operator coefficients) when using a UCC ansatz. This should introduce an initial point that is closer to the ground state point, leading to fewer overall evaluations for VQE.
MP2InitialPoint inherits from the abstract base class (interface) InitialPoint, which takes a driver result and a UCC ansatz either directly via the compute method or via their respective property setters.
The MP2 computation requires the grouped_property to contain the ElectronicEnergy, which must contain the two-body molecular orbital matrix and the orbital energies. Optionally, it will also use the Hartree-Fock reference energy to compute the absolute energy.
- Improves the performance of the qiskit_nature.properties.second_quantization.electronic.integrals.ElectronicIntegrals.to_second_q_op() method significantly. Previously, generating the second quantized operators for a system size greater than 20 spin orbitals took on the order of minutes to hours (depending on the actual size). Now, even system sizes of 50 spin orbitals can be handled in a matter of seconds.
- Now there is a function to interpret the raw result of solving a protein folding problem. Previously the problem was encoded in order to be solved more efficiently but the result could not be easily understood by a user. This new functionality decodes the result for the user and provides a plotting of the protein as well as a file with the x,y,z coordinates of each one of the beads in the protein.
Added: ProteinFoldingResult. This class handles the result found by running a VQE to solve a ProteinFoldingProblem
- Adds qiskit_nature.operators.second_quantization.QuadraticHamiltonian. This class is used to represent quadratic fermionic Hamiltonians and includes methods to efficiently diagonalize them.
- Adds the simplify method to qiskit_nature.operators.second_quantization.SecondQuantizedOp and the normal_ordered method to qiskit_nature.operators.second_quantization.FermionicOp. These methods replace reduce and to_normal_order, which are deprecated
- Adds functionality to prepare Slater determinants and fermionic Gaussian states using the Givens rotation strategy.
- The solver of BOPESSampler now accepts solvers of type Union[GroundStateSolver,ExcitedStatesSolver] instead of only a GroundStateSolver. This generalizes to excited states the sampling of nuclear coordinates for Born Oppenheimer Potential Energy Surfaces. Adds the get_qubit_operators() in qiskit_nature.algorithms.ExcitedStatesEigensolver. This matches the format of qiskit_nature.algorithms.GroundStateEigensolver. BOPESSampler now also accepts auxiliary operators to pass to the solver. Geometry-dependent observable can also be defined as auxiliaries. See the Sampling the potential energy surface tutorial for a demonstration of how to use this calculation of excited state Born Oppenheimer potential energy surfaces.
- VQEClient now extends VariationalAlgorithm, meaning users can now implement BOPESSampler using bootstrapping, which works similarly now with VQEClient VQEClient as it did previously with local VQE.
Upgrade Notes
- Added support for running with Python 3.10. At the the time of the release, PySCF didn’t have a python 3.10 version.
- Support for running with Python 3.6 has been removed. To run Nature you need a minimum Python version of 3.7.
- Changes the default display_format of the constructor of FermionicOp from “dense” to “sparse”.
Deprecation Note
-
The delta argument of AdaptVQE is deprecated in favor of supplying a gradient from Qiskit Terra’s qiskit.opflow.gradients framework. In doing so, the default behavior of AdaptVQE changes from using a finite difference scheme for the gradient evaluation to using a parameter shift method.
-
The following second quantization operator methods are deprecated:
qiskit_nature.operators.second_quantization.SecondQuantizedOp.reduce(). Instead, use [qiskit_nature.operators.second_quantization.SecondQuantizedOp.simplify()](https://qiskit.org/documentation/nature/stubs/qiskit_nature.operators.second_quantization.SecondQuantizedOp.simplify.html#qiskit_nature.operators.second_quantization.SecondQuantizedOp.simplify). [qiskit_nature.operators.second_quantization.FermionicOp.to_normal_order()](https://qiskit.org/documentation/nature/stubs/qiskit_nature.operators.second_quantization.FermionicOp.to_normal_order.html#qiskit_nature.operators.second_quantization.FermionicOp.to_normal_order). Instead, use [qiskit_nature.operators.second_quantization.FermionicOp.normal_ordered()](https://qiskit.org/documentation/nature/stubs/qiskit_nature.operators.second_quantization.FermionicOp.normal_ordered.html#qiskit_nature.operators.second_quantization.FermionicOp.normal_ordered).
-
The argument gss of the constructor of BOPESSampler was deprecated and replaced by state_solver to match the extension of this class to qiskit_nature.algorithms.ExcitedStatesEigensolver
-
VQEUCCFactory had setter/getter properties that were repeated with respect to qiskit.algorithms.VQE.
In order to avoid duplicating all of these attributes, potentially leading to inconsistencies between the attributes of the different classes, these are now deprecated and require you to use the attributes from minimum_eigensolver instead. For this reason, the constructor of VQEUCCFactory has been changed as well
Bug Fixes
-
The BOPESSampler did not support GroundStateSolvers when built out with MinimumEigensolverFactories. This is fixed, so code like the following now functions correctly:
solver = GroundStateEigensolver(converter, VQEUCCFactory(quantum_instance))
sampler = BOPESSampler(solver, bootstrap=True, num_bootstrap=None, extrapolator=None) -
Fix incorrect corner cases in BravyiKitaevSuperFastMapper: Input terms with coefficient zero and output operator equal to zero. Also detect and raise an exception if HartreeFock attempts to use the BKSF mapper.
-
Fix bug in Bravyi-Kitaev Super-Fast (BKSF) Mapper cause by using obsolete method for composing Pauli operators in one kind of fermionic Hamiltonian term.
-
Fixes a bug in VQEClient using dict based aux_operators instead of deprecated list based ones (enabled via qiskit_nature.settings.dict_aux_operators = True).
-
Some minor issues in the ActiveSpaceTransformer were fixed. Namely:
iterated properties are no longer deep-copied resulting in non-transformed ones actually being dropped rather than carried on the correct return type object is being constructed and returned
-
Fixes the ability to disable the freeze_core argument of the FreezeCoreTransformer
-
Fixes the wrong inference of register_length in FermionicOp.
-
Fixes the units used for the Molecule generated by the PySCFDriver.
-
Fixes the computation of the spin orbital occupation in a non-singlet state. Previously, a singly occupied MO would result in SO occupations of 0.5 for each spin. Now, the alpha SO will be fully occupied and the beta SO unoccupied.
-
UCC and UVCC when fully configured via the constructor failed to transpile and were not valid circuits. This fixes that to ensure that if UCC / UVCC are fully configured then as circuits they are are immediately valid from the get go.
-
Fix the groundenergy in EigenstateResult to return a correct value.
-
Alter UCC to build the operators on demand when requested via the property, rather than, as before, when the circuit is built. Now if the circuit is built, then the operators, if not built, will be created as before, but since they are cached when built, if done earlier, then these are used. This avoids problems when used in conjunction with VQE that presently fail - most cases today use a fully configured UCC being passed into VQE but whose constructor presently has an unintended side-effect of building the circuit via a logging statement. For other scenarios VQE would fail when it checked on number of qubits and the operators were None, even though UCC was fully configured, when the circuit had not yet been built.
-
Add a type check for the input graphs to Lattice which asserts that the edge weights of the graph are either numeric (or one of None or {} which is replaced by a unit weight). This prevents possibly unexpected errors in the application stack when an operator is constructed from the lattice.
In particular, the following now raises a ValueError:
from retworkx import PyGraph
from qiskit_nature.problems.second_quantization.lattice import Latticegraph = PyGraph(multigraph=False)
graph.add_nodes_from(range(3))
graph.add_edges_from([(0, 1, 1), (1, 2, "banana")]) # banana is not a valid weight!lattice = Lattice(graph)
-
Alter UVCC to build the operators on demand when requested via the property, rather than, as before, when the circuit is built. This is a similar change as was done to UCC.
-
Ensures the VibrationalStructureProblem.truncation_order gets propagated correctly down to the properties before the SecondQuantizedOp instances are constructed.