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

Update trust_region_step_exact_qr #1363

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open

Update trust_region_step_exact_qr #1363

wants to merge 24 commits into from

Conversation

YigitElma
Copy link
Collaborator

@YigitElma YigitElma commented Nov 13, 2024

  • Updates the initial guess for $\alpha$ to be 0 instead of 0.001* $\alpha$ _upper. I found out that the solution of $\alpha$ is usually pretty small. This reduces the total amount of QR's in the while loop.
  • Removes the last QR outside the while loop of trust_region_step_exact_qr. The loop condition already satisfies the step norm to be around trust radius.

Misc

  • Adds execute_on_cpu flag to desc.examples.get

@YigitElma YigitElma added performance New feature or request to make the code faster enhancement General label for enhancement. Please also tag with "Speed", "Interface", "Functionality", etc labels Nov 13, 2024
@YigitElma YigitElma self-assigned this Nov 13, 2024
Copy link
Contributor

github-actions bot commented Nov 13, 2024

|             benchmark_name             |         dt(%)          |         dt(s)          |        t_new(s)        |        t_old(s)        | 
| -------------------------------------- | ---------------------- | ---------------------- | ---------------------- | ---------------------- |
 test_build_transform_fft_midres         |     +3.04 +/- 6.85     | +1.86e-02 +/- 4.19e-02 |  6.30e-01 +/- 3.2e-02  |  6.12e-01 +/- 2.7e-02  |
 test_build_transform_fft_highres        |     -0.39 +/- 4.57     | -3.86e-03 +/- 4.48e-02 |  9.77e-01 +/- 3.7e-02  |  9.81e-01 +/- 2.5e-02  |
 test_equilibrium_init_lowres            |     -2.36 +/- 5.24     | -9.64e-02 +/- 2.14e-01 |  3.98e+00 +/- 1.3e-01  |  4.08e+00 +/- 1.7e-01  |
 test_objective_compile_atf              |     -2.47 +/- 3.60     | -2.01e-01 +/- 2.93e-01 |  7.94e+00 +/- 1.6e-01  |  8.14e+00 +/- 2.5e-01  |
 test_objective_compute_atf              |     +2.54 +/- 4.85     | +2.68e-04 +/- 5.11e-04 |  1.08e-02 +/- 4.2e-04  |  1.05e-02 +/- 2.9e-04  |
 test_objective_jac_atf                  |     +0.93 +/- 2.62     | +1.82e-02 +/- 5.16e-02 |  1.99e+00 +/- 3.2e-02  |  1.97e+00 +/- 4.1e-02  |
 test_perturb_1                          |     -0.09 +/- 2.65     | -1.31e-02 +/- 3.87e-01 |  1.46e+01 +/- 2.6e-01  |  1.46e+01 +/- 2.9e-01  |
 test_proximal_jac_atf                   |     -0.72 +/- 1.74     | -5.93e-02 +/- 1.43e-01 |  8.15e+00 +/- 7.0e-02  |  8.21e+00 +/- 1.3e-01  |
 test_proximal_freeb_compute             |     -2.74 +/- 1.46     | -5.49e-03 +/- 2.92e-03 |  1.95e-01 +/- 9.8e-04  |  2.00e-01 +/- 2.8e-03  |
 test_build_transform_fft_lowres         |     +5.08 +/- 3.92     | +2.69e-02 +/- 2.07e-02 |  5.56e-01 +/- 1.6e-02  |  5.29e-01 +/- 1.3e-02  |
 test_equilibrium_init_medres            |     -0.80 +/- 4.40     | -3.39e-02 +/- 1.86e-01 |  4.19e+00 +/- 1.1e-01  |  4.22e+00 +/- 1.5e-01  |
 test_equilibrium_init_highres           |     -1.41 +/- 3.35     | -7.95e-02 +/- 1.89e-01 |  5.57e+00 +/- 1.2e-01  |  5.65e+00 +/- 1.5e-01  |
 test_objective_compile_dshape_current   |     +1.17 +/- 3.08     | +4.57e-02 +/- 1.20e-01 |  3.94e+00 +/- 1.1e-01  |  3.89e+00 +/- 4.3e-02  |
 test_objective_compute_dshape_current   |     -1.12 +/- 1.45     | -4.08e-05 +/- 5.28e-05 |  3.60e-03 +/- 2.9e-05  |  3.64e-03 +/- 4.4e-05  |
 test_objective_jac_dshape_current       |     +0.34 +/- 11.75    | +1.44e-04 +/- 4.91e-03 |  4.19e-02 +/- 4.5e-03  |  4.18e-02 +/- 1.9e-03  |
 test_perturb_2                          |     +0.55 +/- 1.83     | +1.05e-01 +/- 3.48e-01 |  1.92e+01 +/- 3.3e-01  |  1.91e+01 +/- 1.1e-01  |
 test_proximal_freeb_jac                 |     +0.85 +/- 1.74     | +6.43e-02 +/- 1.31e-01 |  7.63e+00 +/- 1.1e-01  |  7.57e+00 +/- 6.4e-02  |
 test_solve_fixed_iter                   |    -23.20 +/- 68.55    | -1.18e+00 +/- 3.49e+00 |  3.91e+00 +/- 2.7e+00  |  5.09e+00 +/- 2.2e+00  |

@f0uriest
Copy link
Member

isn't this the same as the cho option but using LU instead of cholesky?

@YigitElma
Copy link
Collaborator Author

YigitElma commented Nov 13, 2024

isn't this the same as the cho option but using LU instead of cholesky?

Yes, pretty similar. jax.scipy.linlag.solve with symmetric A should call LAPACK ?sysv (docs), and it is something like LU. For finding alpha, I used Secant method.

Cholesky is also really fast (maybe faster than this one), but maybe this is more accurate, that's why I wanted to test it. If I remember correctly the problem with Cholesky was the accuracy.

@f0uriest
Copy link
Member

Generally the innaccuracy comes from explitly forming J^T J when J is poorly conditioned, so I don't think you'll see any major improvements with this. Also cholesky should be faster.

@dpanici
Copy link
Collaborator

dpanici commented Nov 20, 2024

run on multiple threads

Copy link

codecov bot commented Nov 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.56%. Comparing base (2741269) to head (3c3dadc).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1363      +/-   ##
==========================================
- Coverage   95.57%   95.56%   -0.01%     
==========================================
  Files          96       96              
  Lines       24405    24406       +1     
==========================================
- Hits        23325    23324       -1     
- Misses       1080     1082       +2     
Files with missing lines Coverage Δ
desc/examples/__init__.py 100.00% <100.00%> (ø)
desc/optimize/tr_subproblems.py 99.44% <100.00%> (-0.01%) ⬇️

... and 1 file with indirect coverage changes

@YigitElma YigitElma added the skip_changelog No need to update changelog on this PR label Nov 25, 2024
@YigitElma YigitElma changed the title Add new trust region subproblem solver Update trust_region _exact_qr Nov 25, 2024
@YigitElma YigitElma changed the title Update trust_region _exact_qr Update trust_region_step_exact_qr Nov 25, 2024
@YigitElma YigitElma removed the enhancement General label for enhancement. Please also tag with "Speed", "Interface", "Functionality", etc label Nov 25, 2024
@YigitElma YigitElma marked this pull request as ready for review November 27, 2024 06:38
@dpanici dpanici requested review from a team, rahulgaur104, f0uriest, ddudt, dpanici, kianorr, sinaatalay and unalmis and removed request for a team November 27, 2024 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance New feature or request to make the code faster skip_changelog No need to update changelog on this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants