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] add partial_init #3674

Merged
merged 1 commit into from
Feb 21, 2024
Merged

[nnx] add partial_init #3674

merged 1 commit into from
Feb 21, 2024

Conversation

cgarciae
Copy link
Collaborator

@cgarciae cgarciae commented Feb 1, 2024

What does this PR do?

Adds the Module.partial_init classmethod which makes it easier to initialize Module while reusing some preexisting State.


graphdef: GraphDef[M]
state: State
state, graphdef = jax.jit(_partial_init_constructor)()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add the option to pass in kwargs into jax.jit? e.g. if the user wanted to pass in shardings. Or can they do that at the top level if they jit partial_init?

Copy link
Collaborator Author

@cgarciae cgarciae Feb 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be tricky. Also NNX Variable applies sharding constraints if available so you should use that API instead.

@copybara-service copybara-service bot merged commit 736d133 into main Feb 21, 2024
21 checks passed
@copybara-service copybara-service bot deleted the nnx-partial-init branch February 21, 2024 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants