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

Multi-node training support #440

Merged
merged 39 commits into from
Feb 29, 2024
Merged

Multi-node training support #440

merged 39 commits into from
Feb 29, 2024

Conversation

michaelbenayoun
Copy link
Member

@michaelbenayoun michaelbenayoun commented Jan 25, 2024

This PR adds support for multi-node training.

  • Check training TP + PP on multiple nodes with llama-7b
  • Check training TP + PP on multiple nodes with llama-70b
  • Check that files are pushed to the remote cache properly (with and without custom remote cache)
  • Test evaluation with PP on multiple nodes
  • Check that the logged loss and metrics are correct

In coming PRs:

  • Add better support for gradient checkpointing (full vs feature to specify which layers to use)
  • Handle GQA better with the custom layer for neuronx_distributed

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@5cp 5cp linked an issue Feb 23, 2024 that may be closed by this pull request
@michaelbenayoun michaelbenayoun marked this pull request as ready for review February 26, 2024 18:15
Copy link
Collaborator

@JingyaHuang JingyaHuang left a comment

Choose a reason for hiding this comment

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

Multi node is huge, thanks for the work 🎊 . The PR looks good to me, just left some minor nits. Wonder if @michaelbenayoun if it's possible to test the least functionality with CIs or other paths(I know setting up for multiple nodes is tricky...

optimum/commands/neuron/cache.py Outdated Show resolved Hide resolved
optimum/neuron/distributed/base.py Outdated Show resolved Hide resolved
optimum/neuron/distributed/decoder_models.py Outdated Show resolved Hide resolved
optimum/neuron/distributed/decoder_models.py Outdated Show resolved Hide resolved
optimum/neuron/distributed/decoder_models.py Outdated Show resolved Hide resolved
optimum/neuron/distributed/decoder_models.py Outdated Show resolved Hide resolved
optimum/neuron/distributed/encoder_decoder_models.py Outdated Show resolved Hide resolved
@@ -615,6 +670,34 @@ def parameter_can_be_initialized(model: torch.nn.Module, parent_module: torch.nn
)


@requires_neuronx_distributed
def apply_activation_checkpointing(
model: Union[torch.nn.Module, "NxDPPModel"],
Copy link
Collaborator

Choose a reason for hiding this comment

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

No need for quote neither

Copy link
Member Author

Choose a reason for hiding this comment

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

Here it is needed since if neuronx_distributed is not available it will not be imported.

optimum/neuron/utils/training_utils.py Outdated Show resolved Hide resolved
@michaelbenayoun
Copy link
Member Author

We test settings with TP + PP, but testing the multi-node setting is more tricky, it requires to create a node cluster, etc. For now let's keep it like that.

Copy link
Collaborator

@dacorvo dacorvo left a comment

Choose a reason for hiding this comment

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

I only looked at the part that is related to the cache: I would rather move the import inside the utils to avoid multiple imports.

optimum/neuron/utils/hub_neuronx_cache.py Outdated Show resolved Hide resolved
optimum/commands/neuron/cache.py Outdated Show resolved Hide resolved
@michaelbenayoun
Copy link
Member Author

michaelbenayoun commented Feb 29, 2024

Merging, tested on custom instances.

@michaelbenayoun michaelbenayoun merged commit 0916761 into main Feb 29, 2024
12 checks passed
@michaelbenayoun michaelbenayoun deleted the multi_node_training branch February 29, 2024 14:51
@shamanez
Copy link

@michaelbenayoun can we conduct multi-node training with Mistral?

@michaelbenayoun
Copy link
Member Author

Yes it should be!
We haven't run many experiments for now, but support is here.

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.

Hang while testing single and multi-node llama training with TP=8, PP=1
5 participants