Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
8fb2b38
Add fft grid and raz grid to test against master
unalmis Apr 10, 2026
25164d0
remove noise by tighten tolerance
unalmis Apr 10, 2026
0d23c66
final attempt
unalmis Apr 10, 2026
5e70567
rory comment
unalmis Apr 10, 2026
945f1af
fix last commit
unalmis Apr 10, 2026
c2ecc4b
Increase correlation in discretization error for optimization
unalmis Apr 12, 2026
bb8ac6a
Merge branch 'master' into ku/test
unalmis Apr 12, 2026
7489317
.
unalmis Apr 12, 2026
e240249
increase tol for test
unalmis Apr 12, 2026
be41c58
remove not implemented todo
unalmis Apr 12, 2026
a55b170
.
unalmis Apr 12, 2026
2cff860
add back short-circuit
unalmis Apr 12, 2026
1727fba
collect redundant docs
unalmis Apr 13, 2026
339643b
Fix if statements
unalmis Apr 13, 2026
bda562a
Merge branch 'master' into ku/test
f0uriest Apr 13, 2026
ff53f80
Resolves #2162
unalmis Apr 14, 2026
83ffee6
loosen tol on test
unalmis Apr 14, 2026
ccf228f
flake8
unalmis Apr 14, 2026
f8a3515
flake8 blank line space
unalmis Apr 14, 2026
d05bda1
future proof
unalmis Apr 15, 2026
c06687d
daniel comments
unalmis Apr 15, 2026
d5a682f
fix render
unalmis Apr 16, 2026
f325bbf
Apply suggestions from code review
unalmis Apr 16, 2026
1792e91
Apply suggestions from code review
unalmis Apr 16, 2026
89479dc
Apply suggestions from code review
unalmis Apr 16, 2026
947641b
dan comment v2
unalmis Apr 16, 2026
13b6870
dan v2
unalmis Apr 16, 2026
a58c075
more dan
unalmis Apr 16, 2026
ad86912
last dan
unalmis Apr 16, 2026
f4faed4
last commit to desc
unalmis Apr 16, 2026
c42a92b
flake
unalmis Apr 16, 2026
2a5d6c2
Merge branch 'master' into ku/test
unalmis Apr 17, 2026
585d59a
Merge branch 'master' into ku/test
unalmis Apr 18, 2026
fcea971
Merge branch 'master' into ku/test
dpanici Apr 19, 2026
86f21f7
Resolves #2168
unalmis Apr 20, 2026
2c93334
remove comment
unalmis Apr 20, 2026
1b79b3e
.
unalmis Apr 21, 2026
1decd5e
clean up internal api
unalmis Apr 21, 2026
6df2ca9
clean
unalmis Apr 21, 2026
eef7938
use none
unalmis Apr 21, 2026
7fc978a
remove kwargs over closure conversion
unalmis Apr 21, 2026
8b33ca1
reduce duplicate code
unalmis Apr 22, 2026
5de9a9e
add missing todo
unalmis Apr 22, 2026
ae984ca
Remove bounce1d
unalmis Apr 22, 2026
ee71551
ad note
unalmis Apr 22, 2026
4da7446
.
unalmis Apr 22, 2026
f34abe2
missing exception
unalmis Apr 22, 2026
55155ed
missing label
unalmis Apr 22, 2026
b32bc40
Remove kwargs that are not needed anymore
unalmis Apr 22, 2026
1953444
clarify boolean
unalmis Apr 22, 2026
906b26a
.
unalmis Apr 22, 2026
f00647c
.
unalmis Apr 22, 2026
cd42371
.
unalmis Apr 22, 2026
088d5a2
clarify documentation
unalmis Apr 22, 2026
3fc45c2
fix closure conversion
unalmis Apr 22, 2026
98c9f1b
safer condition for compelx objs
unalmis Apr 22, 2026
566d464
fix pitch_batch_size subtlety
unalmis Apr 23, 2026
cdb9bf1
.
unalmis Apr 23, 2026
d8ec4c5
.
unalmis Apr 23, 2026
571c7d5
Merge branch 'master' into ku/test
unalmis Apr 23, 2026
c5fe484
.
unalmis Apr 23, 2026
7c721b8
Merge branch 'ku/test' into ku/sparse_pullback
unalmis Apr 23, 2026
adf73b5
fix comment
unalmis Apr 23, 2026
346938d
Switch resolution to per field period to simplify use and analysis (#…
unalmis Apr 25, 2026
e18dfe8
add missing default value
unalmis Apr 26, 2026
8748442
Resolves the fixme comment so that gradients are consistent (#2185)
unalmis Apr 26, 2026
d8868fe
push file into zip
unalmis Apr 27, 2026
8676dbd
Resolve remaining comments in #2147
unalmis Apr 28, 2026
ac79068
fix param
unalmis Apr 28, 2026
fdf80fe
Merge branch 'master' into ku/test
f0uriest Apr 29, 2026
3fe1120
Merge branch 'master' into ku/test
f0uriest Apr 29, 2026
bf95c79
Merge branch 'ku/test' into ku/sparse_pullback
unalmis Apr 29, 2026
18234f8
rory stuff
unalmis Apr 29, 2026
b1f5da7
rory stuff 2
unalmis Apr 29, 2026
06e22a6
.
unalmis Apr 29, 2026
f921c72
rory stuff 3
unalmis Apr 29, 2026
6af9f0f
reuse yb in comment to avoid confusion with nufft eps
unalmis Apr 29, 2026
2de27b0
Merge branch 'master' into ku/test
unalmis Apr 30, 2026
9a365e0
Merge branch 'ku/test' into ku/sparse_pullback
unalmis Apr 30, 2026
9b9d666
Merge branch 'master' into ku/test
unalmis May 1, 2026
1002c49
Merge branch 'ku/test' into ku/sparse_pullback
unalmis May 1, 2026
f729192
Merge branch 'master' into ku/sparse_pullback
unalmis May 4, 2026
b39ab31
Merge branch 'master' into ku/sparse_pullback
unalmis May 4, 2026
1fd2258
Merge branch 'master' into ku/sparse_pullback
unalmis May 11, 2026
81cb1a9
address rory
unalmis May 18, 2026
eaaaff7
Merge branch 'master' into ku/sparse_pullback
unalmis May 19, 2026
4955144
Merge branch 'master' into ku/sparse_pullback
unalmis May 19, 2026
930569d
@f0uriest
unalmis Jun 8, 2026
2808447
update files
unalmis Jun 16, 2026
95c0e1d
Merge remote-tracking branch 'upstream/master' into ku/sparse_pullback
unalmis Jun 19, 2026
d558eae
use external package for sparse pullback
unalmis Jul 20, 2026
99ba3dc
Use external package for sparse support
unalmis Jul 20, 2026
18e0a63
Merge branch 'master' into ku/sparse_pullback
unalmis Jul 20, 2026
3c884e4
Add 'adv-jax-math' to Dependabot configuration
unalmis Jul 20, 2026
bc1eab0
.
unalmis Jul 20, 2026
becbefa
Merge branch 'master' into ku/sparse_pullback
unalmis Jul 20, 2026
5f0817a
Merge branch 'master' into ku/sparse_pullback
unalmis Jul 20, 2026
c8dc88c
merge
unalmis Jul 21, 2026
9a39020
Merge branch 'master' into ku/sparse_pullback
unalmis Jul 24, 2026
897a582
merge
unalmis Jul 26, 2026
3665e13
Merge branch 'master' into ku/sparse_pullback
unalmis Jul 28, 2026
10d6309
Merge
unalmis Jul 28, 2026
7ccaca7
Merge branch 'master' into ku/sparse_pullback
dpanici Jul 29, 2026
951c526
Merge branch 'master' into ku/sparse_pullback
unalmis Jul 29, 2026
20b025e
Merge branch 'master' into ku/sparse_pullback
unalmis Jul 31, 2026
807c13a
Merge branch 'master' into ku/sparse_pullback
unalmis Jul 31, 2026
f32aa76
Merge branch 'master' into ku/sparse_pullback
unalmis Jul 31, 2026
b5aad57
Merge branch 'master' into ku/sparse_pullback
unalmis Aug 3, 2026
4c32882
Merge branch 'master' into ku/sparse_pullback
dpanici Aug 13, 2026
ffa8f24
Merge branch 'master' into ku/sparse_pullback
dpanici Aug 13, 2026
a17a8f4
Dp/requested changes sparse (#2291)
dpanici Aug 26, 2026
f83456c
fix bug, forgot to change to use keyword for surf_batch_size
dpanici Aug 27, 2026
07418a4
surf_batch_size kwarg bugfix for old 1D computes
dpanici Aug 27, 2026
31c52d3
Merge branch 'master' into ku/sparse_pullback
dpanici Aug 27, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ updates:
- "orthax"
- "quadax"
- "jax-finufft"
- "adv-jax-math"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
Expand Down
13 changes: 10 additions & 3 deletions CHANGELOG.md
Comment thread
ddudt marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@ Changelog
Performance Improvements

- Improves memory management to reduce the base memory used during optimization while using `lsq-exact`, `lsq-auglag` and `fmin-auglag` optimizers.
- Sparse reverse-mode differentiation was introduced to yield significant performance improvements [#2170](https://github.com/PlasmaControl/DESC/pull/2170). Plumbing to use this method was added that will be progressively taken advantage of in the future.
- Speeds up ``field_line_integrate`` and ``trace_particles`` for filamentary coils (``Coil``, ``CoilSet``, ``MixedCoilSet``) by precomputing the constant source information, so that the ODE right hand side only evaluates a single fused Biot-Savart kernel instead of recomputing the coil geometry at every solver step.
- Improves the non-singular Biot-Savart kernel which should give a speed/memory improvement to objectives that compute magnetic field from coils such as ``QuadraticFlux``.

Breaking Changes and Deprecations

- The parameter ``num_transit`` in ``EffectiveRipple``, ``Gamma_c``, ``Bounce2D`` and related functions has been changed to ``field_period_transits``. This should make using a consistent resolution across different equilibria easier. The now-deprecated ``num_transit`` may still be used but note the equivalence ``field_period_transits = num_transit * grid.NFP``.
- The parameter ``Y_B`` in ``EffectiveRipple``, ``Gamma_c``, ``Bounce2D`` is now the resolution over a single field period rather than a full toroidal transit. This should make using a consistent resolution across different equilibria easier.
- Objectives using ``Bounce2D`` now do not support fwd mode differentiation for JAX versions <0.11.0.

Bug Fixes

- Fixes bug in ``auglag`` optimizers which prevented them from accepting solver hyperparameters.
Expand All @@ -16,6 +23,7 @@ Bug Fixes
``fmin-auglag`` with the default ``tr_method="exact"``, and in
``lsq-exact``/``lsq-auglag`` with ``tr_method="cho"``.


v0.17.3
-------

Expand Down Expand Up @@ -44,11 +52,11 @@ Bug Fixes
- Updates ``"reactor_QA"`` in ``desc.examples`` to fix this. Note that if using ``"reactor_QA"`` example from ``v0.16.0`` until this fix, the current profile in that example has this issue.
- Fixes bug in `CoilSet.from_symmetry` that ignored the passed in `check_intersection` value. This caused redundant checks in various other functions such as `plot_coils`.


Breaking Changes

- Name change in `_CoilObjective` replacing `coilset_mask` with `objective_mask`. Custom subclasses with `_broadcast_input="node"` that previously used `coilset_mask` should switch to `objective_mask`.


v0.17.2
-------

Expand All @@ -58,7 +66,6 @@ New Features
- Sub-objectives of an `ObjectiveFunction` can now have different `use_jit` values than the `ObjectiveFunction`. These objectives have to be built before building the `ObjectiveFunction`.
- Adds ``num_neighbors`` parameter to ``CoilSetMinDistance`` that limits the pairwise distance computation to the nearest neighbors per coil, reducing memory useage for large coilsets.
- Method to plot frequency spectrum of inverse stream map in field line coordinates ``Bounce2D.plot_angle_spectrum``.
- Method to compute bounce integrals in batches is now added to the public API ``Bounce2D.batch``.
- Initiated deprecation of ``Bounce2D.compute_fieldline_length`` in favor of ``eq.compute("V_psi")``.
- The quadrature resolution in ``Bounce2D.compute_fieldline_length`` now corresponds to the resolution over a single field period instead of the resolution over a toroidal transit.
- Adds an optional attribute `ion_density` to the `Equilibrium` class, to allow the ion density profile to be set independently of the electron density and effective atomic number. Also adds compute functions for ``"ni_rr"`` and ``"Zeff_rr"``.
Expand All @@ -68,6 +75,7 @@ New Features
Bug Fixes

- Fixes SyntaxError thrown when loading hdf5 data from file-like objects.
- Fixes ``pitch_batch_size`` argument getting ignored in compute functions.
- Fixes a bug in `OmnigenousField.change_resolution` when changing `L_B`.
- Scaling a `ScaledProfile` or taking power of a `PowerProfile` now only updates the `scale`/`power` attributes instead of nesting the `ScaledProfile`/`PowerProfile`s.
- `jax.Array`s in `_static_attrs` will be automatically converted to `np.ndarray` to prevent stalling code. In general, jax arrays should be omitted in `_static_attrs`.
Expand All @@ -79,7 +87,6 @@ Performance Improvements
- Now, `desc.compute._build_data_index` uses depth-first search algorithm to construct the dependency tree.
- Some of the default value computations at import time are removed (i.e. `desc.integrals.bounce_integral.default_quad`)
- [Significantly improves convergence of inverse stream maps](https://github.com/PlasmaControl/DESC/pull/1919).

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.

Suggested change
- [Significantly improves convergence of inverse stream maps](https://github.com/PlasmaControl/DESC/pull/1919).
- [Significantly improves convergence of inverse stream maps](https://github.com/PlasmaControl/DESC/pull/1919).
- Check-pointing to bounce integrals to improve speed and reduce memory of reverse mode differentiation.

- Check-pointing to bounce integrals to improve speed and reduce memory of reverse mode differentiation.
- Resolves a JAX memory regression in bounce integrals by avoiding materialization of a large tensor in memory. Previously, we had closed the issue by adding nuffts as a workaround. This update actually solves the issue for the case when a user specifies to not use nuffts as well.
- ``ObjectiveFunction.print_value`` can now use the previously computed ``compute_scaled_error`` values to print. For bounded objectives, we fall back to computing ``compute_unscaled``. Additionally, ``compute_scaled_error`` and array splitting are used in other parts of the code to prevent recompilation for one-time tasks, which makes initialization faster.

Expand Down
59 changes: 16 additions & 43 deletions desc/batching.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from functools import partial

from adv_jax_math import batch_map # noqa: F401
from jax._src.api import (
_check_input_dtype_jacfwd,
_check_input_dtype_jacrev,
Expand Down Expand Up @@ -197,6 +198,21 @@ def vmap_chunked(
- https://github.com/jax-ml/jax/issues/26689
- https://github.com/jax-ml/jax/issues/27591
- https://github.com/jax-ml/jax/issues/31919
- Due to an actively worked on issue in JAX,
https://docs.jax.dev/en/latest/jep/
Comment thread
unalmis marked this conversation as resolved.
2026-custom-derivatives.html#main-problem-descriptions,
this function can simply ignore custom derivative rules
of the function in wraps if ``chunk_size`` is not ``None``,
and therefore can damp the effeciency gains of ``sparse_pullback``.
Use ``batch_map`` instead to avoid this,
or try to make a hack with jax.custom_transforms to bypass this.
- Only out axes = 0 is supported.

See Also
--------
batch_map
If the function supports native vectorization, use ``batch_map`` instead
for the reasons discussed the docstring.

Parameters
----------
Expand Down Expand Up @@ -230,49 +246,6 @@ def vmap_chunked(
)


def batch_map(
fun, fun_input, /, batch_size=None, *, reduction=None, chunk_reduction=identity
):
"""Compute ``chunk_reduction(fun(fun_input))`` in batches.

This utility is like ``vmap_chunked`` except that ``fun`` is assumed to be
vectorized natively. No JAX vectorization such as ``vmap`` is applied to the
supplied function. This makes compilation faster and avoids the weaknesses of
applying JAX vectorization, such as executing all branches of code conditioned on
dynamic values. For example, this function would be useful for GitHub issue #1303.

Parameters
----------
fun : callable
Natively vectorized function.
fun_input : pytree
Data to split into batches to feed to ``fun``.
batch_size : int or None
Size of batches. If no batching should be done or the batch size is the
full input then supply ``None``.
reduction : callable or None
Binary reduction operation.
Should take two arguments and return one output, e.g. ``jnp.add``.
chunk_reduction : callable
Chunk-wise reduction operation.
Should typically apply ``reduction`` along the mapped axis,
e.g. ``jnp.add.reduce``.

Returns
-------
fun_output
Returns ``chunk_reduction(fun(fun_input))``.

"""
return (
chunk_reduction(fun(fun_input))
if batch_size is None
else _evaluate_in_chunks(
fun, batch_size, (0,), reduction, chunk_reduction, fun_input
)
)


def batched_vectorize(pyfunc, *, excluded=frozenset(), signature=None, chunk_size=None):
"""Define a vectorized function with broadcasting and batching.

Expand Down
Loading
Loading