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

[nnx] disallow Array leaves #4172

Merged
merged 1 commit into from
Sep 5, 2024
Merged

[nnx] disallow Array leaves #4172

merged 1 commit into from
Sep 5, 2024

Conversation

copybara-service[bot]
Copy link

@copybara-service copybara-service bot commented Sep 5, 2024

[nnx] disallow Array leaves

Numpy and JAX Array's are no longer consider state leaves. This makes the structure of the State completely determined by Variables, which apart from being more predictable it produces structural stability invariant to leaf type changes which let to issues such as #4142.

class Foo(nnx.Module):
  def __init__(self):
    self.a = jnp.array(1) # no longer allowed, instead...
    self.b = nnx.Param(jnp.array(1)) # just use Variables

Also migrates all remaining tests from pytest to absl to ensure they are tested correctly internally.

@copybara-service copybara-service bot force-pushed the test_670949705 branch 8 times, most recently from df0f0e2 to c1ff648 Compare September 5, 2024 14:54
Numpy and JAX Array's are no longer consider state leaves. This makes the structure of the State completely determined by Variables, which apart from being more predictable it produces structural stability invariant to leaf type changes which let to issues such as #4142.

```python
class Foo(nnx.Module):
  def __init__(self):
    self.a = jnp.array(1) # no longer allowed, instead...
    self.b = nnx.Param(jnp.array(1)) # just use Variables
```

Also migrates all remaining tests from pytest to absl to ensure they are tested correctly internally.

PiperOrigin-RevId: 671372717
@copybara-service copybara-service bot merged commit 90715be into main Sep 5, 2024
@copybara-service copybara-service bot deleted the test_670949705 branch September 5, 2024 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants