Skip to content

Add eq_fixed option to BoundaryError - #2264

Open
IssraAli wants to merge 27 commits into
masterfrom
ia/BoundaryError-eq_fixed
Open

Add eq_fixed option to BoundaryError#2264
IssraAli wants to merge 27 commits into
masterfrom
ia/BoundaryError-eq_fixed

Conversation

@IssraAli

Copy link
Copy Markdown
Collaborator

An option to remove the equilibrium as an optimizable DOF when computing BoundaryError is included.

@github-actions

github-actions Bot commented Jul 10, 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                 |   -2.08 %    |     4.052e+03      |     3.968e+03      |    -84.45    |       34.51        |       29.69        |
  test_proximal_jac_w7x_with_eq_update   |    1.11 %    |     6.557e+03      |     6.630e+03      |    72.59     |       148.60       |       149.87       |
  test_proximal_freeb_jac                |    0.62 %    |     1.335e+04      |     1.344e+04      |    82.69     |       86.16        |       85.60        |
  test_proximal_freeb_jac_blocked        |    0.08 %    |     7.694e+03      |     7.700e+03      |     5.88     |       77.78        |       75.91        |
  test_proximal_freeb_jac_batched        |   -0.18 %    |     7.654e+03      |     7.640e+03      |    -14.07    |       77.30        |       75.74        |
  test_proximal_jac_ripple               |   -0.16 %    |     3.562e+03      |     3.557e+03      |    -5.64     |       52.49        |       52.28        |
  test_proximal_jac_ripple_bounce1d      |   -1.25 %    |     3.716e+03      |     3.670e+03      |    -46.60    |       66.28        |       65.29        |
  test_eq_solve                          |   -0.84 %    |     2.087e+03      |     2.070e+03      |    -17.61    |       53.00        |       52.75        |
  test_objective_quadratic_flux_jac      |   -0.35 %    |     2.514e+03      |     2.506e+03      |    -8.72     |       55.83        |       55.58        |

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

@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.36%. Comparing base (d4ddab0) to head (b26c546).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2264   +/-   ##
=======================================
  Coverage   94.35%   94.36%           
=======================================
  Files         101      101           
  Lines       28897    28930   +33     
=======================================
+ Hits        27266    27300   +34     
+ Misses       1631     1630    -1     
Files with missing lines Coverage Δ
desc/objectives/_free_boundary.py 96.78% <100.00%> (+0.31%) ⬆️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@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.

You can also add a test like test_toroidal_flux to check all paths run fine.

Comment thread desc/objectives/_free_boundary.py Outdated
@YigitElma

Copy link
Copy Markdown
Collaborator

I think the reason tests are failing is that constants["field"] is a SumMagneticField and it expects a list for the params. So, the parameter assignment needs a bit more care. For this objective, field can be something like [MixedCoilSet(), ToroidalMagneticField()].

@IssraAli
IssraAli requested a review from YigitElma July 14, 2026 15:58

@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.

About the formatting and linting check, if you run the following, they will happen automatically everytime you commit something.

pip install pre-commit
pre-commit install

These and some other useful instructions can be found on the Contributing Guide.

Comment thread desc/objectives/_free_boundary.py Outdated
Comment thread desc/objectives/_free_boundary.py Outdated
Comment thread tests/test_objective_funs.py Outdated
Comment thread tests/test_objective_funs.py Outdated
Comment thread CHANGELOG.md Outdated

@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.

Note to other devs: The failing test is related to jax-finufft version 1.2.0 and not caused by this PR. We should solve that problem separetaly or wait CI to run that test on a different python version (which doesn't install jax-finufft 1.2.0)

Comment thread CHANGELOG.md Outdated
@YigitElma
YigitElma requested review from ddudt, dpanici and f0uriest July 15, 2026 22:28
ddudt
ddudt previously approved these changes Jul 17, 2026

@ddudt ddudt 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.

I fixed the failing test, simplified the new tests, and edited some of the docstrings. This approval doesn't really count.

@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.

Other than the order of the operations, it looks good to me.

Comment thread desc/objectives/_free_boundary.py
Comment thread desc/objectives/_free_boundary.py
Comment thread desc/objectives/_free_boundary.py
Comment thread desc/objectives/_free_boundary.py Outdated
@YigitElma YigitElma added the easy Short and simple to code or review label Jul 22, 2026
@lkadz
lkadz self-requested a review July 28, 2026 15:19
lkadz
lkadz previously approved these changes Jul 28, 2026
@YigitElma YigitElma added the run_benchmarks Run timing benchmarks on this PR against current master branch label Jul 29, 2026
@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor
|             benchmark_name             |         dt(%)          |         dt(s)          |        t_new(s)        |        t_old(s)        | 
| -------------------------------------- | ---------------------- | ---------------------- | ---------------------- | ---------------------- |
 test_build_transform_fft_lowres         |     -1.73 +/- 4.40     | -1.51e-02 +/- 3.84e-02 |  8.59e-01 +/- 2.1e-02  |  8.74e-01 +/- 3.2e-02  |
 test_equilibrium_init_lowres            |     -2.48 +/- 3.46     | -1.69e-01 +/- 2.35e-01 |  6.62e+00 +/- 1.3e-01  |  6.79e+00 +/- 2.0e-01  |
 test_objective_compile_atf              |     -1.60 +/- 3.61     | -1.01e-01 +/- 2.27e-01 |  6.20e+00 +/- 1.7e-01  |  6.30e+00 +/- 1.5e-01  |
 test_objective_compute_atf              |     -1.28 +/- 14.66    | -2.87e-05 +/- 3.29e-04 |  2.22e-03 +/- 2.3e-04  |  2.25e-03 +/- 2.4e-04  |
 test_objective_jac_atf                  |     -1.88 +/- 5.02     | -3.04e-02 +/- 8.15e-02 |  1.59e+00 +/- 6.8e-02  |  1.62e+00 +/- 4.5e-02  |
 test_perturb_1                          |     -1.60 +/- 1.74     | -2.00e-01 +/- 2.17e-01 |  1.23e+01 +/- 1.6e-01  |  1.25e+01 +/- 1.5e-01  |
 test_proximal_jac_atf                   |     +0.02 +/- 2.30     | +1.25e-03 +/- 1.24e-01 |  5.39e+00 +/- 9.5e-02  |  5.39e+00 +/- 8.0e-02  |
 test_proximal_freeb_compute             |     +1.28 +/- 2.73     | +2.12e-03 +/- 4.52e-03 |  1.68e-01 +/- 3.5e-03  |  1.66e-01 +/- 2.8e-03  |
 test_solve_fixed_iter                   |     +1.92 +/- 2.36     | +4.81e-01 +/- 5.91e-01 |  2.55e+01 +/- 4.9e-01  |  2.51e+01 +/- 3.4e-01  |
 test_LinearConstraintProjection_build   |     +2.80 +/- 4.39     | +1.98e-01 +/- 3.10e-01 |  7.27e+00 +/- 2.0e-01  |  7.07e+00 +/- 2.4e-01  |
 test_objective_compute_ripple           |     -0.82 +/- 4.42     | -1.97e-03 +/- 1.06e-02 |  2.39e-01 +/- 6.2e-03  |  2.41e-01 +/- 8.6e-03  |
 test_objective_grad_ripple              |     -2.51 +/- 3.34     | -2.30e-02 +/- 3.07e-02 |  8.94e-01 +/- 2.8e-02  |  9.17e-01 +/- 1.2e-02  |
 test_objective_quadratic_flux_compute   |     -1.57 +/- 10.95    | -8.19e-04 +/- 5.71e-03 |  5.13e-02 +/- 1.9e-03  |  5.21e-02 +/- 5.4e-03  |
 test_build_transform_fft_midres         |     -1.85 +/- 5.70     | -1.31e-02 +/- 4.03e-02 |  6.95e-01 +/- 2.4e-02  |  7.08e-01 +/- 3.2e-02  |
 test_build_transform_fft_highres        |     -1.38 +/- 3.25     | -1.29e-02 +/- 3.03e-02 |  9.19e-01 +/- 2.0e-02  |  9.32e-01 +/- 2.2e-02  |
 test_equilibrium_init_medres            |     +4.51 +/- 3.99     | +2.55e-01 +/- 2.25e-01 |  5.90e+00 +/- 1.4e-01  |  5.65e+00 +/- 1.8e-01  |
 test_objective_compile_dshape_current   |     +2.43 +/- 2.85     | +7.62e-02 +/- 8.97e-02 |  3.22e+00 +/- 5.7e-02  |  3.14e+00 +/- 6.9e-02  |
 test_objective_compute_dshape_current   |    +15.60 +/- 6.56     | +7.24e-05 +/- 3.05e-05 |  5.37e-04 +/- 2.2e-05  |  4.64e-04 +/- 2.1e-05  |
 test_objective_jac_dshape_current       |    +18.04 +/- 28.34    | +3.62e-03 +/- 5.68e-03 |  2.37e-02 +/- 4.6e-03  |  2.01e-02 +/- 3.3e-03  |
 test_perturb_2                          |     +4.18 +/- 3.70     | +5.02e-01 +/- 4.45e-01 |  1.25e+01 +/- 4.4e-01  |  1.20e+01 +/- 6.9e-02  |
 test_proximal_jac_atf_with_eq_update    |     -0.49 +/- 1.50     | -4.87e-02 +/- 1.50e-01 |  9.91e+00 +/- 1.1e-01  |  9.96e+00 +/- 1.0e-01  |
 test_proximal_freeb_jac                 |     +1.38 +/- 5.35     | +5.32e-02 +/- 2.07e-01 |  3.92e+00 +/- 2.0e-01  |  3.86e+00 +/- 5.5e-02  |
 test_solve_fixed_iter_compiled          |     +0.91 +/- 2.17     | +4.46e-02 +/- 1.07e-01 |  4.96e+00 +/- 9.5e-02  |  4.92e+00 +/- 4.9e-02  |
 test_objective_compute_ripple_bounce1d  |     +1.15 +/- 5.08     | +2.63e-03 +/- 1.16e-02 |  2.30e-01 +/- 6.8e-03  |  2.28e-01 +/- 9.4e-03  |
 test_objective_grad_ripple_bounce1d     |     +1.36 +/- 2.63     | +1.06e-02 +/- 2.05e-02 |  7.89e-01 +/- 1.7e-02  |  7.79e-01 +/- 1.1e-02  |
 test_objective_quadratic_flux_jac       |     -0.53 +/- 1.05     | -4.17e-02 +/- 8.28e-02 |  7.81e+00 +/- 3.9e-02  |  7.86e+00 +/- 7.3e-02  |

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

@YigitElma
YigitElma dismissed stale reviews from lkadz, ddudt, and themself via ded077e July 30, 2026 04:10
@YigitElma
YigitElma requested review from YigitElma, ddudt and lkadz July 30, 2026 04:11
YigitElma
YigitElma previously approved these changes Jul 30, 2026

@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.

There was just a merge conflict in CHANGELOG

Comment thread desc/objectives/_free_boundary.py Outdated
ddudt
ddudt previously approved these changes Jul 30, 2026
Comment thread tests/test_compute_everything.py Outdated
@YigitElma
YigitElma requested review from YigitElma and dpanici July 30, 2026 19:25
@YigitElma
YigitElma requested a review from ddudt July 31, 2026 01:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

easy Short and simple to code or review run_benchmarks Run timing benchmarks on this PR against current master branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants