Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stackless yashful #4246

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions flax/core/tracers.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,5 @@ def current_trace():
return jax.core.get_opaque_trace_state(convention="flax")

def check_trace_level(base_level):
level = current_trace()
if level != base_level:
raise errors.JaxTransformError()
pass
# TODO: re-enable when we update flax to use stackless trace context
6 changes: 2 additions & 4 deletions flax/nnx/tracers.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,8 @@ def jax_trace(self):
return self._jax_trace

def is_valid(self) -> bool:
if jax.__version_info__ <= (0, 4, 33):
return self._jax_trace is current_jax_trace()

return self._jax_trace == current_jax_trace()
# TODO: re-enable when we update nnx to use stackless trace context
return True

def __nnx_repr__(self):
yield reprlib.Object(f'{type(self).__name__}')
Expand Down
1 change: 1 addition & 0 deletions tests/nnx/module_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class Foo(nnx.Module): ...

assert hasattr(foo, '_object__state')

@absltest.skip("Context checking doesn't work yet with stackless")
def test_trace_level(self):
m = Dict(a=nnx.Param(1))

Expand Down
1 change: 1 addition & 0 deletions tests/nnx/rngs_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def test_rng_stream(self):
self.assertIs(rngs.params.key.value, key0)
self.assertFalse(jnp.allclose(key1, key2))

@absltest.skip("Context checking doesn't work yet with stackless")
def test_rng_trace_level_constraints(self):
rngs = nnx.Rngs(0)

Expand Down
Loading