-
There seem to be a few options for host callback functions which return data:
Could someone with knowledge of these methods possibly compare/contrast them, highlighting which (if any) are preferred? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 19 replies
-
Thanks for the question! These are all a bit different:
|
Beta Was this translation helpful? Give feedback.
-
is jax.pure_callback compatible with pjit? |
Beta Was this translation helpful? Give feedback.
-
What does "guaranteed execution" mean in the document? And what is the correct way to do async callback, like the old |
Beta Was this translation helpful? Give feedback.
-
But why Another question is that are callbacks executed asynchronously? |
Beta Was this translation helpful? Give feedback.
Thanks for the question! These are all a bit different:
jax.make_array_from_callback
is just about array creation, like an analogue ofjnp.array
but more general to work in distributed multi-controller scenarios. It's different from the other two.jax.pure_callback
is a way to call a functionally pure Python function within staged-out (e.g. jitted) code. It's one of the new set of callbacks, along with e.g.jax.debug.debug_callback
.jax.experimental.host_callback
is essentially deprecated in the sense that we don't recommend using it if you can avoid it, and instead we suggest usingjax.debug.debug_callback
orjax.pure_callback
where possible.