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

SPMD for initializing model using nnx.jit #4129

Open
mmorinag127 opened this issue Aug 18, 2024 · 1 comment
Open

SPMD for initializing model using nnx.jit #4129

mmorinag127 opened this issue Aug 18, 2024 · 1 comment
Labels
Priority: P1 - soon Response within 5 business days. Resolution within 30 days. (Assignee required)

Comments

@mmorinag127
Copy link

I would like to ask an example for initializing and updating a model using nnx.jit with SPMD.
Is there any relevant example?

@cgarciae cgarciae added the Priority: P1 - soon Response within 5 business days. Resolution within 30 days. (Assignee required) label Aug 20, 2024
@cgarciae
Copy link
Collaborator

nnx.jit's API is changing very soon (#3963) according to #4107. Currently you could use nnx.iter_graph to traverse the entire model and use with jax.device_put to shard the arrays inside Variables.

with path, parent in nnx.iter_graph(model):
  if isinstance(parent, nnx.Module):
    for name, value in vars(parent).items():
      if isinstance(value, nnx.Variable):
        sharding = ...
        value.value = jax.device_put(value.value, sharding)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: P1 - soon Response within 5 business days. Resolution within 30 days. (Assignee required)
Projects
None yet
Development

No branches or pull requests

2 participants