Closed frajos100 closed 5 years ago
QuantumInstance code is here https://github.com/Qiskit/qiskit-aqua/blob/master/qiskit/aqua/quantum_instance.py The find_minimum is in the parent class of VQE which is VQAlgorithm here https://github.com/Qiskit/qiskit-aqua/blob/master/qiskit/aqua/algorithms/adaptive/vqalgorithm.py Is this what you were looking for? The API doc was created from the stable release version of the code. The code in master is the development version and so that API doc may not always reflect what you see in the code in the master branch.
Thank you so much Steve for pointing out the code for Quantum_Instance. Found that the find_minimum_eigenvalue in vqe class generates the optimized matrix from the classical algorithm which is then used to generate the Quantum circuit to produce the optimal result. Hence the final results depend on the classical optimization algorithm, Need your affirmation on this. We have chosen SPSA .
How exactly vqe runs depends on the backend you provide. matrix mode was done for performance reasons. And for paulis mode, with the operator as a list of paulis, these are each evaluated as circuits. The optimizer is what finds the minimum. We supply it an objective (cost) function and a starting (initial) point. The function is _energy_evaluation and that evaluates the energy at a given point (params) using the variational form. The variation form is parameterized and we seek to find the parameterization that gives the minimum energy. The optimizer is the classical part the evaluation of the energy using variational form circuits and operator is the quantum part. Once the optimizer is started it will attempt to find the minimum by whatever strategy it has. This can be done by evaluating gradient using close neighbouring points and using that to go to a new point and repeat. We have a notebook that shows the a plot of convergence where the evaluation at each point, in the cost function, is captured using a callback we supply and later a graph is plotted. You can see this here in our working fork where we preparing notebooks for the next release https://github.com/manoelmarques/qiskit-tutorials/blob/aqua0.5/community/aqua/general/vqe_convergence.ipynb SPSA was designed to work when the evaluation is noisy such as probabilistic measurements on a qasm simulator or a real device. If you are using the state vector simulator, then other optimizers, such as used in the above notebook, can perform better.
Thanks once again Steve The underlying circuits are created based on RY variational forms or the form that we have selected. For Matrix is Ry form the best approach? Got a bit confused in the u1, u2 and u3 gates. Not able to find some good reading material on them. circuit.u2(0.0, np.pi, q[target]) # h circuit.u3(parameters[param_idx], 0.0, 0.0, q[qubit])
Thanks once again Steve. Hardamard gate definition is U2(0,PI q[1]); But in the circuit it is U2(0.0,Pi, q[1]); are they both the same?
What exactly looks different to you that you ask are those two U2's the same? They look the same to me. We use the U gates in our circuits directly rather than relying on the translation from say H or RY; though we usually comment the line as its often easier quicker to see RY in the comment etc
Thank you. Got the overall picture.
Cannot find the definition for the random function as described below in the VQE.py file. initial_point = self.random.uniform(low, high) Tried adding some print statement in uniform_distribution.py at Python\Python36\Lib\site-packages\qiskit_aqua\components\random_distributions. But they did not get fired. Where could i find the random function?
The method is here https://github.com/Qiskit/qiskit-aqua/blob/af1db3e704105f87e0633ddcfaf293057b58d55e/qiskit/aqua/algorithms/quantum_algorithm.py#L44 in a base class of VQE - QuantumAlgorithm. Its the base class of all the algorithms.
If you follow the logic there you will see it ends up using numpy.random so the uniform() method is from numpy https://docs.scipy.org/doc/numpy/reference/generated/numpy.random.uniform.html#numpy.random.uniform
If you use an IDE, such as PyCharm, then you can find functionality like goto implementation
and find usages
etc. These can be highly useful in navigating around code
What is the expected enhancement?
Need the QuantumInstance API code base. In vqe.py there is a find_minimum function definition of which is not present at https://qiskit.org/documentation/autodoc/qiskit_aqua.quantum_instance.html?highlight=quantuminstance