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

Neuron support in Axlearn #566

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
add 'data' axis to fsdp axis
  • Loading branch information
apoorvtintin committed Jul 1, 2024
commit 6669a41090f2882ee3364bc9c0d5489e7adfd6a6
7 changes: 6 additions & 1 deletion axlearn/experiments/text/gpt/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,17 @@ def model_config(
batch_axis_names=batch_axis_names,
seq_axis_names="seq",
)

device_platform = np.asarray(jax.devices())[0].platform
Copy link
Contributor

Choose a reason for hiding this comment

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

jax.devices() during config building may be an unexpected dependency on global state -- should we take a platform arg or similar?

Copy link
Contributor Author

@apoorvtintin apoorvtintin Jul 24, 2024

Choose a reason for hiding this comment

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

We could change it, but I followed the pattern already used here

devices = jax.devices()

Please let me know if the platform flag is necessary, I can add it. Thanks!

# neuron uses Zero 3
apoorvtintin marked this conversation as resolved.
Show resolved Hide resolved
fsdp_axis_names = ("expert", "fsdp", "seq") if device_platform != 'neuron' else ("data", "expert", "fsdp", "seq")
apoorvtintin marked this conversation as resolved.
Show resolved Hide resolved

cfg.dtype = jnp.float32
# Shard some FFN and attention weights over multiple axes.
set_double_shard_weights_config(
cfg.decoder.transformer.layer,
batch_axis_names=batch_axis_names,
fsdp_axis_names=("expert", "fsdp", "seq"),
fsdp_axis_names=fsdp_axis_names,
tp_axis_names="model",
seq_axis_names=("seq",),
)
Expand Down