ENH: compile estimators entirely with JAX - #582
Open
grayson-helmholz wants to merge 2 commits into
Open
Conversation
redeboer
force-pushed
the
ENH/jit-estimators
branch
from
August 31, 2026 14:44
f5b4825 to
1236b1b
Compare
redeboer
force-pushed
the
ENH/jit-estimators
branch
from
September 1, 2026 08:59
1236b1b to
2553167
Compare
redeboer
reviewed
Sep 1, 2026
Member
There was a problem hiding this comment.
⚠️ Performance Alert ⚠️
Possible performance regression was detected for benchmark 'TensorWaves benchmark results'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.
| Benchmark suite | Current: 3b506e9 | Previous: f5c1db9 | Ratio |
|---|---|---|---|
benchmarks/ampform.py::TestJPsiToGammaPiPi::test_fit[10000-jax] |
0.6168525486949856 iter/sec (stddev: 0) |
1.439081184425215 iter/sec (stddev: 0) |
2.33 |
This comment was automatically generated by workflow using github-action-benchmark.
redeboer
force-pushed
the
ENH/jit-estimators
branch
from
September 1, 2026 09:30
2553167 to
3b506e9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #570
⚙️ Enhancements
On the JAX backend,
ChiSquaredandUnbinnedNLLare now JIT-compiled as a whole, instead of only JIT-compiling the wrapped function. The estimator body is built once in the constructor as a pure kernel over(parameters, *data)and wrapped injax.jit, so the reduction, the normalization, and the function evaluation all fuse into a single compiled call that is reused across evaluations. A regression test asserts that a fit loop traces the kernel exactly once.The analytic
gradient()is nowjax.jit(jax.grad(core))over that same kernel, differentiated with respect to itsparametersargument. It previously differentiatedself.__call__, which forced a re-trace through the bound method on every call.Data samples are converted to backend arrays once, in the constructor, so JIT-compiled evaluations no longer pay a host-to-device transfer per call.
❗ Behavioral changes
Estimators now import and initialize JAX when they are constructed rather than on the first gradient call, so a
configure(jax_precision=...)call made before construction is respected. Estimator results are computed at the configured precision, where a fixed x64 flag was effectively assumed before.Parameter values handed to an estimator are coerced to
floatorcomplexbefore evaluation. This keeps JIT input types stable — anintvalue would otherwise re-trace the kernel as soon as the optimizer turns it into a float — but it means integer parameter values no longer reach the wrapped function as integers.Squash commit messages