Open charlesm93 opened 3 years ago
I think the best we could do here is return NaN
instead of a valid answer, since it isn't possible to raise errors from within XLA.
Returning NaN
would certainly be an improvement.
I do find warning and error messages extremely helpful, especially when writing intricate code. Specifying a model with TensorFlow Probability built on JAX becomes quite challenging when I need to hunt down where in the code the NaN
comes from. By contrast, a language such as Stan provides detailed information about what caused the issue (e.g. "ode integrator reached the maximum number of steps", "cannot evaluate gamma density for a negative variable", etc ). Then again, if this is a constraint imposed by XLA, I'm not sure what the best course of action might be.
Well, we can certainly imagine passing status codes around explicitly. We just can't use "exceptions", since those don't exist in XLA HLO.
How about simply documenting this more clearly? The caller sets both the maximum step count and the tolerance, so it might be reasonable for them to expect a "whichever happens first" policy, provided we make that clear.
Please:
When
odeint
fails to meet the target precision, as determined by the relative and absolute tolerance, no error or warning message is issued. Here's a toy example demonstrating the problem:With this max number of steps, the final state returned by
odeint
isNow, let's set
mxstep = 1
. Thenodeint
returnswhich is patently wrong. There are however no warning messages suggesting this solution might not be reliable.