-
I'm writing a function that should never be run with JIT. I want to add an |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
JAX deliberately does not provide any API for this. Code with logic that branches on trace state is an anti-pattern and should be avoided: for example, it might cause autodiff to silently return wrong results if you use different codepaths when tracing and when not. If your goal is to fail if a function is being traced, one way to do so would be to write code that fails under tracing; e.g. |
Beta Was this translation helpful? Give feedback.
JAX deliberately does not provide any API for this. Code with logic that branches on trace state is an anti-pattern and should be avoided: for example, it might cause autodiff to silently return wrong results if you use different codepaths when tracing and when not.
If your goal is to fail if a function is being traced, one way to do so would be to write code that fails under tracing; e.g.
jnp.unique(0)
would raise aConcretizationTypeError
under tracing. That may not be a very satisfying answer though.