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

Noise transformation fails with the latest cvxpy version #779

Closed
mtreinish opened this issue Jun 3, 2020 · 6 comments · Fixed by #832
Closed

Noise transformation fails with the latest cvxpy version #779

mtreinish opened this issue Jun 3, 2020 · 6 comments · Fixed by #832
Labels
bug Something isn't working

Comments

@mtreinish
Copy link
Member

Informations

  • Qiskit Aer version: Master
  • Python version: Any
  • Operating system: Any

What is the current behavior?

Running tests with cvxpy 1.1.0 installed fails:

test.terra.noise.test_noise_transformation.TestNoiseTransformer.test_clifford

-----------------------------------------------------------------------------

Captured traceback:

~~~~~~~~~~~~~~~~~~~

    Traceback (most recent call last):

      File "/home/travis/build/Qiskit/qiskit-aer/test/terra/noise/test_noise_transformation.py", line 221, in test_clifford

    results = approximate_quantum_error(error, operator_string="clifford")

      File "/home/travis/virtualenv/python3.8.1/lib/python3.8/site-packages/qiskit/providers/aer/utils/noise_transformation.py", line 102, in approximate_quantum_error

    probabilities = transformer.transform_by_operator_list(

      File "/home/travis/virtualenv/python3.8.1/lib/python3.8/site-packages/qiskit/providers/aer/utils/noise_transformation.py", line 388, in transform_by_operator_list

    probabilities = self.transform_by_given_channel(

      File "/home/travis/virtualenv/python3.8.1/lib/python3.8/site-packages/qiskit/providers/aer/utils/noise_transformation.py", line 669, in transform_by_given_channel

    return self.solve_quadratic_program(P, q)

      File "/home/travis/virtualenv/python3.8.1/lib/python3.8/site-packages/qiskit/providers/aer/utils/noise_transformation.py", line 757, in solve_quadratic_program

    prob.solve()

      File "/home/travis/virtualenv/python3.8.1/lib/python3.8/site-packages/cvxpy/problems/problem.py", line 395, in solve

    return solve_func(self, *args, **kwargs)

      File "/home/travis/virtualenv/python3.8.1/lib/python3.8/site-packages/cvxpy/problems/problem.py", line 743, in _solve

    data, solving_chain, inverse_data = self.get_problem_data(

      File "/home/travis/virtualenv/python3.8.1/lib/python3.8/site-packages/cvxpy/problems/problem.py", line 498, in get_problem_data

    solving_chain = self._construct_chain(

      File "/home/travis/virtualenv/python3.8.1/lib/python3.8/site-packages/cvxpy/problems/problem.py", line 651, in _construct_chain

    return construct_solving_chain(self, candidate_solvers, gp=gp,

      File "/home/travis/virtualenv/python3.8.1/lib/python3.8/site-packages/cvxpy/reductions/solvers/solving_chain.py", line 151, in construct_solving_chain

    reductions = _reductions_for_problem_class(problem, candidates, gp)

      File "/home/travis/virtualenv/python3.8.1/lib/python3.8/site-packages/cvxpy/reductions/solvers/solving_chain.py", line 89, in _reductions_for_problem_class

    raise DCPError(

    cvxpy.error.DCPError: Problem does not follow DCP rules. Specifically:

The objective is not DCP. Its following subexpressions are not:

QuadForm(var92, [[8.43095092e-30 3.99680289e-15 3.99680289e-15 7.99360578e-15

  7.99360578e-15 3.99680289e-15 3.99680289e-15 5.99520433e-15

  5.99520433e-15 5.99520433e-15 5.99520433e-15 3.99680289e-15

  7.99360578e-15 5.99520433e-15 7.99360578e-15 3.99680289e-15

  5.99520433e-15 5.99520433e-15 5.99520433e-15 7.99360578e-15

  7.99360578e-15 7.99360578e-15 7.99360578e-15 7.99360578e-15]

 [3.99680289e-15 8.00000000e+00 7.99360578e-15 8.00000000e+00

  6.00000000e+00 2.00000000e+00 2.00000000e+00 2.00000000e+00

  2.00000000e+00 6.00000000e+00 6.00000000e+00 2.00000000e+00

  6.00000000e+00 6.00000000e+00 6.00000000e+00 2.00000000e+00

  2.00000000e+00 6.00000000e+00 2.00000000e+00 6.00000000e+00

  4.00000000e+00 4.00000000e+00 4.00000000e+00 4.00000000e+00]

 [3.99680289e-15 7.99360578e-15 8.00000000e+00 8.00000000e+00

  6.00000000e+00 2.00000000e+00 2.00000000e+00 6.00000000e+00

  6.00000000e+00 2.00000000e+00 2.00000000e+00 2.00000000e+00

  6.00000000e+00 2.00000000e+00 6.00000000e+00 2.00000000e+00

  6.00000000e+00 2.00000000e+00 6.00000000e+00 6.00000000e+00

  4.00000000e+00 4.00000000e+00 4.00000000e+00 4.00000000e+00]

 [7.99360578e-15 8.00000000e+00 8.00000000e+00 1.60000000e+01

  1.20000000e+01 4.00000000e+00 4.00000000e+00 8.00000000e+00

  8.00000000e+00 8.00000000e+00 8.00000000e+00 4.00000000e+00

  1.20000000e+01 8.00000000e+00 1.20000000e+01 4.00000000e+00

  8.00000000e+00 8.00000000e+00 8.00000000e+00 1.20000000e+01

  8.00000000e+00 8.00000000e+00 8.00000000e+00 8.00000000e+00]

 [7.99360578e-15 6.00000000e+00 6.00000000e+00 1.20000000e+01

  1.60000000e+01 4.00000000e+00 4.00000000e+00 1.00000000e+01

  1.00000000e+01 1.00000000e+01 1.00000000e+01 6.00000000e+00

  1.00000000e+01 6.00000000e+00 1.00000000e+01 6.00000000e+00

  6.00000000e+00 6.00000000e+00 6.00000000e+00 8.00000000e+00

  1.20000000e+01 8.00000000e+00 1.00000000e+01 1.00000000e+01]

 [3.99680289e-15 2.00000000e+00 2.00000000e+00 4.00000000e+00

  4.00000000e+00 8.00000000e+00 1.11022302e-15 6.00000000e+00

  2.00000000e+00 6.00000000e+00 2.00000000e+00 2.00000000e+00

  6.00000000e+00 2.00000000e+00 6.00000000e+00 2.00000000e+00

  2.00000000e+00 6.00000000e+00 6.00000000e+00 4.00000000e+00

  4.00000000e+00 8.00000000e+00 6.00000000e+00 6.00000000e+00]

 [3.99680289e-15 2.00000000e+00 2.00000000e+00 4.00000000e+00

  4.00000000e+00 1.11022302e-15 8.00000000e+00 2.00000000e+00

  6.00000000e+00 2.00000000e+00 6.00000000e+00 2.00000000e+00

  6.00000000e+00 6.00000000e+00 6.00000000e+00 2.00000000e+00

  6.00000000e+00 2.00000000e+00 2.00000000e+00 4.00000000e+00

  4.00000000e+00 8.00000000e+00 6.00000000e+00 6.00000000e+00]

 [5.99520433e-15 2.00000000e+00 6.00000000e+00 8.00000000e+00

  1.00000000e+01 6.00000000e+00 2.00000000e+00 1.20000000e+01

  6.00000000e+00 4.00000000e+00 6.00000000e+00 6.00000000e+00

  1.00000000e+01 4.00000000e+00 6.00000000e+00 2.00000000e+00

  4.00000000e+00 6.00000000e+00 6.00000000e+00 6.00000000e+00

  8.00000000e+00 8.00000000e+00 6.00000000e+00 1.00000000e+01]

 [5.99520433e-15 2.00000000e+00 6.00000000e+00 8.00000000e+00

  1.00000000e+01 2.00000000e+00 6.00000000e+00 6.00000000e+00

  1.20000000e+01 6.00000000e+00 4.00000000e+00 6.00000000e+00

  6.00000000e+00 6.00000000e+00 1.00000000e+01 2.00000000e+00

  6.00000000e+00 4.00000000e+00 4.00000000e+00 6.00000000e+00

  8.00000000e+00 8.00000000e+00 1.00000000e+01 6.00000000e+00]

 [5.99520433e-15 6.00000000e+00 2.00000000e+00 8.00000000e+00

  1.00000000e+01 6.00000000e+00 2.00000000e+00 4.00000000e+00

  6.00000000e+00 1.20000000e+01 6.00000000e+00 2.00000000e+00

  6.00000000e+00 4.00000000e+00 1.00000000e+01 6.00000000e+00

  4.00000000e+00 6.00000000e+00 6.00000000e+00 6.00000000e+00

  8.00000000e+00 8.00000000e+00 1.00000000e+01 6.00000000e+00]

 [5.99520433e-15 6.00000000e+00 2.00000000e+00 8.00000000e+00

  1.00000000e+01 2.00000000e+00 6.00000000e+00 6.00000000e+00

  4.00000000e+00 6.00000000e+00 1.20000000e+01 2.00000000e+00

  1.00000000e+01 6.00000000e+00 6.00000000e+00 6.00000000e+00

  6.00000000e+00 4.00000000e+00 4.00000000e+00 6.00000000e+00

  8.00000000e+00 8.00000000e+00 6.00000000e+00 1.00000000e+01]

 [3.99680289e-15 2.00000000e+00 2.00000000e+00 4.00000000e+00

  6.00000000e+00 2.00000000e+00 2.00000000e+00 6.00000000e+00

  6.00000000e+00 2.00000000e+00 2.00000000e+00 8.00000000e+00

  4.00000000e+00 6.00000000e+00 4.00000000e+00 1.77635684e-15

  2.00000000e+00 6.00000000e+00 2.00000000e+00 6.00000000e+00

  8.00000000e+00 4.00000000e+00 6.00000000e+00 6.00000000e+00]

 [7.99360578e-15 6.00000000e+00 6.00000000e+00 1.20000000e+01

  1.00000000e+01 6.00000000e+00 6.00000000e+00 1.00000000e+01

  6.00000000e+00 6.00000000e+00 1.00000000e+01 4.00000000e+00

  1.60000000e+01 1.00000000e+01 8.00000000e+00 4.00000000e+00

  6.00000000e+00 6.00000000e+00 1.00000000e+01 1.00000000e+01

  8.00000000e+00 1.20000000e+01 1.00000000e+01 1.00000000e+01]

 [5.99520433e-15 6.00000000e+00 2.00000000e+00 8.00000000e+00

  6.00000000e+00 2.00000000e+00 6.00000000e+00 4.00000000e+00

  6.00000000e+00 4.00000000e+00 6.00000000e+00 6.00000000e+00

  1.00000000e+01 1.20000000e+01 6.00000000e+00 2.00000000e+00

  4.00000000e+00 6.00000000e+00 6.00000000e+00 1.00000000e+01

  8.00000000e+00 8.00000000e+00 1.00000000e+01 6.00000000e+00]

 [7.99360578e-15 6.00000000e+00 6.00000000e+00 1.20000000e+01

  1.00000000e+01 6.00000000e+00 6.00000000e+00 6.00000000e+00

  1.00000000e+01 1.00000000e+01 6.00000000e+00 4.00000000e+00

  8.00000000e+00 6.00000000e+00 1.60000000e+01 4.00000000e+00

  1.00000000e+01 1.00000000e+01 6.00000000e+00 1.00000000e+01

  8.00000000e+00 1.20000000e+01 1.00000000e+01 1.00000000e+01]

 [3.99680289e-15 2.00000000e+00 2.00000000e+00 4.00000000e+00

  6.00000000e+00 2.00000000e+00 2.00000000e+00 2.00000000e+00

  2.00000000e+00 6.00000000e+00 6.00000000e+00 1.77635684e-15

  4.00000000e+00 2.00000000e+00 4.00000000e+00 8.00000000e+00

  6.00000000e+00 2.00000000e+00 6.00000000e+00 6.00000000e+00

  8.00000000e+00 4.00000000e+00 6.00000000e+00 6.00000000e+00]

 [5.99520433e-15 2.00000000e+00 6.00000000e+00 8.00000000e+00

  6.00000000e+00 2.00000000e+00 6.00000000e+00 4.00000000e+00

  6.00000000e+00 4.00000000e+00 6.00000000e+00 2.00000000e+00

  6.00000000e+00 4.00000000e+00 1.00000000e+01 6.00000000e+00

  1.20000000e+01 6.00000000e+00 6.00000000e+00 1.00000000e+01

  8.00000000e+00 8.00000000e+00 6.00000000e+00 1.00000000e+01]

 [5.99520433e-15 6.00000000e+00 2.00000000e+00 8.00000000e+00

  6.00000000e+00 6.00000000e+00 2.00000000e+00 6.00000000e+00

  4.00000000e+00 6.00000000e+00 4.00000000e+00 6.00000000e+00

  6.00000000e+00 6.00000000e+00 1.00000000e+01 2.00000000e+00

  6.00000000e+00 1.20000000e+01 4.00000000e+00 1.00000000e+01

  8.00000000e+00 8.00000000e+00 6.00000000e+00 1.00000000e+01]

 [5.99520433e-15 2.00000000e+00 6.00000000e+00 8.00000000e+00

  6.00000000e+00 6.00000000e+00 2.00000000e+00 6.00000000e+00

  4.00000000e+00 6.00000000e+00 4.00000000e+00 2.00000000e+00

  1.00000000e+01 6.00000000e+00 6.00000000e+00 6.00000000e+00

  6.00000000e+00 4.00000000e+00 1.20000000e+01 1.00000000e+01

  8.00000000e+00 8.00000000e+00 1.00000000e+01 6.00000000e+00]

 [7.99360578e-15 6.00000000e+00 6.00000000e+00 1.20000000e+01

  8.00000000e+00 4.00000000e+00 4.00000000e+00 6.00000000e+00

  6.00000000e+00 6.00000000e+00 6.00000000e+00 6.00000000e+00

  1.00000000e+01 1.00000000e+01 1.00000000e+01 6.00000000e+00

  1.00000000e+01 1.00000000e+01 1.00000000e+01 1.60000000e+01

  1.20000000e+01 8.00000000e+00 1.00000000e+01 1.00000000e+01]

 [7.99360578e-15 4.00000000e+00 4.00000000e+00 8.00000000e+00

  1.20000000e+01 4.00000000e+00 4.00000000e+00 8.00000000e+00

  8.00000000e+00 8.00000000e+00 8.00000000e+00 8.00000000e+00

  8.00000000e+00 8.00000000e+00 8.00000000e+00 8.00000000e+00

  8.00000000e+00 8.00000000e+00 8.00000000e+00 1.20000000e+01

  1.60000000e+01 8.00000000e+00 1.20000000e+01 1.20000000e+01]

 [7.99360578e-15 4.00000000e+00 4.00000000e+00 8.00000000e+00

  8.00000000e+00 8.00000000e+00 8.00000000e+00 8.00000000e+00

  8.00000000e+00 8.00000000e+00 8.00000000e+00 4.00000000e+00

  1.20000000e+01 8.00000000e+00 1.20000000e+01 4.00000000e+00

  8.00000000e+00 8.00000000e+00 8.00000000e+00 8.00000000e+00

  8.00000000e+00 1.60000000e+01 1.20000000e+01 1.20000000e+01]

 [7.99360578e-15 4.00000000e+00 4.00000000e+00 8.00000000e+00

  1.00000000e+01 6.00000000e+00 6.00000000e+00 6.00000000e+00

  1.00000000e+01 1.00000000e+01 6.00000000e+00 6.00000000e+00

  1.00000000e+01 1.00000000e+01 1.00000000e+01 6.00000000e+00

  6.00000000e+00 6.00000000e+00 1.00000000e+01 1.00000000e+01

  1.20000000e+01 1.20000000e+01 1.60000000e+01 8.00000000e+00]

 [7.99360578e-15 4.00000000e+00 4.00000000e+00 8.00000000e+00

  1.00000000e+01 6.00000000e+00 6.00000000e+00 1.00000000e+01

  6.00000000e+00 6.00000000e+00 1.00000000e+01 6.00000000e+00

  1.00000000e+01 6.00000000e+00 1.00000000e+01 6.00000000e+00

  1.00000000e+01 1.00000000e+01 6.00000000e+00 1.00000000e+01

  1.20000000e+01 1.20000000e+01 8.00000000e+00 1.60000000e+01]])

https://travis-ci.com/github/Qiskit/qiskit-aer/jobs/342857594#L14782

Steps to reproduce the problem

  1. Install cvxpy 1.1.0
  2. Run tests

What is the expected behavior?

They pass

Suggested solutions

Find underlying cause of the failure and open a bug on cvxpy if necessary.

@mtreinish mtreinish added the bug Something isn't working label Jun 3, 2020
mtreinish added a commit to mtreinish/qiskit-aer that referenced this issue Jun 3, 2020
Version 1.1.0 of cvxpy was released yesterday and is causing tests to
fail. It's not clear if this is a bug in the noise transformation code
or in cvxpy. But until this is resolved (see Qiskit#779) this adds a version
cap to the dev requirements list to avoid the version which fails.
atilag pushed a commit that referenced this issue Jun 3, 2020
Version 1.1.0 of cvxpy was released yesterday and is causing tests to
fail. It's not clear if this is a bug in the noise transformation code
or in cvxpy. But until this is resolved (see #779) this adds a version
cap to the dev requirements list to avoid the version which fails.
@mtreinish mtreinish changed the title Noise transformation Noise transformation fails with the latest cvxpy version Jun 5, 2020
mtreinish added a commit to mtreinish/qiskit-aer that referenced this issue Jun 11, 2020
It looks like cvxpy 1.1.0 was just released with a regression which
caused the test failures. A day after 1.1.0 was released and Qiskit#780 was
merged in aer to cap cvxpy 1.1.1 was pushed out without any issues
or PRs opened or without any release notes published. Looking at the git
log there was 1 commit on top of 1.1.0 for the 1.1.1 release [1] which
looks releated to the error message we were seeing with 1.1.0. This
commit removes the version cap to try (and changes it to exclude 1.1.0
only) to see if 1.1.1 fixes our problem.

Potentially Fixes Qiskit#779

[1] cvxgrp/cvxpy@1ea3d67
@mtreinish
Copy link
Member Author

It looks like 1.1.1 did not fix the failure so we'll still have to keep the cap. It looks like other people are seeing this too: https://github.com/cvxgrp/cvxpy/issues/1051 so it's probably not an aer bug. But let's keep this open to track the cap

@SteveDiamond
Copy link

Would you like the cvxpy devs to look at this? My guess is there's an issue with mixed eigenvalues.

@mtreinish
Copy link
Member Author

@SteveDiamond yeah that would be great. I haven't found the time to dig into it myself

@gadial
Copy link
Collaborator

gadial commented Jul 14, 2020

I can simplify the problem a little. The following optimization fails because of non-DCP:

P = numpy.array([[ 8.  2.  6.  2.  6.  2.  6.  6.  6.  2.  6.  2.  2.  4.  4.  8.  6.  6.]
 [ 2. 12.  6.  4.  6.  6. 10.  4.  6.  2.  4.  6.  6.  6.  8.  8.  6. 10.]
 [ 6.  6. 12.  6.  4.  6.  6.  6. 10.  2.  6.  4.  4.  6.  8.  8. 10.  6.]
 [ 2.  4.  6. 12.  6.  2.  6.  4. 10.  6.  4.  6.  6.  6.  8.  8. 10.  6.]
 [ 6.  6.  4.  6. 12.  2. 10.  6.  6.  6.  6.  4.  4.  6.  8.  8.  6. 10.]
 [ 2.  6.  6.  2.  2.  8.  4.  6.  4.  0.  2.  6.  2.  6.  8.  4.  6.  6.]
 [ 6. 10.  6.  6. 10.  4. 16. 10.  8.  4.  6.  6. 10. 10.  8. 12. 10. 10.]
 [ 6.  4.  6.  4.  6.  6. 10. 12.  6.  2.  4.  6.  6. 10.  8.  8. 10.  6.]
 [ 6.  6. 10. 10.  6.  4.  8.  6. 16.  4. 10. 10.  6. 10.  8. 12. 10. 10.]
 [ 2.  2.  2.  6.  6.  0.  4.  2.  4.  8.  6.  2.  6.  6.  8.  4.  6.  6.]
 [ 6.  4.  6.  4.  6.  2.  6.  4. 10.  6. 12.  6.  6. 10.  8.  8.  6. 10.]
 [ 2.  6.  4.  6.  4.  6.  6.  6. 10.  2.  6. 12.  4. 10.  8.  8.  6. 10.]
 [ 2.  6.  4.  6.  4.  2. 10.  6.  6.  6.  6.  4. 12. 10.  8.  8. 10.  6.]
 [ 4.  6.  6.  6.  6.  6. 10. 10. 10.  6. 10. 10. 10. 16. 12.  8. 10. 10.]
 [ 4.  8.  8.  8.  8.  8.  8.  8.  8.  8.  8.  8.  8. 12. 16.  8. 12. 12.]
 [ 8.  8.  8.  8.  8.  4. 12.  8. 12.  4.  8.  8.  8.  8.  8. 16. 12. 12.]
 [ 6.  6. 10. 10.  6.  6. 10. 10. 10.  6.  6.  6. 10. 10. 12. 12. 16.  8.]
 [ 6. 10.  6.  6. 10.  6. 10.  6. 10.  6. 10. 10.  6. 10. 12. 12.  8. 16.]])
x = cvxpy.Variable(n)
prob = cvxpy.Problem(cvxpy.Minimize((1 / 2) * cvxpy.quad_form(x, P)))
prob.solve()

@gadial
Copy link
Collaborator

gadial commented Jul 14, 2020

Until we understand what's going on in CVXPY, I'm removing the test (in #832). I tried debugging my code but could not find any concrete problem with it.

@SteveDiamond
Copy link

SteveDiamond commented Jul 14, 2020

@gadial the problem solves fine with the master branch of cvxpy. I also pushed a new version with the fix.

@mtreinish mtreinish linked a pull request Jul 28, 2020 that will close this issue
mtreinish pushed a commit that referenced this issue Jul 28, 2020
Since the release of cvxpy 1.1.3 the issue reported in #779 which was caused the
Clifford-based transformations has been addressed. This commit removes the version
cap to enable the use of the latest versions of cvxpy again.

* Removing a test which crashes due to changes in CVXPY

* Style

* Return simplified test version

* Removed version pin
mtreinish added a commit to mtreinish/aqua that referenced this issue Jul 30, 2020
The bug in cvxpy 1.1.x that was breaking the aqua usage has been fixed
in the latest 1.1.3 release (see Qiskit/qiskit-aer#832 and
Qiskit/qiskit-aer#779 for more details). Since the bug is fixed we can
remove the version cap an enable newer versions of cvxpy to be
installed. Exclude rules are left on the setuptools extra requirement so
that end users don't accidently try to use a version known not to run.
manoelmarques added a commit to qiskit-community/qiskit-aqua that referenced this issue Jul 30, 2020
The bug in cvxpy 1.1.x that was breaking the aqua usage has been fixed
in the latest 1.1.3 release (see Qiskit/qiskit-aer#832 and
Qiskit/qiskit-aer#779 for more details). Since the bug is fixed we can
remove the version cap an enable newer versions of cvxpy to be
installed. Exclude rules are left on the setuptools extra requirement so
that end users don't accidently try to use a version known not to run.

Co-authored-by: Manoel Marques <manoelmrqs@gmail.com>
pbark pushed a commit to pbark/qiskit-aqua that referenced this issue Sep 16, 2020
The bug in cvxpy 1.1.x that was breaking the aqua usage has been fixed
in the latest 1.1.3 release (see Qiskit/qiskit-aer#832 and
Qiskit/qiskit-aer#779 for more details). Since the bug is fixed we can
remove the version cap an enable newer versions of cvxpy to be
installed. Exclude rules are left on the setuptools extra requirement so
that end users don't accidently try to use a version known not to run.

Co-authored-by: Manoel Marques <manoelmrqs@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants