Skip to content

Dp/requested changes sparse - #2291

Open
dpanici wants to merge 21 commits into
ku/sparse_pullbackfrom
dp/requested-changes-sparse
Open

Dp/requested changes sparse#2291
dpanici wants to merge 21 commits into
ku/sparse_pullbackfrom
dp/requested-changes-sparse

Conversation

@dpanici

@dpanici dpanici commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

@unalmis I put my requested changes in this PR pointing to yours, tests locally pass for test_integrals, test_objective_funs and test_compute_everything (paths where I thought warnings might pop up potentially), feel free to merge if you accept these change requests

@dpanici
dpanici requested a review from unalmis August 13, 2026 18:12
@dpanici
dpanici changed the base branch from master to ku/sparse_pullback August 13, 2026 18:12
@github-actions

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.04 %    |     4.240e+03      |     4.242e+03      |     1.68     |       25.58        |       23.17        |
  test_proximal_jac_w7x_with_eq_update   |   -0.86 %    |     6.879e+03      |     6.819e+03      |    -59.41    |       110.29       |       111.34       |
  test_proximal_freeb_jac                |   -0.04 %    |     1.354e+04      |     1.354e+04      |    -4.91     |       71.49        |       69.57        |
  test_proximal_freeb_jac_blocked        |    0.43 %    |     7.861e+03      |     7.896e+03      |    34.11     |       63.66        |       64.21        |
  test_proximal_freeb_jac_batched        |    0.24 %    |     7.849e+03      |     7.867e+03      |    18.45     |       62.42        |       62.19        |
  test_proximal_jac_ripple               |    0.21 %    |     3.773e+03      |     3.781e+03      |     7.98     |       41.33        |       40.46        |
  test_proximal_jac_ripple_bounce1d      |    0.56 %    |     3.785e+02      |     3.806e+02      |     2.11     |        2.56        |        2.56        |
  test_eq_solve                          |   -1.48 %    |     1.840e+03      |     1.813e+03      |    -27.33    |       36.45        |       36.78        |
  test_objective_quadratic_flux_jac      |   -0.41 %    |     2.715e+03      |     2.704e+03      |    -11.07    |       41.88        |       43.03        |

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

@codecov

codecov Bot commented Aug 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 45.45455% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.35%. Comparing base (ffa8f24) to head (7abb617).

Files with missing lines Patch % Lines
desc/integrals/bounce_integral.py 33.33% 2 Missing ⚠️
desc/objectives/_fast_ion.py 50.00% 2 Missing ⚠️
desc/objectives/_neoclassical.py 50.00% 2 Missing ⚠️
Additional details and impacted files
@@                  Coverage Diff                   @@
##           ku/sparse_pullback    #2291      +/-   ##
======================================================
- Coverage               94.37%   94.35%   -0.02%     
======================================================
  Files                     101      101              
  Lines                   28944    28953       +9     
======================================================
+ Hits                    27315    27319       +4     
- Misses                   1629     1634       +5     
Files with missing lines Coverage Δ
desc/integrals/_bounce_utils.py 94.82% <ø> (ø)
desc/integrals/bounce_integral.py 97.21% <33.33%> (-0.21%) ⬇️
desc/objectives/_fast_ion.py 88.63% <50.00%> (-3.87%) ⬇️
desc/objectives/_neoclassical.py 88.37% <50.00%> (-3.94%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ddudt

ddudt commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

suggestion(if-minor)
In this PR can we also change the name of num_field_periods to field_period_transits as explained in this comment?


@staticmethod
def pitch_quad(min_B, max_B, num_pitch, **kwargs):
def get_pitch_inv_quad(min_B, max_B, num_pitch, simp=True):

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.

@unalmis Was there a compelling reason to change the name to pitch_quad? If so, I can revert this and replace it with an alias to throw a deprecation warning about the new function name, like I did for regular_points -> bounce_points. But the original name get_pitch_inv_quad sounds more descriptive so I prefer keeping it.

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.

pitch_quad is shorter. get_pitch_inv_quad still works so there is no need to remove pitch_quad. What do you mean like you did for regular to bounce points? Those were private functions so you don't need deprecation

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.

OK I will keep it as get_pitch_inv_quad if you don't mind.

I mean like this change to throw a warning if you call the old function name. I know we don't really intend for users to call this directly, but it's still good practice and only a few lines of extra code that we can remove after a couple of releases have passed.

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.

Okay on the regular points thing but fyi the whole file is an underscore and there is a docstring at top of file that warns every method here is private and may change without notice.

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.

Just to clarify, in original PR get_pitch_inv_quad still works. Just pitch_quad is added as an option.

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

Looks like there is some confusion that is causing some unnecessary deprecation warnings. Have marked those that should be reverted or excluded.

Also the two line change I added in downstream PR to not include a dummy argument in the docstring should be kept to avoid polluting an already complicated objective. As just a practical example of why that is also useful for developers, observe this PR reverts that change has introduced an inefficiency of allowing jac_chunk_size to be modified by the user. That will result in poor performance at no improvement. I recall I cached the Jacobin so doesn't matter.

Comment thread desc/integrals/_bounce_utils.py Outdated
Comment thread desc/integrals/bounce_integral.py

@staticmethod
def pitch_quad(min_B, max_B, num_pitch, **kwargs):
def get_pitch_inv_quad(min_B, max_B, num_pitch, simp=True):

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.

simp is a private kwarg that should not be documented.

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.

We want to document all arguments, since the documentation is not just for users but also helpful for us developers to remember what things do.

@unalmis unalmis Aug 18, 2026

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.

The intention is to always use simp unless user supplies their own quadrature in future. DESC has plenty of methods where some features are buried into kwargs to avoid polluting the signature, especially when those kwargs are unchaged in almost all cases.

Comment thread desc/integrals/bounce_integral.py
Comment thread desc/integrals/bounce_integral.py

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.

revert get_pitch_inv_quad to pitch_quad

Comment thread tests/test_integrals.py
)
bounce = Bounce1D(grid, data, check=True)
pitch_inv, _ = bounce.pitch_quad(
pitch_inv, _ = bounce.get_pitch_inv_quad(

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.

revert

Comment thread tests/test_integrals.py
# Exclude singularity not captured by analytic approximation for pitch near
# the maximum |B|. (This is captured by the numerical integration).
pitch_inv = Bounce1D.pitch_quad(np.min(B), np.max(B), 100, simp=False)[0][:-1]
pitch_inv = Bounce1D.get_pitch_inv_quad(np.min(B), np.max(B), 100, simp=False)[

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.

revert

Comment thread tests/test_integrals.py
quad=chebgauss1(16), # this is our own custom chebgauss1
)
pitch_inv, _ = bounce.pitch_quad(
pitch_inv, _ = bounce.get_pitch_inv_quad(

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.

revert

Comment thread CHANGELOG.md Outdated
Comment thread desc/integrals/_bounce_utils.py
@ddudt ddudt mentioned this pull request Aug 18, 2026
17 tasks
@ddudt

ddudt commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

Looks like there is some confusion that is causing some unnecessary deprecation warnings. Have marked those that should be reverted or excluded.

Yes I had misunderstood some things, thanks for the clarification. I now get that you were not introducing any breaking changes to the public API, but those changes should still be documented.

Let's try to make some compromises to get this finished. I reverted my edits to the private functions and I'm fine with those changing. But we still want users to be warned about changes to the public API and those warnings can be removed later.

Once you merge this PR we will merge #2170.

@ddudt
ddudt requested a review from unalmis August 18, 2026 18:22
Comment thread desc/integrals/bounce_integral.py
@unalmis

unalmis commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

These are not resolved and break code.

  1. Dp/requested changes sparse #2291 (comment)
  2. Dp/requested changes sparse #2291 (comment)

But we still want users to be warned about changes to the public API and those warnings can be removed later.

Please see second point on why the edits made here are counter to above statement. There is still incorrect understanding that those comments correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants