Skip to content

LogLikelihood transformations and decompositions (FP32 prep)#431

Draft
vhaasteren wants to merge 3 commits intonanograv:devfrom
vhaasteren:sp-transformations
Draft

LogLikelihood transformations and decompositions (FP32 prep)#431
vhaasteren wants to merge 3 commits intonanograv:devfrom
vhaasteren:sp-transformations

Conversation

@vhaasteren
Copy link
Copy Markdown
Member

Add likelihood transform support and split varying/constant log-likelihood terms

Summary

Extends LogLikelihood to support transformed bases ("native", "Lw", "GtLw") and to optionally return the log-likelihood split into parameter-varying vs. constant terms (e.g., when white noise and delay params are fixed). This enables single-precision workflows and numerical verification.

Changes

  • transform parameter on LogLikelihood: LogLikelihood now accepts a transform argument ("native", "Lw", "GtLw"). The transform selects how the rNr/logdet data term is computed via get_transformed_rNr_logdet.
  • Unified get_transformed_rNr_logdet: All transforms (native, Lw, GtLw) go through a single get_transformed_rNr_logdet API. Each pulsar returns a tuple whose first element is the parameter-varying part and the rest are constant terms (e.g., dimension counts, log determinants).
  • Return format: For transform="native" (default), returns a single scalar log-likelihood (backward compatible). For transform="Lw" or "GtLw", returns (loglike_varying, loglike_remainder) — the part that depends on the prior matrix B vs. the rest.
  • TransformedLogLikelihood removed: Logic folded into LogLikelihood; the transform is controlled by the constructor argument.

Backward compatibility

Existing callers that do not pass transform get transform="native" and receive a scalar. PTAs built with lnlikelihood=LogLikelihood (or LogLikelihoodDenseCholesky) behave as before.

Usage

Default: scalar log-likelihood (unchanged behavior)

loglike = pta.get_lnlikelihood(params)

Transformed mode: returns (varying, remainder) for single-precision use

pta = PTA(models, lnlikelihood=lambda pta: LogLikelihood(pta, transform="GtLw"))
loglike_varying, loglike_remainder = pta.get_lnlikelihood(params)
total = loglike_varying + loglike_remainder

@vhaasteren vhaasteren marked this pull request as draft February 11, 2026 07:28
@vhaasteren vhaasteren changed the base branch from master to dev February 11, 2026 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant