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

Refactoring Basis/Transform/Grid stuff #1405

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

Refactoring Basis/Transform/Grid stuff #1405

wants to merge 33 commits into from

Conversation

f0uriest
Copy link
Member

@f0uriest f0uriest commented Nov 21, 2024

  • Transform(method="fft") now works with grids that have an even number of toroidal nodes
  • Adds attributes to Basis classes for unique mode numbers, inverse indices etc, similar to grids
  • Removes unique option Basis.evaluate in favor of always using precomputed unique modes/nodes (Take advantage of separable basis functions #1530)
  • Adds attributes to grids denoting whether they work with ffts in poloidal/toroidal directions (Making transforms more efficient #1243)

@f0uriest f0uriest marked this pull request as draft November 21, 2024 04:12
Copy link
Contributor

github-actions bot commented Nov 21, 2024

|             benchmark_name             |         dt(%)          |         dt(s)          |        t_new(s)        |        t_old(s)        | 
| -------------------------------------- | ---------------------- | ---------------------- | ---------------------- | ---------------------- |
-test_build_transform_fft_lowres         |    +14.92 +/- 4.41     | +7.90e-02 +/- 2.34e-02 |  6.09e-01 +/- 2.1e-02  |  5.29e-01 +/- 1.1e-02  |
 test_equilibrium_init_medres            |     -3.73 +/- 1.91     | -1.56e-01 +/- 7.94e-02 |  4.01e+00 +/- 6.9e-02  |  4.16e+00 +/- 4.0e-02  |
+test_equilibrium_init_highres           |     -8.21 +/- 1.69     | -4.47e-01 +/- 9.17e-02 |  4.99e+00 +/- 7.9e-02  |  5.44e+00 +/- 4.6e-02  |
 test_objective_compile_dshape_current   |     +2.81 +/- 4.64     | +1.14e-01 +/- 1.88e-01 |  4.17e+00 +/- 1.4e-01  |  4.05e+00 +/- 1.2e-01  |
-test_objective_compute_dshape_current   |     +6.46 +/- 1.62     | +3.32e-04 +/- 8.35e-05 |  5.48e-03 +/- 6.6e-05  |  5.15e-03 +/- 5.1e-05  |
 test_objective_jac_dshape_current       |     +1.05 +/- 6.45     | +4.47e-04 +/- 2.76e-03 |  4.32e-02 +/- 2.0e-03  |  4.28e-02 +/- 1.9e-03  |
 test_perturb_2                          |     +3.74 +/- 1.68     | +7.34e-01 +/- 3.30e-01 |  2.04e+01 +/- 2.7e-01  |  1.96e+01 +/- 1.9e-01  |
 test_proximal_freeb_jac                 |     -0.20 +/- 1.30     | -1.48e-02 +/- 9.62e-02 |  7.36e+00 +/- 4.9e-02  |  7.38e+00 +/- 8.3e-02  |
 test_solve_fixed_iter                   |     +1.32 +/- 1.36     | +4.20e-01 +/- 4.34e-01 |  3.22e+01 +/- 2.9e-01  |  3.18e+01 +/- 3.2e-01  |
 test_LinearConstraintProjection_build   |     +2.73 +/- 1.59     | +2.80e-01 +/- 1.62e-01 |  1.05e+01 +/- 9.6e-02  |  1.02e+01 +/- 1.3e-01  |
 test_build_transform_fft_midres         |     +5.38 +/- 5.63     | +3.25e-02 +/- 3.40e-02 |  6.37e-01 +/- 3.4e-02  |  6.04e-01 +/- 3.4e-03  |
 test_build_transform_fft_highres        |     -5.36 +/- 7.69     | -5.20e-02 +/- 7.46e-02 |  9.18e-01 +/- 6.8e-02  |  9.70e-01 +/- 3.0e-02  |
+test_equilibrium_init_lowres            |    -10.74 +/- 2.66     | -4.42e-01 +/- 1.09e-01 |  3.67e+00 +/- 7.7e-02  |  4.11e+00 +/- 7.8e-02  |
 test_objective_compile_atf              |     -3.20 +/- 2.10     | -2.75e-01 +/- 1.80e-01 |  8.31e+00 +/- 1.4e-01  |  8.58e+00 +/- 1.1e-01  |
 test_objective_compute_atf              |     +0.19 +/- 3.47     | +3.03e-05 +/- 5.58e-04 |  1.61e-02 +/- 1.9e-04  |  1.61e-02 +/- 5.3e-04  |
 test_objective_jac_atf                  |     +0.45 +/- 2.01     | +8.78e-03 +/- 3.96e-02 |  1.98e+00 +/- 1.5e-02  |  1.97e+00 +/- 3.6e-02  |
 test_perturb_1                          |     +4.59 +/- 3.12     | +6.74e-01 +/- 4.58e-01 |  1.54e+01 +/- 3.3e-01  |  1.47e+01 +/- 3.2e-01  |
 test_proximal_jac_atf                   |     -1.84 +/- 1.72     | -1.53e-01 +/- 1.43e-01 |  8.16e+00 +/- 9.4e-02  |  8.31e+00 +/- 1.1e-01  |
 test_proximal_freeb_compute             |     -0.87 +/- 1.76     | -1.75e-03 +/- 3.54e-03 |  2.00e-01 +/- 2.3e-03  |  2.02e-01 +/- 2.7e-03  |
 test_solve_fixed_iter_compiled          |     +0.59 +/- 1.35     | +1.22e-01 +/- 2.78e-01 |  2.07e+01 +/- 2.5e-01  |  2.06e+01 +/- 1.3e-01  |

@f0uriest f0uriest mentioned this pull request Dec 4, 2024
@dpanici
Copy link
Collaborator

dpanici commented Dec 18, 2024

replace at axis with 0.0 for quantities we know must be the case

@unalmis unalmis linked an issue Jan 23, 2025 that may be closed by this pull request
@unalmis unalmis added the performance New feature or request to make the code faster label Jan 23, 2025
@f0uriest f0uriest marked this pull request as ready for review January 28, 2025 21:14
@f0uriest f0uriest changed the title Rc/transforms Refactoring Basis/Transform/Grid stuff Jan 28, 2025
@f0uriest f0uriest requested review from a team, rahulgaur104, ddudt, dpanici, sinaatalay, unalmis and YigitElma and removed request for a team January 28, 2025 21:22
@@ -257,29 +257,26 @@ def test_3d_tz(self):
assert "Z" in data.keys()

assert "|F|" in data.keys()
return fig
Copy link
Member Author

Choose a reason for hiding this comment

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

newer versions of pytest complain if tests return something that isn't used

Copy link

codecov bot commented Jan 28, 2025

Codecov Report

Attention: Patch coverage is 92.91339% with 27 lines in your changes missing coverage. Please review.

Project coverage is 95.63%. Comparing base (48eb4d0) to head (ff50bc7).
Report is 6 commits behind head on master.

Files with missing lines Patch % Lines
desc/basis.py 91.35% 21 Missing ⚠️
desc/plotting.py 89.74% 4 Missing ⚠️
desc/grid.py 94.87% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1405      +/-   ##
==========================================
- Coverage   95.69%   95.63%   -0.07%     
==========================================
  Files         101      101              
  Lines       25633    25775     +142     
==========================================
+ Hits        24529    24649     +120     
- Misses       1104     1126      +22     
Files with missing lines Coverage Δ
desc/equilibrium/coords.py 88.16% <100.00%> (-0.10%) ⬇️
desc/integrals/singularities.py 90.90% <100.00%> (-0.39%) ⬇️
desc/profiles.py 95.46% <100.00%> (ø)
desc/transform.py 92.51% <100.00%> (-0.77%) ⬇️
desc/grid.py 94.57% <94.87%> (-0.01%) ⬇️
desc/plotting.py 95.88% <89.74%> (-0.15%) ⬇️
desc/basis.py 96.84% <91.35%> (-1.34%) ⬇️

... and 3 files with indirect coverage changes

@YigitElma
Copy link
Collaborator

|             benchmark_name             |         dt(%)          |         dt(s)          |        t_new(s)        |        t_old(s)        | 
| -------------------------------------- | ---------------------- | ---------------------- | ---------------------- | ---------------------- |
-test_build_transform_fft_lowres         |    +26.22 +/- 3.97     | +1.37e-01 +/- 2.08e-02 |  6.60e-01 +/- 1.8e-02  |  5.23e-01 +/- 1.0e-02  |
 test_equilibrium_init_medres            |     +5.01 +/- 2.60     | +2.07e-01 +/- 1.07e-01 |  4.33e+00 +/- 1.0e-01  |  4.13e+00 +/- 3.1e-02  |
 test_equilibrium_init_highres           |     -2.09 +/- 2.48     | -1.13e-01 +/- 1.34e-01 |  5.29e+00 +/- 1.3e-01  |  5.41e+00 +/- 3.3e-02  |
 test_objective_compile_dshape_current   |     +6.37 +/- 4.86     | +2.60e-01 +/- 1.99e-01 |  4.34e+00 +/- 1.5e-01  |  4.08e+00 +/- 1.3e-01  |
 test_objective_compute_dshape_current   |     +7.76 +/- 3.04     | +4.00e-04 +/- 1.57e-04 |  5.55e-03 +/- 1.5e-04  |  5.15e-03 +/- 4.5e-05  |
 test_objective_jac_dshape_current       |     +4.94 +/- 7.94     | +2.10e-03 +/- 3.38e-03 |  4.47e-02 +/- 2.7e-03  |  4.25e-02 +/- 2.0e-03  |
-test_perturb_2                          |     +9.92 +/- 0.70     | +1.95e+00 +/- 1.37e-01 |  2.16e+01 +/- 1.1e-01  |  1.96e+01 +/- 8.1e-02  |
 test_proximal_freeb_jac                 |     +2.01 +/- 1.30     | +1.49e-01 +/- 9.63e-02 |  7.55e+00 +/- 8.5e-02  |  7.40e+00 +/- 4.6e-02  |
 test_solve_fixed_iter                   |     +6.81 +/- 3.10     | +2.16e+00 +/- 9.84e-01 |  3.39e+01 +/- 9.3e-01  |  3.17e+01 +/- 3.2e-01  |
 test_LinearConstraintProjection_build   |     +2.48 +/- 1.03     | +2.53e-01 +/- 1.05e-01 |  1.05e+01 +/- 4.9e-02  |  1.02e+01 +/- 9.3e-02  |
 test_build_transform_fft_midres         |     +8.88 +/- 5.26     | +5.43e-02 +/- 3.21e-02 |  6.66e-01 +/- 1.7e-02  |  6.12e-01 +/- 2.7e-02  |
 test_build_transform_fft_highres        |     -2.07 +/- 2.00     | -2.02e-02 +/- 1.95e-02 |  9.56e-01 +/- 1.7e-02  |  9.76e-01 +/- 9.5e-03  |
 test_equilibrium_init_lowres            |     -1.37 +/- 4.57     | -5.35e-02 +/- 1.79e-01 |  3.86e+00 +/- 1.7e-01  |  3.91e+00 +/- 6.1e-02  |
 test_objective_compile_atf              |     +0.23 +/- 1.67     | +1.87e-02 +/- 1.38e-01 |  8.30e+00 +/- 1.2e-01  |  8.28e+00 +/- 7.1e-02  |
 test_objective_compute_atf              |     +2.63 +/- 2.31     | +4.17e-04 +/- 3.66e-04 |  1.62e-02 +/- 2.6e-04  |  1.58e-02 +/- 2.6e-04  |
 test_objective_jac_atf                  |     +1.60 +/- 2.25     | +3.12e-02 +/- 4.38e-02 |  1.98e+00 +/- 3.4e-02  |  1.95e+00 +/- 2.7e-02  |
 test_perturb_1                          |     +1.43 +/- 5.14     | +2.17e-01 +/- 7.84e-01 |  1.55e+01 +/- 3.9e-01  |  1.53e+01 +/- 6.8e-01  |
 test_proximal_jac_atf                   |     -0.81 +/- 1.62     | -6.71e-02 +/- 1.35e-01 |  8.23e+00 +/- 1.3e-01  |  8.30e+00 +/- 5.0e-02  |
 test_proximal_freeb_compute             |     +0.01 +/- 1.43     | +2.95e-05 +/- 2.88e-03 |  2.01e-01 +/- 1.4e-03  |  2.01e-01 +/- 2.5e-03  |
 test_solve_fixed_iter_compiled          |     +0.53 +/- 1.37     | +1.09e-01 +/- 2.82e-01 |  2.08e+01 +/- 1.6e-01  |  2.07e+01 +/- 2.3e-01  |

Is this slowdown only on CPU? It was faster at some point but some recent change made it slower.

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Take advantage of separable basis functions
4 participants