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

Nonuniform fast transforms #1294

Open
unalmis opened this issue Oct 5, 2024 · 3 comments
Open

Nonuniform fast transforms #1294

unalmis opened this issue Oct 5, 2024 · 3 comments
Assignees
Labels
P3 Highest Priority, someone is/should be actively working on this performance New feature or request to make the code faster

Comments

@unalmis
Copy link
Collaborator

unalmis commented Oct 5, 2024

In general, the computation of locally defined or singular quantities will be more efficient with non-uniform fast transforms. In particular, I am referring to the type 2 nonuniform fast transform, which evaluates spectral coefficients at non-uniformly spaced points.

Although a fixed grid with nodes uniformly spaced throughout the plasma is fine for optimizing continuous functions defined throughout the volume, it is of course not well-suited for locally defined quantities such as bounce integrals. There are two hurdles with computing these quantities efficiently:

  1. Require computation along field lines.
  2. They are defined by singular integrals.
    • This requires evaluating the function at points concentrated near the singularity. For flux surface average of bounce integrals in particular, there are infinitely many integrals to be done, so regardless of the efficiency of the quadrature, there will be many function evaluations. Hence, linearithmic performance of fast non-uniform transform is desired over the quadratic performance of MMTs.

We should pick a JAX compatible NFFT package and write drop in replacements for the currently used MMTs. We can check the $\epsilon$ errors of these external NFFT libraries by comparing to those utilities on the tests in that PR. (Note that for strongly singular integrals $1 / \sqrt(1 - \lambda |B|)$, we will maybe still use MMT's for |B| since the integrands are not smooth functions of |B|, and the nodes are packed more tightly near the edges. This should be fine since |B| is parameterized by a series expansion in a single variable along each cut of the field line, so it is cheaper. The other quantities in the integrand are 2D functions where this would be more useful. For the weakly singular ones, all the quantities should be able to use NFFTs without issue).

Here are some candidates:

  1. https://github.com/jakevdp/nfft
  2. https://github.com/flatironinstitute/jax-finufft
@unalmis unalmis added the performance New feature or request to make the code faster label Oct 5, 2024
@acerfon
Copy link

acerfon commented Oct 5, 2024

For what it's worth, we have been very happy with the Flatiron's NUFFT, which we have used with much success for a new Particle in Fourier scheme:
https://www.sciencedirect.com/science/article/pii/S0021999124006387#:~:text=Journal%20of%20Computational%20Physics.%20Volume

I highly recommend that https://github.com/flatironinstitute/jax-finufft library!

@acerfon
Copy link

acerfon commented Oct 5, 2024

As another 2-cents, for the singular integrals you are talking about, I very highly recommend the Kapur-Rokhlin quadrature schemes, which we have also found easy to use, and super accurate, in our case for the evaluation of the virtual casing principle:
https://www.jstor.org/stable/2952054

@f0uriest
Copy link
Member

f0uriest commented Oct 7, 2024

I've also used finufft and really like it, I thought about using it for some of the stuff in #725, the main reason I didn't was that they don't have prebuilt cuda wheels so installing it with gpu support can be annoying. It looks like they have an open issue for that (flatironinstitute/jax-finufft#88) so if that can be fixed it would be great for us.

NUFFTs may also make for #641 easier for some cases.

@dpanici dpanici added the P2 Medium Priority, not urgent but should be on the near-term agend label Nov 11, 2024
@unalmis unalmis added P3 Highest Priority, someone is/should be actively working on this and removed P2 Medium Priority, not urgent but should be on the near-term agend labels Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 Highest Priority, someone is/should be actively working on this performance New feature or request to make the code faster
Projects
None yet
Development

No branches or pull requests

4 participants