Skip to content

Add deprecated signature support for Bounce.batch - #2354

Open
unalmis wants to merge 6 commits into
masterfrom
unalmis-patch-1
Open

unalmis wants to merge 6 commits into
masterfrom
unalmis-patch-1

Conversation

@unalmis

@unalmis unalmis commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator

Added a wrapper to support deprecated signatures for the Bounce.batch method more completely.

The two files are copy pasted from #2215 and the changes are required for

Added a wrapper to support deprecated signatures for the Bounce.batch method more completely.

This is taken from #2215 and the changes are required for #2215 quantities like available energy to be computable as well as #2257
@unalmis unalmis added the skip_changelog No need to update changelog on this PR label Oct 11, 2026
@github-actions

github-actions Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Memory benchmark result

|               Test Name                |      %Δ      |    Master (MB)     |      PR (MB)       |    Δ (MB)    |    Time PR (s)     |  Time Master (s)   |
| -------------------------------------- | ------------ | ------------------ | ------------------ | ------------ | ------------------ | ------------------ |
  test_objective_jac_w7x                 |    0.05 %    |     4.344e+03      |     4.346e+03      |     2.09     |       31.09        |       28.32        |
  test_proximal_jac_w7x_with_eq_update   |    0.19 %    |     6.608e+03      |     6.621e+03      |    12.82     |       144.69       |       142.53       |
  test_proximal_freeb_jac                |   -0.52 %    |     1.359e+04      |     1.352e+04      |    -70.45    |       73.93        |       75.92        |
  test_proximal_freeb_jac_blocked        |    0.29 %    |     7.841e+03      |     7.864e+03      |    22.75     |       67.54        |       66.06        |
  test_proximal_freeb_jac_batched        |   -0.27 %    |     7.873e+03      |     7.852e+03      |    -21.27    |       66.02        |       65.71        |
  test_proximal_jac_ripple               |   -2.37 %    |     3.719e+03      |     3.631e+03      |    -88.14    |       50.18        |       50.31        |
  test_eq_solve                          |   -0.63 %    |     1.819e+03      |     1.808e+03      |    -11.40    |       50.04        |       50.00        |
  test_objective_quadratic_flux_jac      |    0.29 %    |     1.957e+03      |     1.962e+03      |     5.68     |       34.67        |       34.71        |

For the memory plots, go to the summary of Memory Benchmarks workflow and download the artifact.

Comment out deprecated warning for batching method.
@unalmis
unalmis requested review from YigitElma and dpanici October 11, 2026 01:54
@codecov

codecov Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.50000% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.24%. Comparing base (c4856be) to head (4d1ec2e).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
desc/integrals/bounce_integral.py 86.53% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2354      +/-   ##
==========================================
- Coverage   94.25%   94.24%   -0.02%     
==========================================
  Files         101      101              
  Lines       29130    29160      +30     
==========================================
+ Hits        27457    27481      +24     
- Misses       1673     1679       +6     
Files with missing lines Coverage Δ
desc/utils.py 92.51% <100.00%> (+0.01%) ⬆️
desc/integrals/bounce_integral.py 96.19% <86.53%> (-1.05%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@unalmis unalmis added the run_benchmarks Run timing benchmarks on this PR against current master branch label Oct 11, 2026
@github-actions

github-actions Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor
|             benchmark_name             |         dt(%)          |         dt(s)          |        t_new(s)        |        t_old(s)        | 
| -------------------------------------- | ---------------------- | ---------------------- | ---------------------- | ---------------------- |
 test_build_transform_fft_midres         |     -5.42 +/- 4.31     | -4.60e-02 +/- 3.66e-02 |  8.04e-01 +/- 1.8e-02  |  8.50e-01 +/- 3.2e-02  |
 test_build_transform_fft_highres        |     -3.23 +/- 3.21     | -3.52e-02 +/- 3.50e-02 |  1.05e+00 +/- 3.3e-02  |  1.09e+00 +/- 1.0e-02  |
 test_equilibrium_init_medres            |     -3.92 +/- 2.72     | -2.64e-01 +/- 1.83e-01 |  6.46e+00 +/- 1.1e-01  |  6.72e+00 +/- 1.5e-01  |
 test_objective_compile_dshape_current   |     -0.09 +/- 5.86     | -3.19e-03 +/- 2.03e-01 |  3.46e+00 +/- 1.7e-01  |  3.46e+00 +/- 1.1e-01  |
 test_objective_compute_dshape_current   |     +3.81 +/- 10.05    | +2.79e-05 +/- 7.37e-05 |  7.61e-04 +/- 2.9e-05  |  7.33e-04 +/- 6.8e-05  |
 test_objective_jac_dshape_current       |     -1.22 +/- 6.69     | -2.76e-04 +/- 1.51e-03 |  2.23e-02 +/- 9.8e-04  |  2.26e-02 +/- 1.2e-03  |
 test_perturb_2                          |     -0.40 +/- 2.44     | -5.64e-02 +/- 3.46e-01 |  1.42e+01 +/- 3.3e-01  |  1.42e+01 +/- 1.0e-01  |
 test_proximal_jac_atf_chunked           |     +1.31 +/- 2.00     | +6.30e-02 +/- 9.61e-02 |  4.87e+00 +/- 6.4e-02  |  4.81e+00 +/- 7.2e-02  |
 test_proximal_freeb_jac                 |     +1.30 +/- 3.61     | +6.80e-02 +/- 1.89e-01 |  5.31e+00 +/- 1.8e-01  |  5.24e+00 +/- 5.0e-02  |
 test_solve_fixed_iter                   |     +1.44 +/- 2.00     | +3.27e-01 +/- 4.55e-01 |  2.30e+01 +/- 3.7e-01  |  2.27e+01 +/- 2.7e-01  |
 test_objective_grad_ripple              |     +1.09 +/- 5.81     | +9.60e-03 +/- 5.11e-02 |  8.89e-01 +/- 3.6e-02  |  8.80e-01 +/- 3.6e-02  |
 test_objective_quadratic_flux_jac       |     -0.23 +/- 2.06     | -5.00e-03 +/- 4.49e-02 |  2.18e+00 +/- 1.2e-02  |  2.18e+00 +/- 4.3e-02  |
 test_build_transform_fft_lowres         |     +8.17 +/- 5.53     | +7.06e-02 +/- 4.78e-02 |  9.35e-01 +/- 3.5e-02  |  8.64e-01 +/- 3.3e-02  |
 test_equilibrium_init_lowres            |     +9.27 +/- 3.39     | +6.11e-01 +/- 2.24e-01 |  7.20e+00 +/- 1.3e-01  |  6.59e+00 +/- 1.8e-01  |
 test_objective_compile_atf              |     +6.22 +/- 2.23     | +3.52e-01 +/- 1.26e-01 |  6.00e+00 +/- 1.1e-01  |  5.65e+00 +/- 7.0e-02  |
 test_objective_compute_atf              |    +19.32 +/- 10.34    | +4.25e-04 +/- 2.27e-04 |  2.62e-03 +/- 1.8e-04  |  2.20e-03 +/- 1.3e-04  |
 test_objective_jac_atf                  |     +0.74 +/- 7.95     | +1.16e-02 +/- 1.25e-01 |  1.58e+00 +/- 8.3e-02  |  1.57e+00 +/- 9.4e-02  |
 test_perturb_1                          |     -0.15 +/- 4.62     | -1.95e-02 +/- 5.85e-01 |  1.26e+01 +/- 1.5e-01  |  1.27e+01 +/- 5.6e-01  |
 test_proximal_jac_atf                   |     +1.20 +/- 3.43     | +6.45e-02 +/- 1.84e-01 |  5.44e+00 +/- 1.4e-01  |  5.37e+00 +/- 1.2e-01  |
 test_proximal_jac_atf_with_eq_update    |     +3.31 +/- 2.91     | +3.99e-01 +/- 3.51e-01 |  1.25e+01 +/- 2.9e-01  |  1.21e+01 +/- 2.0e-01  |
 test_proximal_freeb_compute             |     +1.05 +/- 3.71     | +1.65e-03 +/- 5.85e-03 |  1.59e-01 +/- 4.5e-03  |  1.57e-01 +/- 3.7e-03  |
 test_solve_fixed_iter_compiled          |     -0.22 +/- 2.45     | -1.31e-02 +/- 1.49e-01 |  6.05e+00 +/- 7.4e-02  |  6.07e+00 +/- 1.3e-01  |
 test_LinearConstraintProjection_build   |     -1.71 +/- 2.89     | -1.16e-01 +/- 1.95e-01 |  6.64e+00 +/- 8.1e-02  |  6.76e+00 +/- 1.8e-01  |
 test_objective_compute_ripple           |     -0.35 +/- 9.19     | -8.04e-04 +/- 2.09e-02 |  2.27e-01 +/- 1.3e-02  |  2.28e-01 +/- 1.7e-02  |
 test_objective_quadratic_flux_compute   |     -1.67 +/- 1.67     | -3.67e-04 +/- 3.68e-04 |  2.16e-02 +/- 2.0e-04  |  2.20e-02 +/- 3.1e-04  |

Github CI performance can be noisy. When evaluating the benchmarks, developers should take this into account.

@YigitElma YigitElma left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Tbh, most of the changes in this PR doesn't make sense for the current master, and frankly very confusing. All the addition are for the things that don't exist yet, and I prefer to add these when they are needed (i.e. in #2215 and #2257).

Some of the changes in docstrings and rho=None seems to be useful.

return batch(*args, **kwargs)

# otherwise act according to the deprecated signature
# warnings.warn( # noqa: F401

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What is the point of having these commented warning here?

@unalmis unalmis Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

If I uncomment the warnings will fail the tests. The point of this PR is to update the api to support the new needed functionality in backwards compatible manner. With this approach it is obvious the new api is compatible with old because all the tests pass using the old api.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

#2215 uncomments the warning after updates the calls to the new api

Comment thread desc/integrals/bounce_integral.py
Comment thread desc/integrals/bounce_integral.py Outdated
Comment thread desc/integrals/bounce_integral.py Outdated
Comment thread desc/integrals/bounce_integral.py Outdated
Removed the static method _compute_objective from BounceOptions class.
@unalmis

unalmis commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator Author

All the addition are for the things that don't exist yet, and I prefer to add these when they are needed (i.e. in #2215 and #2257).

Some of the changes in docstrings and rho=None seems to be useful.

#2354 (comment)

PR doesn't make sense for the current master, and frankly very confusing.

Thank you for sharing your thought. Note that people who write/use the objectives likely find the opposite conclusion. Take for example the master which requires knowing much of DESC to write a simple objective compute function. It also duplicates lots of code in each of the objectives.

def compute(self, params, constants=None):

Compare with #2215 which simply requires a one line method call that works for every objective.

return BounceOptions._compute_objective(

Note this was the same approach already taken in the build method, so I do think it makes sense. Generally, people have asked me how to write build and compute methods for these objectives. This removes confusion there, saving everyone time.

Anyway, to obtain your approval to merge the PR, I have removed it from this PR.

@unalmis
unalmis requested a review from YigitElma October 12, 2026 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run_benchmarks Run timing benchmarks on this PR against current master branch skip_changelog No need to update changelog on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants