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

Multiprecision and Python 3.11 support for SDPA #2097

Merged
merged 9 commits into from Jun 17, 2023
Merged

Multiprecision and Python 3.11 support for SDPA #2097

merged 9 commits into from Jun 17, 2023

Conversation

usamamuneeb
Copy link
Contributor

Description

SDPA for Python now supports SDPA Multiprecision, a fork of SDPA-GMP. This change will test the multiprecision backend and Python 3.11 wheels in the CI pipeline.

SDPA with OpenBLAS backend does not pass LP5 test on the Windows runners, so I changed install_dependencies.sh to use the multiprecision backend on Windows and the regular (OpenBLAS) backend on Linux and macOS.

Type of change

  • New feature (backwards compatible)
  • New feature (breaking API changes)
  • Bug fix
  • Other (Documentation, CI, ...)

Contribution checklist

  • Add our license to new files.
  • Check that your code adheres to our coding style.
  • Write unittests.
  • Run the unittests and check that they’re passing.
  • Run the benchmarks to make sure your change doesn’t introduce a regression.

This should be handled internally by SDPA for Python, and as of version 0.2, it takes care of it.
@github-actions
Copy link

github-actions bot commented Apr 5, 2023

Benchmarks that have stayed the same:

   before           after         ratio
 [4f3799d6]       [5de91523]
      29.5±0s          30.0±0s     1.01  cvar_benchmark.CVaRBenchmark.time_compile_problem
      1.80±0s          1.81±0s     1.01  simple_LP_benchmarks.SimpleScalarParametrizedLPBenchmark.time_compile_problem
      24.0±0s          24.1±0s     1.00  simple_LP_benchmarks.SimpleLPBenchmark.time_compile_problem
      9.50±0s          9.53±0s     1.00  huber_regression.HuberRegression.time_compile_problem
      8.72±0s          8.74±0s     1.00  semidefinite_programming.SemidefiniteProgramming.time_compile_problem
      46.0±0s          46.1±0s     1.00  sdp_segfault_1132_benchmark.SDPSegfault1132Benchmark.time_compile_problem
      3.89±0s          3.89±0s     1.00  simple_LP_benchmarks.SimpleFullyParametrizedLPBenchmark.time_compile_problem
      7.35±0s          7.34±0s     1.00  optimal_advertising.OptimalAdvertising.time_compile_problem
      11.2±0s          11.2±0s     1.00  svm_l1_regularization.SVMWithL1Regularization.time_compile_problem

@rileyjmurray
Copy link
Collaborator

rileyjmurray commented Apr 5, 2023 via email

@rileyjmurray
Copy link
Collaborator

@usamamuneeb tests are failing because of unrelated issues with COPT.

Can you please update our web documentation to mention these changes? You'll want to update the solver install guide and the material about choosing solver settings.

It would be nice to add a dedicated test that showcases the accuracy guarantees of SDPA-multiprecision. You can have a test under TestSDPA that only runs if multiprecision support is available. I don't know exactly what test problem you'd use here. It would be okay to define a new problem specifically for this purpose.

One possibility is to have a basic LP/SDP where some variable has optimal value sqrt(2). Using double-precision arithmetic, an IPM should only be able to compute a solution to accuracy 1e-8 or so. With multiprecision support, you can ask for a solution accurate to 1e-16. I don't think you can ask for a solution with accuracy better than 1e-16 since CVXPY will probably convert to double-precision somewhere in its rewriting process. (It would be good to check if that happens and to document it if so.)

@usamamuneeb
Copy link
Contributor Author

Hi @rileyjmurray, I will go over the SDPA-GMP paper to select some problems which show the benefit of using the multiprecision variant. If I recall correctly, besides a more accurate solution, multiprecision version also has a secondary benefit in sense that it can solve some ill posed problems in SDPLIB that the regular SDPA package cannot.

As test cases, I will try to select some problems to demonstrate each of these benefits.

@rileyjmurray
Copy link
Collaborator

Hi @usamamuneeb. Thanks for adding the new test problem!

I think we should wrap test_lp_7 with a check that we're using SDPA-GMP, not just SDPA.

I suggest you add an enumeration like SDPA_Variants with values Standard and GMP. Then have SDPA.variant be a class property that returns Standard by default or GMP if appropriate to do so. If you make other versions of SDPA-Python in the future, then you can extend the SDPA_Variants enumeration and update the implementation of SDPA.variant accordingly.

@usamamuneeb
Copy link
Contributor Author

Hi @rileyjmurray, just made the change. LP7 will now run only if GMP support is available.

In the next release of sdpa-python and sdpa-multiprecision, I can create an alias for sdpap.sdpacall.sdpacall.get_backend_info() to simplify it to sdpap.get_backend_info(). That might act as a suitable replacement for the enumeration.

Copy link
Collaborator

@rileyjmurray rileyjmurray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved! @phschiele @SteveDiamond can one of you review? It's a little ambiguous as to whether this is changing the public API, but regardless it would be good to get more eyes on it.

Copy link
Collaborator

@SteveDiamond SteveDiamond left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@phschiele phschiele left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@usamamuneeb Great feature, thanks a lot. LGTM

@rileyjmurray rileyjmurray merged commit 7a034ac into cvxpy:master Jun 17, 2023
50 checks passed
@phschiele phschiele mentioned this pull request Jun 22, 2023
@phschiele phschiele mentioned this pull request Jul 29, 2023
@Paulnkk Paulnkk mentioned this pull request Aug 1, 2023
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.

None yet

4 participants