Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge qiskit-aqua to my fork #1

Merged
merged 35 commits into from
Jul 4, 2020

Conversation

molar-volume
Copy link
Owner

Summary

Details and comments

mtreinish and others added 30 commits May 19, 2020 09:53
* Add reno fore release notes and update CONTRIBUTING guide

Moving forward aqua will be using reno for release documentation. This
commit adds a pro-forma release note and the documentation configuration
to verify release notes moving forward. It also updates the CONTRIBUTING
guide to reflect this new change.

Fixes #990

* Add missing docs file

* Fix copy and paste errors

* Fix more copy and paste errors

* Add release_notes to index.rst

Co-authored-by: Manoel Marques <manoel@us.ibm.com>
* fix problem with variable bounds in cobyla optimizer and add unit test

* derive initial state from variable bounds

Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>
…f add (#1000)

* removed unnecessary "[]"

* separate SummedOp.simplify out from SummedOp.add

* simplify

* revise comments

* add a unit test

* revise comments

* revise test_op_construction and test_abelian_grouper

* revise comments of abelian_grouper

* revise a comment

* use ddt for test of abelian grouper

* revise a comment
* #893
Iterative Grover Allows Custom Lambda
1) Parameter "lam" can be explicitly set in constructor, with default value 1.34, which is proved to be optimal
2) Sequence of Grover rotation counts can be explicitly set in the constructor, e.g. rotation_counts = [ 0, 1, 3, 5, 9 ]

Iterative Grover Allows Custom Lambda
- grover_test parametrised by rotation_counts
- if rotations_counts is None, the number of iterations increases by the factor of lambda
- the fixed rotation sequence [0, 0, ..., 49, 4, 60 ] is efficient choice according to Baritompa et al., Grovers Quantum Algorithm Applied to Global Optimization


Co-authored-by: Stefan Woerner <41292468+stefan-woerner@users.noreply.github.com>
Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>
Co-authored-by: Manoel Marques <manoel@us.ibm.com>
* Update to new NumPy RNG

* use global generator on numpydiscriminator

* fix ml digits test

* fix finance random test

* increase scipy min.requirements

* fix portfolio test

* fix optimization tests

* unit test change

* fix hhl unit test

* change unit test

* fix IBMQ unit test imports

* change remaining np.random calls to generator

* change unit tests

* change seed on test vqc

* Amend unit tests

* Update numpy method

* Amend unit tests

* change vqc test

Co-authored-by: woodsp <woodsp@us.ibm.com>
* Fix VQE optimizer setter
* Test lam argument in Grover algorithm
* re-use optimal vector result previously computed

* fix type of result.eigenstate
* reset step count in minimize and set params_new

* remove duplicate loc
* trim vqe

* dont remove max_evals_grouped test

* reduce tests to library objects

* wrap reused code in a separate assert fun

* reduce VQE2IQPE, SwapRZ and QGAN tests

* keep testing SwapRZ

* remove old qft tests

* remove trailing unpack

* trim QSVM

* fix qpe test

precision was set too high -- no trivial translation from "signficant" to either "places" or "delta"

* test HHL, QPE, QAE on deprecated QFTS

* fix vqe and qsvm tests

* fix vqc tests

* fix arg mixup in negative eigenvalues

* fix lint

* use better suited optimizer for statevector

* change assertLess to assertGreater

* correct QASM -> statevector comment

Co-authored-by: Manoel Marques <manoel@us.ibm.com>
* Use AlgorithmResult for return from run()

* Store phi_add as a gate, create _init_circuit method

* Use inverse and control logic inside controlled_controlled_phi_add_mod_N

* Use a separate circuit to be inverted during _controlled_multiple_mod_N

* Typing on _get_factors

* Import Gate from qiskit.circuit

* Use name in init_circuit

* Use inverse of controlled_multiple_mod_N

* Use gates for multiplication functions

* Reduce gate name and keep register order consistent

* Revert back to circuit functions

* Update documentation and extract modinv

* Update documentation in accordance with contribution guidelines

* Add tests

* Update for spell check

* Apply suggestions from code review

Co-authored-by: Julien Gacon <gaconju@gmail.com>

* Rename to double_controlled_phi_add

* Initialise QuantumCircuit without private method

* Make modinv error message more meaningful

* Remove phi_add_gate test

* Add int type hint

* Omit quantum register in _phi_add_gate

* replace compose calls with append

* Use angles ParameterVector and rewrite double_controlled_phi_add_mod_N

* Mak phi_add_gate static

* Update indexing in _double_controlled_phi_add_mod_N

* Move inverted controlled addition into _controlled_multiple_mod_N

* Update documentation

* Apply angles correctly

* Revert "Remove phi_add_gate test"

This reverts commit 907e861.

* Optimize imports

* Update phi_add_gate test logic

* Remove phi_add_gate test

* Remove redundant qubit index call

* rename multiple_mod_N to gate, update formatting

* Add extra test case for modinv test

* Use circuit.qubits explicitly when reconstructing registers

* replace append calls in controlled addition circuit

* Make qft an instruction during __init__

* replace compose calls in _controlled_multiple_mod_N_gate

* Update docstrings

* Apply IQFT at the end of the exponentiation

* refactor logging formatting for results

* Make trivial factor check less verbose

* Return counts of successful results instead of each measurement

* Refactor factorization logic and logging in _get_factors()

* Add test cases for result counts

* Use % for logging statements

* extract continued fraction logic

* Sort factors in return of _get_factors

* rename x_value to x_final

* Fix type hint

* Do not evaluate i = N+1 in _get_factors()

Co-authored-by: Manoel Marques <manoel@us.ibm.com>
Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>
Co-authored-by: Julien Gacon <gaconju@gmail.com>
* Add static type hints checking

* run mypy on python 3.5

* a few more type hint fixes

Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>
* Fix QAOA initial point bug
* fix remaining type hints errors
* Pin sphinx version temporarily
* Remove cvxopt and use cvxpy instead

This commit removes the usage of cvxopt from aqua. It was supposed to be
removed as part of the 0.7 release since some users have issue
installing it, and other users aren't allowed to have GPL code installed
in their environment. However, cvxopt is still used for the quadratic
program solver utility. cvxopt is not needed to solve a quadratic
program and other elements are already doing this with cvxpy which
doesn't have the same issues [1][2]. This commit migrates the cvxopt
usage to cvxpy to be consistent with the rest of qiskit.

[1] Qiskit/qiskit-aer@e41d868
[2] qiskit-community/qiskit-ignis@42cbbf8

* fix lint, unit tests

* remove cvxopt from travis

Co-authored-by: Manoel Marques <manoel@us.ibm.com>
* VQE default expectation selection
* use compose instead of combine

* add test

* add reno
* compute eigenvalues more efficiently, if possible

* remove note

* fix spell

* use qubo to compute eigenvalue, not operator

* remove deprecation warning

* remove eval_operator_at_bitstring

* Update qiskit/optimization/algorithms/minimum_eigen_optimizer.py
* matrixop should return an instruction

* add test for matop.to_instruction

* add reno

* fix typo

* multiply operator by coeff before conversion

* ignore type

* cast type instead of ignore

* Revert "cast type instead of ignore"

This reverts commit 3e3e4bc.
* Fix hash function of PauliOp class

This change replaces the use of the `id()` function in the `PauliOp`
hash function with the hash of its string representation. This is inline
with the hash function of the `Pauli` class.

This fix is necessary, since prior to this change, a set comparison
including instances of identical `PauliOp`s would fail, because sets
rely on hash tables.

A regression test to ensure the working state after this commit is
included, too.

Credits for spotting and collaborating in fixing the bug go to @Cryoris

* Add releasenote

Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>
* Make cvxpy an optional dependency

This commit makes the cvxpy dependency optional because many users have
trouble installing it because on many environments it requires that a
compiler be present to build the package from sdist and there are no
precompiled binary wheels present for many environments. Users of the
svm classifier will have to install cvxpy manually or with the extra
now, but it should remove the barrier for most users.

Related to #1053

* Fix lint and requirements list

* Update requirements list

* add cvxpy install to travis, remove from requirements-dev.txt

* Update error message

* Update releasenotes/notes/cvx-optional-e44920f87cff5e8d.yaml

Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com>

Co-authored-by: Manoel Marques <manoel@us.ibm.com>
Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com>
* 1) __str__ method implemented as export_as_lp_string()
2) methods pprint_as_string and prettyprint removed
3) unittest changed to use only export_as_lp_string()

* Update qiskit/optimization/problems/quadratic_program.py

Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com>

Co-authored-by: Manoel Marques <manoel@us.ibm.com>
Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>
Co-authored-by: Julien Gacon <gaconju@gmail.com>
Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com>
* qubo enhancement

* linting

* more linting

* docstring

* spelling, styling

* weird spell checker
)

* Fix Exchange/wiki providers, new Yahoo! provider, fix divide by 0

* add words to pylintdic to support latest pyenchant on mac

* Remove unused stockmarket parameter

* handle division by 0

* make pandas, quandl, yfinance optional

* fix spelling

* install pandas,quandl,yfinance on  aqua install

* expand not installed msgs
* factor in the coeff of ListOp

* fix coeff in composedop reduce

* state coeff must be squared (applied left and right)

* fix norm

* add test

* add reno
woodsp-ibm and others added 5 commits June 29, 2020 16:47
* Z2 symmetry fix for when no symmetries found

* Use classical solver for faster test
The legacy tutorial in the Qiskit/qiskit-tutorials repo for running
QSVM classification is failing with newer versions of aqua that use
cvxpy. The error message returned suggests setting the qcp flag to true
on solve(). This treats the problem as disciplined quasiconvex program
instead of a disciplined convex program and seems to avoid the hard
failure in the tutorial.

Fixes: Qiskit/qiskit-tutorials#928
* fix param binding of primitive

* add test

Co-authored-by: Manoel Marques <manoel@us.ibm.com>
@molar-volume molar-volume merged commit 246dbe9 into molar-volume:master Jul 4, 2020
molar-volume pushed a commit that referenced this pull request Oct 19, 2020
* clean PR with the current gradient state

* Update derivatives_base.py

* Update hessian.py

* Update test_grad.py

* add notebooks

* Typing, Linting

* Update gradient_framework.ipynb

* typing qfi

* enable gradients for VQAlgorithms

* remove old files and notes

* enfoce num chars <= 100

* fix an import

* re-adjust import

* fix other imports

* additional base classes

* test cases pass and the core logic all works. Doc strings could use another look. Same goes for some of the class method names inside of LinCombQFI and OverlapQFI

* Update derivatives_base.py (qiskit-community#75)

* Update derivatives_base.py

Added some doc-strings to several methods inside of derivatives_base.py. Also simplified the logic of `erase_operator_coeffs` by removing some leftover logic from previous implementations.

* Update qiskit/aqua/operators/gradients/derivatives_base.py

Co-authored-by: Julien Gacon <jul@zurich.ibm.com>

* update ordering/naming

* reshuffle, rename

* add VQE gradient unittest

* add notebook B2Meeting

This notebook will be removed after today - sorry but this is the best way to share this notebook with @bryce

* Update gradient_framework_reduced.ipynb

* removed a leftover notebook file

* removed the notebooks (and am pushing them to a cleaned up QGradients repo)

* Update gradient.py

This small change prevents trivial/zero operators from appearing in SummedOps during product rule computations.

* will be deleted need this to pull sry

* fix qfi docstring

* Add retworkx version check

* delete notebooks, fixed seed fin_diff circSampler, fix kwargs import error

* Delete test_natural_gradient.py

* fix symbol map in parameter expression grad

* typing

* Update qfi.py

* typing

* Update test_grad.py

* added a docstring to unroll_operator

* Update hessian.py

* Update gradient.py

* Fix statevector check (not always a QuantumInstance)

* Update hessian.py

* fix lint of qiskit/aqua/operators/gradients/*.py

* fix lint of qiskit/aqua/operators/gradients/circuit_gradients/*.py

* fix lint of qiskit/aqua/operators/gradients/circuit_qfis/*.py

* fix test_grad

* Copy folder

* remove unknown aqua changes

* fix ListOp, VQAlgorithms for gradients

* VQE Gradients import

* update operators init

* rm some changes not related to gradients

* mypy fixes

* skip jax test if not installed

* try to fix cyclic import

* fix lint in isinstance

* uncomment vqe tests + consistent HAS_JAX

* mypy fixes

* ignore mypy warning from opbase.coeff

* fix isinstance used w/ typehints

* try fixing sphinx

* ignore cases mypy doesn't understand correctly

* fix unnecessary else after raise

* Add jax to github actions

* fix spell

* add jax dependency to actions lint

* fix spell

* Reduce VQE Iterations in unittest

* Use ImportError

* fix lint

* Add gradient framework release note

* update gradient framework release note

* fix reno formatting errors

* Update to documentation

* Fix doctring to avoid warnings

* update gradient init

* update qaoa docstring

* remover retworkx check

* update docstrings

* lint fixes

* update docstrings to hint max_evals_grouped deprecation if gradient is given

* Update test_grad.py

Several high-level function calls still used a `method=...` argument in the initialization; however, we changed this to `grad_method`, `hess_method`, `qfi_method`. 
So I updated these arguments. 

This was causing some tests to not be carried out as the default argument was inferred when the correct argument name was not assigned a method type.

* Update test_grad.py

Added a test case for Hessian.py that forces it to differentiate an operator with a custom combo_fn

* Update lin_comb circuit gradients to fix hessian evaluation

* Move renamed gradient test into operator file

* update lin_comb

* update lin_comb gradients

* fix lint

* fix lin_comb

* fixed the bugs that were causing Hessian logic to fail with custom combo_fns

* increase coverage of natural gradient

* merge zoufalc gradients

* try all combinations of grad_method and qfi_method

* style fix

* updates for hessians

* remove redundant line

* make fixes

* remove hessian from grad

* relax VQE test

* remove redundant lambda

* fix identation

* fix spelling

* fix whitespace

* revert qfi_method in test_natural_gradient

* revert param name

* fix lint

* remove redundant comment

* update identation

* fix np.random.seed

* increase coverage for lin_comb

* fix lint

* lint

* whitespace fix

* docstring

* lint

* disable misspelling

* add yy, zz to pylintdict

* Update __init__.py

updated the gradients  __init__ file with some of the content from the release note

* fixed linting

* update init file

* fix spell

* fix spelling

* remove redundant import

* attempt to fix sphinx #1

* Update qiskit/aqua/operators/gradients/qfi.py

Co-authored-by: Julien Gacon <gaconju@gmail.com>

* try to fix sphinx no.2

* add words to pylintdict

* fix cryoris comments

* Update qiskit/aqua/operators/gradients/circuit_qfis/lin_comb_full.py

Co-authored-by: Julien Gacon <gaconju@gmail.com>

* Update qiskit/aqua/operators/gradients/circuit_qfis/lin_comb_full.py

Co-authored-by: Julien Gacon <gaconju@gmail.com>

* Update qiskit/aqua/operators/gradients/circuit_qfis/lin_comb_full.py

Co-authored-by: Julien Gacon <gaconju@gmail.com>

* cryoris comments

* delete unneccessary

* Update qiskit/aqua/operators/gradients/hessian.py

Co-authored-by: Julien Gacon <gaconju@gmail.com>

* raise warning hessians

* include docstring TypeError

* Update qiskit/aqua/operators/gradients/circuit_qfis/overlap_diag.py

Co-authored-by: Julien Gacon <gaconju@gmail.com>

* Update qiskit/aqua/operators/gradients/gradient.py

Co-authored-by: Julien Gacon <gaconju@gmail.com>

* remove unnecessary os comment

* Update qiskit/aqua/operators/gradients/circuit_gradients/lin_comb.py

Co-authored-by: Julien Gacon <gaconju@gmail.com>

* Insert proper Error

* apply changes from code review

Co-authored-by: Cryoris <jules.gacon@googlemail.com>
Co-authored-by: Takashi Imamichi <imamichi@jp.ibm.com>
Co-authored-by: Bryce-Fuller <Bryce.Fuller@ibm.com>
Co-authored-by: Julien Gacon <jul@zurich.ibm.com>
Co-authored-by: Manoel Marques <manoel.marques@ibm.com>
Co-authored-by: Manoel Marques <manoel@us.ibm.com>
Co-authored-by: woodsp <woodsp@us.ibm.com>
Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com>
Co-authored-by: Julien Gacon <gaconju@gmail.com>
molar-volume pushed a commit that referenced this pull request Dec 18, 2020
…munity#1367)

* clean PR with the current gradient state

* Update derivatives_base.py

* Update hessian.py

* Update test_grad.py

* add notebooks

* Typing, Linting

* Update gradient_framework.ipynb

* typing qfi

* enable gradients for VQAlgorithms

* remove old files and notes

* enfoce num chars <= 100

* fix an import

* re-adjust import

* fix other imports

* additional base classes

* test cases pass and the core logic all works. Doc strings could use another look. Same goes for some of the class method names inside of LinCombQFI and OverlapQFI

* Update derivatives_base.py (qiskit-community#75)

* Update derivatives_base.py

Added some doc-strings to several methods inside of derivatives_base.py. Also simplified the logic of `erase_operator_coeffs` by removing some leftover logic from previous implementations.

* Update qiskit/aqua/operators/gradients/derivatives_base.py

Co-authored-by: Julien Gacon <jul@zurich.ibm.com>

* update ordering/naming

* reshuffle, rename

* add VQE gradient unittest

* add notebook B2Meeting

This notebook will be removed after today - sorry but this is the best way to share this notebook with @bryce

* Update gradient_framework_reduced.ipynb

* removed a leftover notebook file

* removed the notebooks (and am pushing them to a cleaned up QGradients repo)

* Update gradient.py

This small change prevents trivial/zero operators from appearing in SummedOps during product rule computations.

* will be deleted need this to pull sry

* fix qfi docstring

* Add retworkx version check

* delete notebooks, fixed seed fin_diff circSampler, fix kwargs import error

* Delete test_natural_gradient.py

* fix symbol map in parameter expression grad

* typing

* Update qfi.py

* typing

* Update test_grad.py

* added a docstring to unroll_operator

* Update hessian.py

* Update gradient.py

* Fix statevector check (not always a QuantumInstance)

* Update hessian.py

* fix lint of qiskit/aqua/operators/gradients/*.py

* fix lint of qiskit/aqua/operators/gradients/circuit_gradients/*.py

* fix lint of qiskit/aqua/operators/gradients/circuit_qfis/*.py

* fix test_grad

* Copy folder

* remove unknown aqua changes

* fix ListOp, VQAlgorithms for gradients

* VQE Gradients import

* update operators init

* rm some changes not related to gradients

* mypy fixes

* skip jax test if not installed

* try to fix cyclic import

* fix lint in isinstance

* uncomment vqe tests + consistent HAS_JAX

* mypy fixes

* ignore mypy warning from opbase.coeff

* fix isinstance used w/ typehints

* try fixing sphinx

* ignore cases mypy doesn't understand correctly

* fix unnecessary else after raise

* Add jax to github actions

* fix spell

* add jax dependency to actions lint

* fix spell

* Reduce VQE Iterations in unittest

* Use ImportError

* fix lint

* Add gradient framework release note

* update gradient framework release note

* fix reno formatting errors

* Update to documentation

* Fix doctring to avoid warnings

* update gradient init

* update qaoa docstring

* remover retworkx check

* update docstrings

* lint fixes

* update docstrings to hint max_evals_grouped deprecation if gradient is given

* Update test_grad.py

Several high-level function calls still used a `method=...` argument in the initialization; however, we changed this to `grad_method`, `hess_method`, `qfi_method`. 
So I updated these arguments. 

This was causing some tests to not be carried out as the default argument was inferred when the correct argument name was not assigned a method type.

* Update test_grad.py

Added a test case for Hessian.py that forces it to differentiate an operator with a custom combo_fn

* Update lin_comb circuit gradients to fix hessian evaluation

* Move renamed gradient test into operator file

* update lin_comb

* update lin_comb gradients

* fix lint

* fix lin_comb

* fixed the bugs that were causing Hessian logic to fail with custom combo_fns

* increase coverage of natural gradient

* merge zoufalc gradients

* try all combinations of grad_method and qfi_method

* style fix

* updates for hessians

* remove redundant line

* make fixes

* remove hessian from grad

* relax VQE test

* remove redundant lambda

* fix identation

* fix spelling

* fix whitespace

* revert qfi_method in test_natural_gradient

* revert param name

* fix lint

* remove redundant comment

* update identation

* fix np.random.seed

* increase coverage for lin_comb

* fix lint

* lint

* whitespace fix

* docstring

* lint

* disable misspelling

* add yy, zz to pylintdict

* Update __init__.py

updated the gradients  __init__ file with some of the content from the release note

* fixed linting

* update init file

* fix spell

* fix spelling

* remove redundant import

* attempt to fix sphinx #1

* Update qiskit/aqua/operators/gradients/qfi.py

Co-authored-by: Julien Gacon <gaconju@gmail.com>

* try to fix sphinx no.2

* add words to pylintdict

* fix cryoris comments

* Update qiskit/aqua/operators/gradients/circuit_qfis/lin_comb_full.py

Co-authored-by: Julien Gacon <gaconju@gmail.com>

* Update qiskit/aqua/operators/gradients/circuit_qfis/lin_comb_full.py

Co-authored-by: Julien Gacon <gaconju@gmail.com>

* Update qiskit/aqua/operators/gradients/circuit_qfis/lin_comb_full.py

Co-authored-by: Julien Gacon <gaconju@gmail.com>

* cryoris comments

* delete unneccessary

* Update qiskit/aqua/operators/gradients/hessian.py

Co-authored-by: Julien Gacon <gaconju@gmail.com>

* raise warning hessians

* include docstring TypeError

* Update qiskit/aqua/operators/gradients/circuit_qfis/overlap_diag.py

Co-authored-by: Julien Gacon <gaconju@gmail.com>

* Update qiskit/aqua/operators/gradients/gradient.py

Co-authored-by: Julien Gacon <gaconju@gmail.com>

* remove unnecessary os comment

* Update qiskit/aqua/operators/gradients/circuit_gradients/lin_comb.py

Co-authored-by: Julien Gacon <gaconju@gmail.com>

* Insert proper Error

* apply changes from code review

* Fix probability hessians parameter shift

* change type hint

* update docstrings

* fix typos

Co-authored-by: Cryoris <jules.gacon@googlemail.com>
Co-authored-by: Takashi Imamichi <imamichi@jp.ibm.com>
Co-authored-by: Bryce-Fuller <Bryce.Fuller@ibm.com>
Co-authored-by: Julien Gacon <jul@zurich.ibm.com>
Co-authored-by: Manoel Marques <manoel.marques@ibm.com>
Co-authored-by: Manoel Marques <manoel@us.ibm.com>
Co-authored-by: woodsp <woodsp@us.ibm.com>
Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com>
Co-authored-by: Julien Gacon <gaconju@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants