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

Clean up local_sgd and diloco #120

Merged
merged 1 commit into from
Mar 4, 2025
Merged

Clean up local_sgd and diloco #120

merged 1 commit into from
Mar 4, 2025

Conversation

H-Huang
Copy link
Member

@H-Huang H-Huang commented Mar 1, 2025

Changes:

  • Remove backup parameters from local_sgd
  • clean up tests
  • Make DiLoCo not a subclass of local_sgd (there is some code repetition, but I think this is okay if we want to use these as an example for using our torchft APIs)

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Meta Open Source bot. label Mar 1, 2025
@H-Huang H-Huang force-pushed the diloco branch 3 times, most recently from e4c31a3 to 1411aeb Compare March 1, 2025 03:52
@H-Huang H-Huang requested a review from d4l3k March 3, 2025 22:30
Copy link
Member

@d4l3k d4l3k left a comment

Choose a reason for hiding this comment

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

LGTM

works.append(self._manager.allreduce(p.data.detach()))

# Create a new tensor to store the averaged parameter
avg_param = p.data.clone()
Copy link
Member

Choose a reason for hiding this comment

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

Should we be checking/setting p.data.grad to None to minimize memory impact from the copy here?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think p.data.grad should always be None, but I can add a line to ensure it is None. I think only p.grad gets set, not sure when p.data.grad would get updated

@H-Huang H-Huang merged commit 082753c into pytorch:main Mar 4, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Meta Open Source bot.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants