Skip to content

Commit

Permalink
Improve usability of chexify.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 578145061
  • Loading branch information
hbq1 authored and ChexDev committed Oct 31, 2023
1 parent 3c9af1b commit 13f9356
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions chex/_src/asserts_chexify.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,16 @@ def _chexified_fn(*args, **kwargs):
'Nested @chexify wrapping is disallowed. '
'Make sure that you only wrap the function at the outermost level.')

if _ai.has_tracers((args, kwargs)):
raise RuntimeError(
'@chexify must be applied on top of all (p)jit/pmap transformations'
' (otherwise it will result in `UnexpectedTracerError`). If you have'
' functions that use value assertions, do not wrap them'
' individually -- just wrap the outermost function after'
' applying all your JAX transformations. See the example at'
'https://github.com/google-deepmind/chex#static-and-value-aka-runtime-assertions'
)

if async_check:
# Check completed calls.
while async_check_futures and async_check_futures[0].done():
Expand Down

0 comments on commit 13f9356

Please sign in to comment.