equinox icon indicating copy to clipboard operation
equinox copied to clipboard

Option for `EQX_ON_ERROR="off"`

Open michael-0brien opened this issue 2 months ago • 2 comments

I am using equinox.error_if in library code, particularly in __init__s to check whether or not parameters take on allowed values. It is important that our classes can be instantiated across JIT boundaries, so we must use runtime checking.

Beyond myself, for use in library code it would be very useful to have EQX_ON_ERROR="off" to optionally remove all uses of jax.lax.cond in compiled programs for end-users (for GPU performance). Would Equinox accept a PR with this feature?

michael-0brien avatar Oct 24 '25 14:10 michael-0brien

So I considered this, but ended up settling on EQX_ON_ERROR=nan instead, which struck me as a safer alternative.

I take your point that this may result in reduced performance - JAX/XLA/etc maybe isn't smart enough to speculatively execute through a lax.cond.

I'd be happy to take a PR on this :)

patrick-kidger avatar Oct 24 '25 20:10 patrick-kidger

This makes sense. This and the nan option both seem like they would have their use cases!

michael-0brien avatar Oct 24 '25 21:10 michael-0brien