Overview
A focused prior/message backend audit performed while fixing #1458 found four additional, independently reproducible JAX tracing failures. Each affected method accepts an xp argument but still calls NumPy/SciPy directly, so a traced value is coerced through __array__ and raises jax.errors.TracerArrayConversionError.
This is not covered by the completed JAX-native prior transforms in #1262 or the NumPy/statistical fixes tracked in #1331.
Confirmed failures
On current main, each of these fails under jax.jit:
GammaMessage.log_partition(xp=jnp)
- uses
scipy.special.gammaln(alpha) and np.log(beta)
BetaMessage.log_partition(xp=jnp)
- uses
scipy.special.betaln(*self.parameters)
Log._instance_for_arguments(..., xp=jnp)
- ignores
xp and calls np.log
Log10._instance_for_arguments(..., xp=jnp)
- ignores
xp and calls np.log10
Minimal shape of the reproducer:
jax.jit(
lambda x: GammaMessage(x + 1, x + 2).log_partition(xp=jnp)
)(jnp.asarray(2.0))
Equivalent JIT calls fail for the other three paths.
Proposed fix
- Dispatch Gamma/Beta special functions through a JAX-compatible backend when
xp is JAX, while preserving SciPy on the NumPy path.
- Use
xp.log / xp.log10 in the compound prior modifiers.
- Confirm whether compound priors must forward
xp recursively to child prior models; add coverage for nested modifiers/compound expressions if so.
- Add scalar and batched
jax.jit regression tests with NumPy/SciPy numerical parity.
- Keep statistical semantics unchanged.
Verification
- Direct tests must fail on current
main with TracerArrayConversionError and pass after the fix.
- Run the focused prior/message suites and full PyAutoFit suite.
- Exercise at least one nested compound-prior expression through the real
instance_for_arguments(..., xp=jnp) API.
Relationship to #1458
#1458 addresses fixed-array construction and GammaMessage.to_canonical_form. These four failures are separate call paths and should remain a follow-up PR to keep that repair reviewable.
Overview
A focused prior/message backend audit performed while fixing #1458 found four additional, independently reproducible JAX tracing failures. Each affected method accepts an
xpargument but still calls NumPy/SciPy directly, so a traced value is coerced through__array__and raisesjax.errors.TracerArrayConversionError.This is not covered by the completed JAX-native prior transforms in #1262 or the NumPy/statistical fixes tracked in #1331.
Confirmed failures
On current
main, each of these fails underjax.jit:GammaMessage.log_partition(xp=jnp)scipy.special.gammaln(alpha)andnp.log(beta)BetaMessage.log_partition(xp=jnp)scipy.special.betaln(*self.parameters)Log._instance_for_arguments(..., xp=jnp)xpand callsnp.logLog10._instance_for_arguments(..., xp=jnp)xpand callsnp.log10Minimal shape of the reproducer:
Equivalent JIT calls fail for the other three paths.
Proposed fix
xpis JAX, while preserving SciPy on the NumPy path.xp.log/xp.log10in the compound prior modifiers.xprecursively to child prior models; add coverage for nested modifiers/compound expressions if so.jax.jitregression tests with NumPy/SciPy numerical parity.Verification
mainwithTracerArrayConversionErrorand pass after the fix.instance_for_arguments(..., xp=jnp)API.Relationship to #1458
#1458 addresses fixed-array construction and
GammaMessage.to_canonical_form. These four failures are separate call paths and should remain a follow-up PR to keep that repair reviewable.