Switch compute from recursive to looped#1557
Conversation
| benchmark_name | dt(%) | dt(s) | t_new(s) | t_old(s) |
| -------------------------------------- | ---------------------- | ---------------------- | ---------------------- | ---------------------- |
test_build_transform_fft_lowres | -0.34 +/- 3.49 | -2.92e-03 +/- 2.96e-02 | 8.46e-01 +/- 2.1e-02 | 8.49e-01 +/- 2.1e-02 |
test_equilibrium_init_medres | -1.29 +/- 3.98 | -8.88e-02 +/- 2.74e-01 | 6.79e+00 +/- 2.0e-01 | 6.88e+00 +/- 1.9e-01 |
test_equilibrium_init_highres | -4.75 +/- 5.67 | -3.77e-01 +/- 4.50e-01 | 7.56e+00 +/- 1.5e-01 | 7.94e+00 +/- 4.2e-01 |
test_objective_compile_dshape_current | -1.11 +/- 2.61 | -4.69e-02 +/- 1.10e-01 | 4.16e+00 +/- 9.1e-02 | 4.21e+00 +/- 6.1e-02 |
test_objective_compute_dshape_current | +1.92 +/- 14.08 | +1.44e-05 +/- 1.06e-04 | 7.67e-04 +/- 7.9e-05 | 7.52e-04 +/- 7.1e-05 |
test_objective_jac_dshape_current | -4.12 +/- 17.23 | -9.76e-04 +/- 4.08e-03 | 2.27e-02 +/- 2.3e-03 | 2.37e-02 +/- 3.3e-03 |
test_perturb_2 | -3.64 +/- 2.32 | -7.35e-01 +/- 4.68e-01 | 1.94e+01 +/- 3.1e-01 | 2.02e+01 +/- 3.5e-01 |
test_proximal_jac_atf_with_eq_update | -0.17 +/- 1.14 | -2.00e-02 +/- 1.37e-01 | 1.19e+01 +/- 1.3e-01 | 1.20e+01 +/- 4.9e-02 |
test_proximal_freeb_jac | -0.06 +/- 3.04 | -2.95e-03 +/- 1.45e-01 | 4.76e+00 +/- 1.2e-01 | 4.77e+00 +/- 8.4e-02 |
test_solve_fixed_iter_compiled | +1.24 +/- 2.91 | +7.81e-02 +/- 1.83e-01 | 6.38e+00 +/- 1.1e-01 | 6.30e+00 +/- 1.5e-01 |
test_LinearConstraintProjection_build | -3.22 +/- 3.13 | -2.25e-01 +/- 2.18e-01 | 6.76e+00 +/- 1.4e-01 | 6.98e+00 +/- 1.7e-01 |
test_objective_compute_ripple_bounce1d | -1.05 +/- 2.55 | -3.20e-03 +/- 7.74e-03 | 3.01e-01 +/- 6.9e-03 | 3.04e-01 +/- 3.6e-03 |
test_objective_grad_ripple_bounce1d | +0.59 +/- 2.21 | +5.49e-03 +/- 2.05e-02 | 9.33e-01 +/- 1.8e-02 | 9.27e-01 +/- 1.0e-02 |
test_build_transform_fft_midres | -3.12 +/- 3.88 | -2.91e-02 +/- 3.61e-02 | 9.02e-01 +/- 1.9e-02 | 9.31e-01 +/- 3.1e-02 |
test_build_transform_fft_highres | -2.06 +/- 3.00 | -2.50e-02 +/- 3.64e-02 | 1.19e+00 +/- 2.5e-02 | 1.21e+00 +/- 2.7e-02 |
test_equilibrium_init_lowres | -2.32 +/- 3.23 | -1.59e-01 +/- 2.20e-01 | 6.67e+00 +/- 1.4e-01 | 6.83e+00 +/- 1.7e-01 |
test_objective_compile_atf | +0.23 +/- 4.25 | +1.50e-02 +/- 2.73e-01 | 6.44e+00 +/- 1.9e-01 | 6.42e+00 +/- 2.0e-01 |
test_objective_compute_atf | +16.61 +/- 11.24 | +3.46e-04 +/- 2.34e-04 | 2.43e-03 +/- 2.0e-04 | 2.08e-03 +/- 1.2e-04 |
test_objective_jac_atf | -2.97 +/- 4.93 | -4.95e-02 +/- 8.22e-02 | 1.62e+00 +/- 5.6e-02 | 1.67e+00 +/- 6.0e-02 |
test_perturb_1 | +2.90 +/- 7.05 | +4.79e-01 +/- 1.16e+00 | 1.70e+01 +/- 1.1e+00 | 1.65e+01 +/- 2.1e-01 |
test_proximal_jac_atf | +0.89 +/- 1.61 | +4.75e-02 +/- 8.57e-02 | 5.38e+00 +/- 8.1e-02 | 5.33e+00 +/- 2.8e-02 |
test_proximal_freeb_compute | +3.05 +/- 2.68 | +5.16e-03 +/- 4.54e-03 | 1.75e-01 +/- 3.1e-03 | 1.70e-01 +/- 3.3e-03 |
test_solve_fixed_iter | +2.19 +/- 3.38 | +5.51e-01 +/- 8.51e-01 | 2.58e+01 +/- 7.7e-01 | 2.52e+01 +/- 3.6e-01 |
test_objective_compute_ripple | +0.41 +/- 5.34 | +9.81e-04 +/- 1.28e-02 | 2.41e-01 +/- 1.1e-02 | 2.40e-01 +/- 6.5e-03 |
test_objective_grad_ripple | +1.86 +/- 2.61 | +1.65e-02 +/- 2.31e-02 | 9.02e-01 +/- 1.6e-02 | 8.86e-01 +/- 1.7e-02 |Github CI performance can be noisy. When evaluating the benchmarks, developers should take this into account. |
|
The logic should take into account that a given data may make certain sub dependencies obselete |
… always have these keys in, some clean up
| Type of object to compute for, eg Equilibrium, Curve, etc. | ||
| names : str or array-like of str | ||
| Name(s) of the quantity(s) to compute. | ||
| deps : set[str] |
There was a problem hiding this comment.
Previously this function was recursive, so this deps was needed but not anymore
|
|
||
| def _get_derivs_1_key(key): | ||
| if has_axis: | ||
| if "full_with_axis_dependencies" in data_index[p][key]: |
There was a problem hiding this comment.
We used to call this function in _build_data_index, but now data_index is already built when we call this function
Memory benchmark result| Test Name | %Δ | Master (MB) | PR (MB) | Δ (MB) | Time PR (s) | Time Master (s) |
| -------------------------------------- | ------------ | ------------------ | ------------------ | ------------ | ------------------ | ------------------ |
test_objective_jac_w7x | 3.10 % | 3.941e+03 | 4.064e+03 | 122.30 | 33.36 | 30.45 |
test_proximal_jac_w7x_with_eq_update | -1.61 % | 6.634e+03 | 6.527e+03 | -106.80 | 153.60 | 159.59 |
test_proximal_freeb_jac | -0.01 % | 1.337e+04 | 1.337e+04 | -1.38 | 81.35 | 81.44 |
test_proximal_freeb_jac_blocked | 0.33 % | 7.676e+03 | 7.701e+03 | 25.57 | 70.81 | 71.92 |
test_proximal_freeb_jac_batched | -0.17 % | 7.664e+03 | 7.651e+03 | -12.80 | 71.61 | 71.63 |
test_proximal_jac_ripple | -0.18 % | 3.516e+03 | 3.510e+03 | -6.34 | 55.37 | 54.86 |
test_proximal_jac_ripple_bounce1d | -1.01 % | 3.784e+03 | 3.745e+03 | -38.38 | 70.96 | 69.04 |
test_eq_solve | 2.01 % | 1.924e+03 | 1.963e+03 | 38.77 | 61.42 | 59.92 |For the memory plots, go to the summary of |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1557 +/- ##
==========================================
+ Coverage 94.32% 94.38% +0.05%
==========================================
Files 101 101
Lines 28866 28829 -37
==========================================
- Hits 27228 27209 -19
+ Misses 1638 1620 -18
🚀 New features to boost your workflow:
|
|
I am not sure if this PR is necessary, given that there is no performance difference. I guess it is cleaner than before, anyway it is ready for review. |
 - Adds FFT grids and field aligned grids to `test_compute_everything`. Should be merged before stuff that changes grids #2053 or stuff that changes how the dependencies are ordered/selected for computation #1557 to ensure they do not cause bugs in the computations. - Deletes a bunch of files that are now not necessary and removes bounce objective docstring boilerplate - uses `nondiff_argnums` instead of `nondiff_argnames` so that the code works on old jax versions - Adds comments to explain per bounce_comments PR - Resolves #2162 . --------- Co-authored-by: Rory Conlin <mail@fouriest.net> Co-authored-by: Dario Panici <37969854+dpanici@users.noreply.github.com>
ddudt
left a comment
There was a problem hiding this comment.
need to fix the failing test, otherwise this looks good
Btw, I cannot recreate the failing test locally. |
|
|
@f0uriest let me know if you approve, since you opened the PR, I can approve for you |
| @pytest.mark.optimize | ||
| def test_constrained_AL_lsq(): | ||
| """Tests that the least squares augmented Lagrangian optimizer does something.""" | ||
| # Note: This test is known to be sensitive to small numerical differences |
There was a problem hiding this comment.
Related comment about this test
#2247 (comment)
|
@dpanici can you check this once you have some time? |
This PR builds upon #2156
_computenow uses a for loop instead of recursion_get_depsto consider given dataResolves #1336