Skip to content

Commit

Permalink
Update libraries to use JAX's limited (and ill-advised) trace-state-q…
Browse files Browse the repository at this point in the history
…uerying APIs rather than depending on JAX's deeper internals, which are about to change.

PiperOrigin-RevId: 678332660
  • Loading branch information
dougalm authored and learned_optimization authors committed Sep 24, 2024
1 parent 4bcaeb0 commit 143b3db
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions learned_optimization/jax_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,12 @@ def body_fn(_, operand):

def in_jit() -> bool:
"""Returns true if tracing jit."""
return "DynamicJaxprTrace" in str(
jax.core.thread_local_state.trace_state.trace_stack
)
if jax.__version_info__ <= (0, 4, 33):
return "DynamicJaxprTrace" in str(
jax.core.thread_local_state.trace_state.trace_stack
)

return jax.core.unsafe_am_i_under_a_jit_DO_NOT_USE()


Carry = TypeVar("Carry")
Expand Down

0 comments on commit 143b3db

Please sign in to comment.