-
I find it hard to use assertion in JAX.
And the assertion can be easily disabled by:
However, according to the document of
This workaround may fail when using with |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Unfortunately, there's no supported way to do runtime value assertions in JAX. One main reason for this is that some accelerators supported by JAX literally have no path for raising errors at runtime. You can do various imperfect workarounds using callbacks, but those are not recommended. Better would be to modify your programming style to avoid the need for runtime value assertions. It takes some getting used to, but we find it works pretty well in practice. Another option is to use the |
Beta Was this translation helpful? Give feedback.
Unfortunately, there's no supported way to do runtime value assertions in JAX. One main reason for this is that some accelerators supported by JAX literally have no path for raising errors at runtime.
You can do various imperfect workarounds using callbacks, but those are not recommended. Better would be to modify your programming style to avoid the need for runtime value assertions. It takes some getting used to, but we find it works pretty well in practice.
Another option is to use the
jax.experimental.checkify
module, which allows you to propagate value-based errors using a functional approach supported by JAX. It's still somewhat rough around the edges, but there's some ongoing work t…