Skip to content

save model in global rank 0 in multinode #1357

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

Merged
merged 2 commits into from
Jun 15, 2025
Merged

Conversation

IceCreamMilkyTea
Copy link
Contributor

No description provided.

@facebook-github-bot
Copy link
Contributor

Hi @IceCreamMilkyTea!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

Copy link

netlify bot commented Jun 15, 2025

Deploy Preview for pytorch-examples-preview canceled.

Name Link
🔨 Latest commit 7de4898
🔍 Latest deploy log https://app.netlify.com/projects/pytorch-examples-preview/deploys/684e89929a7e610008985696

@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@msaroufim msaroufim requested review from Copilot and msaroufim June 15, 2025 22:54
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR focuses on ensuring that model snapshots are saved only on the global rank 0 node in a multi-node distributed training setup, thereby preventing multiple nodes from redundantly saving models. Key changes include updating the sampler epoch setting in the training loop and modifying the condition for saving model snapshots by replacing self.local_rank with self.global_rank.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
distributed/minGPT-ddp/mingpt/trainer.py Added a conditional check to update the epoch for the sampler only during training.
distributed/ddp-tutorial-series/multinode.py Updated snapshot saving condition to check self.global_rank instead of self.local_rank.
Comments suppressed due to low confidence (1)

distributed/ddp-tutorial-series/multinode.py:74

  • Ensure that self.global_rank is properly initialized and consistent across all nodes to guarantee that only the intended process saves the model snapshot.
if self.global_rank == 0 and epoch % self.save_every == 0:

@msaroufim msaroufim merged commit 5cc81aa into pytorch:main Jun 15, 2025
5 checks passed
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.

3 participants