-
Notifications
You must be signed in to change notification settings - Fork 40
Add option to choose Proximal inversion method #2031
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
base: master
Are you sure you want to change the base?
Conversation
Memory benchmark result| Test Name | %Δ | Master (MB) | PR (MB) | Δ (MB) | Time PR (s) | Time Master (s) |
| -------------------------------------- | ------------ | ------------------ | ------------------ | ------------ | ------------------ | ------------------ |
test_objective_jac_w7x | 4.32 % | 3.890e+03 | 4.058e+03 | 168.16 | 38.89 | 35.94 |
test_proximal_jac_w7x_with_eq_update | -0.08 % | 6.480e+03 | 6.475e+03 | -4.94 | 148.11 | 161.57 |
test_proximal_freeb_jac | -0.40 % | 1.320e+04 | 1.315e+04 | -52.20 | 83.11 | 83.32 |
test_proximal_freeb_jac_blocked | 0.31 % | 7.474e+03 | 7.498e+03 | 23.32 | 71.89 | 72.39 |
test_proximal_freeb_jac_batched | -0.59 % | 7.449e+03 | 7.406e+03 | -43.65 | 71.78 | 72.41 |
test_proximal_jac_ripple | -2.01 % | 3.515e+03 | 3.445e+03 | -70.55 | 61.67 | 64.49 |
test_proximal_jac_ripple_bounce1d | -5.34 % | 3.660e+03 | 3.465e+03 | -195.51 | 72.51 | 75.12 |
test_eq_solve | -3.40 % | 2.050e+03 | 1.980e+03 | -69.62 | 94.08 | 93.58 |For the memory plots, go to the summary of |
| eq.solve(verbose=3) | ||
|
|
||
| eq1 = run_qh_step(0, eq) | ||
| eq1 = run_qh_step(2, eq) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should check the notebooks to see if anything is changed with this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this test doesn't work with the new option that suggests that there may be something wrong. We should figure out what the actual issue is rather than changing the test.
(note that this is such low resolution that it would already converge without the fourier continuation, but we want to test that part as well)
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2031 +/- ##
==========================================
- Coverage 95.75% 95.75% -0.01%
==========================================
Files 102 102
Lines 28344 28356 +12
==========================================
+ Hits 27142 27152 +10
- Misses 1202 1204 +2
🚀 New features to boost your workflow:
|
| benchmark_name | dt(%) | dt(s) | t_new(s) | t_old(s) |
| -------------------------------------- | ---------------------- | ---------------------- | ---------------------- | ---------------------- |
test_build_transform_fft_midres | +0.77 +/- 4.79 | +6.28e-03 +/- 3.90e-02 | 8.21e-01 +/- 2.7e-02 | 8.15e-01 +/- 2.8e-02 |
test_build_transform_fft_highres | -0.20 +/- 2.04 | -2.11e-03 +/- 2.21e-02 | 1.08e+00 +/- 1.4e-02 | 1.08e+00 +/- 1.7e-02 |
test_equilibrium_init_lowres | -1.89 +/- 2.98 | -1.09e-01 +/- 1.72e-01 | 5.66e+00 +/- 1.1e-01 | 5.77e+00 +/- 1.3e-01 |
+test_objective_compile_atf | -4.79 +/- 1.11 | -3.81e-01 +/- 8.84e-02 | 7.57e+00 +/- 6.3e-02 | 7.96e+00 +/- 6.2e-02 |
test_objective_compute_atf | -7.79 +/- 10.91 | -1.75e-04 +/- 2.45e-04 | 2.07e-03 +/- 1.9e-04 | 2.25e-03 +/- 1.6e-04 |
test_objective_jac_atf | +0.09 +/- 3.15 | +1.55e-03 +/- 5.45e-02 | 1.73e+00 +/- 2.9e-02 | 1.73e+00 +/- 4.6e-02 |
test_perturb_1 | +2.57 +/- 1.64 | +3.76e-01 +/- 2.39e-01 | 1.50e+01 +/- 6.0e-02 | 1.46e+01 +/- 2.3e-01 |
+test_proximal_jac_atf | -37.05 +/- 1.16 | -1.99e+00 +/- 6.22e-02 | 3.38e+00 +/- 5.4e-02 | 5.36e+00 +/- 3.0e-02 |
test_proximal_freeb_compute | +1.28 +/- 3.60 | +2.03e-03 +/- 5.68e-03 | 1.60e-01 +/- 4.6e-03 | 1.58e-01 +/- 3.3e-03 |
test_solve_fixed_iter | +2.16 +/- 3.27 | +5.97e-01 +/- 9.03e-01 | 2.82e+01 +/- 6.3e-01 | 2.76e+01 +/- 6.5e-01 |
test_objective_compute_ripple | +2.36 +/- 3.02 | +4.81e-03 +/- 6.16e-03 | 2.09e-01 +/- 3.3e-03 | 2.04e-01 +/- 5.2e-03 |
test_objective_grad_ripple | -4.18 +/- 3.22 | -3.71e-02 +/- 2.86e-02 | 8.52e-01 +/- 1.9e-02 | 8.89e-01 +/- 2.1e-02 |
test_build_transform_fft_lowres | -0.17 +/- 2.91 | -1.27e-03 +/- 2.15e-02 | 7.37e-01 +/- 2.0e-02 | 7.38e-01 +/- 6.5e-03 |
test_equilibrium_init_medres | -0.08 +/- 0.95 | -4.85e-03 +/- 5.75e-02 | 6.03e+00 +/- 4.7e-02 | 6.03e+00 +/- 3.3e-02 |
test_equilibrium_init_highres | -1.35 +/- 0.88 | -9.21e-02 +/- 6.04e-02 | 6.75e+00 +/- 4.2e-02 | 6.84e+00 +/- 4.4e-02 |
test_objective_compile_dshape_current | -0.59 +/- 6.18 | -2.42e-02 +/- 2.53e-01 | 4.06e+00 +/- 2.2e-01 | 4.09e+00 +/- 1.2e-01 |
test_objective_compute_dshape_current | +4.04 +/- 13.68 | +2.90e-05 +/- 9.79e-05 | 7.45e-04 +/- 9.1e-05 | 7.16e-04 +/- 3.6e-05 |
test_objective_jac_dshape_current | -2.07 +/- 15.93 | -5.43e-04 +/- 4.18e-03 | 2.57e-02 +/- 3.5e-03 | 2.63e-02 +/- 2.3e-03 |
test_perturb_2 | +0.05 +/- 1.49 | +9.82e-03 +/- 2.69e-01 | 1.81e+01 +/- 2.3e-01 | 1.81e+01 +/- 1.3e-01 |
+test_proximal_jac_atf_with_eq_update | -8.81 +/- 0.85 | -1.17e+00 +/- 1.13e-01 | 1.21e+01 +/- 9.5e-02 | 1.33e+01 +/- 6.1e-02 |
test_proximal_freeb_jac | -0.47 +/- 2.49 | -2.30e-02 +/- 1.21e-01 | 4.86e+00 +/- 5.6e-02 | 4.88e+00 +/- 1.1e-01 |
test_solve_fixed_iter_compiled | +0.90 +/- 1.70 | +7.06e-02 +/- 1.34e-01 | 7.95e+00 +/- 5.8e-02 | 7.88e+00 +/- 1.2e-01 |
test_LinearConstraintProjection_build | -0.65 +/- 2.03 | -5.47e-02 +/- 1.70e-01 | 8.34e+00 +/- 9.2e-02 | 8.39e+00 +/- 1.4e-01 |
test_objective_compute_ripple_bounce1d | -2.31 +/- 2.73 | -6.88e-03 +/- 8.14e-03 | 2.91e-01 +/- 6.7e-03 | 2.98e-01 +/- 4.6e-03 |
test_objective_grad_ripple_bounce1d | -2.48 +/- 2.43 | -2.37e-02 +/- 2.33e-02 | 9.34e-01 +/- 1.9e-02 | 9.57e-01 +/- 1.3e-02 |Github CI performance can be noisy. When evaluating the benchmarks, developers should take this into account. |
|
If people are ok with the changes, I will update the notebooks. Given the single step works just fine, maybe we can make the advanced optimization notebook a single step? |
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
| if wrapper is not None and wrapper.lower() in ["prox", "proximal"]: | ||
| perturb_options = options.pop("perturb_options", {}) | ||
| solve_options = options.pop("solve_options", {}) | ||
| inv_method = options.pop("prox_inv_method", "qr") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to see more testing on a wide class of problems before we change the default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed, I will try it on some trickier free boundary problems I have
| eq.solve(verbose=3) | ||
|
|
||
| eq1 = run_qh_step(0, eq) | ||
| eq1 = run_qh_step(2, eq) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this test doesn't work with the new option that suggests that there may be something wrong. We should figure out what the actual issue is rather than changing the test.
(note that this is such low resolution that it would already converge without the fourier continuation, but we want to test that part as well)
|
|
||
| - Adds new option for ``loss_function``, ``"sum"``, which changes an objective to target the sum of the values computed. | ||
| - Adds ``"scipy-l-bfgs-b"`` optimizer option as a wrapper to scipy's ``"l-bfgs-b"`` method. | ||
| - Adds ``prox_inv_method`` option to be used in equilibrium constrained optimization problems. ``prox_inv_method`` can be ``qr``, ``svd`` or ``svd-reg``. ``svd-reg`` is the legacy behaviour which had an unnecessary regularization term. The new default is ``qr`` which is faster than ``svd`` without loss of significant accuracy. Note that this may change the results of the optimization scripts. For number of example cases, it is been seen that the new default facilitates the optimization without continuation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these example cases are super low res, so I wouldn't take that as representative of the true behavior
| uf, sf, vtf = jnp.linalg.svd(Fxh, full_matrices=False) | ||
| sfi = jnp.where(sf < cutoff * sf[0], 0, 1 / sf) | ||
| return vtf.T @ (sfi * (uf.T @ Fc)) | ||
| elif inv_method == "svd-reg": # this option will be deleted |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why the comment on deleting the option?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was planning to remove it, but I will keep it at least for foreseable future
Adds new options to use during the computation of projected tangents. The operation is used to solve:
svd: just computes SVD ofsvd-reg: to reproduce the old behavior, adds the smallest eigenvalue to all eigenvalues as regularizationqr: uses QR to solve the system (default)Resolves #2000