Skip to content

FEAT: define pytrees for bilby types#1110

Open
ColmTalbot wants to merge 10 commits into
bilby-dev:mainfrom
ColmTalbot:pytrees
Open

FEAT: define pytrees for bilby types#1110
ColmTalbot wants to merge 10 commits into
bilby-dev:mainfrom
ColmTalbot:pytrees

Conversation

@ColmTalbot

@ColmTalbot ColmTalbot commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

This PR adds JAX pytree definitions for most classes in Bilby including:

  • all (I think) priors
  • all likelihoods
  • the GW interferometer and waveform generator classes

Defining pytrees allows these classes to be used as inputs to JIT-compiled (or other transformations) functions and can dramatically reduce compilation/execution time.

As an example, I've used this in a case where I'm analyzing lots of events in series.
I can then JIT-compile an outer function that takes a likelihood as input and everything works smoothly.

The basic breakdown of pytree definitions relies on breaking the constituent parts of the class into leaves and auxillary data.
Any change in the auxillary data causes a recompilation, whereas leaves are traced through the functions allowing for them to be changed without recompilation.
As an example, the shape of an array would be auxillary data, but the values themselves a leaf/leaves.

TODO:

  • more testing, especially of likelihoods

@ColmTalbot ColmTalbot marked this pull request as draft July 7, 2026 19:11
@ColmTalbot ColmTalbot marked this pull request as ready for review July 9, 2026 18:12
@ColmTalbot ColmTalbot requested a review from a team July 10, 2026 13:42
@ColmTalbot ColmTalbot added this to the 3.0.0 milestone Jul 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant