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

πŸ§‘β€πŸ€β€πŸ§‘ Proper metrics gathering across ranks before logging #2474

Merged
merged 6 commits into from
Jan 7, 2025

Conversation

zhc7
Copy link
Contributor

@zhc7 zhc7 commented Dec 13, 2024

according to #2468

What does this PR do?

Fixes #2468

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a GitHub issue? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines.
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@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.

@qgallouedec
Copy link
Member

I realized that the problem was in fact not only confined to DPO but also to other trainers. So I thought twice about the approach, and I think the right solution is actually to gather at the time these metrics are calculated. It's the most logical and it's what's done in the other trainers.
Thanks for spotting on the issue, I'll wait until the CI is green and merge.

@kashif
Copy link
Collaborator

kashif commented Jan 7, 2025

@zhc7 accelerate has a dedicated helper for metrics: https://huggingface.co/docs/accelerate/en/package_reference/accelerator#accelerate.Accelerator.gather_for_metrics which is what is recommended to be used

@qgallouedec
Copy link
Member

Valid point! thanks @kashif. I generalised gather_for_metrics in 17383f9

@qgallouedec qgallouedec changed the title dpo_trainer gather metrics across ranks before logging πŸ§‘β€πŸ€β€πŸ§‘ Proper metrics gathering across ranks before logging Jan 7, 2025
@qgallouedec qgallouedec merged commit a50124d into huggingface:main Jan 7, 2025
13 checks passed
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.

DPOTrainer log metrics are not gathered and meaned across ranks
4 participants