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

🕊️ Migration PPOv2 -> PPO #2174

Merged
merged 41 commits into from
Oct 11, 2024
Merged

🕊️ Migration PPOv2 -> PPO #2174

merged 41 commits into from
Oct 11, 2024

Conversation

qgallouedec
Copy link
Member

@qgallouedec qgallouedec commented Oct 4, 2024

What does this PR do?

Follows #2016

Fixes # (issue)

It basically:

  • Deletes PPO (including trainer, config, tests, examples, but not all, see my comment)
  • Renames PPOv2 to PPO (in trainer, config, examples, tests, doc, etc.)
  • Creates an alias PPOv2 for PPO

I've done my best, but it may break some code. To put things in perspective, PPO isn't as popular as it used to be, at the time of writing, the last PPO model created on the hub was two weeks ago.

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 qgallouedec changed the title Migration PPOv2 -> PPO 🕊️ Migration PPOv2 -> PPO Oct 4, 2024
@qgallouedec
Copy link
Member Author

qgallouedec commented Oct 8, 2024

While working on this, I noticed that most of our documentation and notebooks are based on PPO and may be outdated, relying on older datasets, models, references, etc. I believe updating all of our examples and guides falls outside the scope of this PR.

I recommend the following:

  • For now, keep the existing outdated documentation, guides, and notebooks as they are.
  • Begin a separate effort to rewrite these materials in future PR(s), primarily starting from scratch.

@qgallouedec qgallouedec marked this pull request as ready for review October 8, 2024 14:25
@@ -1,4 +1,4 @@
# Copyright 2022 The HuggingFace Team. All rights reserved.
Copy link
Member Author

Choose a reason for hiding this comment

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

This one is just the renaming of ppov2_config. the diff view makes no sense

@@ -11,1271 +11,53 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Copy link
Member Author

Choose a reason for hiding this comment

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

This one is just the tests/test_ppov2_trainer.py renamed. The diff view makes no sense

Copy link
Collaborator

@edbeeching edbeeching left a comment

Choose a reason for hiding this comment

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

LGTM apart from a comment about the examples and 1 change

trl/trainer/ppov2_config.py Outdated Show resolved Hide resolved
docs/source/example_overview.md Show resolved Hide resolved
Copy link
Member

@lewtun lewtun left a comment

Choose a reason for hiding this comment

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

Thanks for the migration @qgallouedec ! Overall LGTM with some nits about the docs since we can take this opportunity to nuke a bunch of outdated stuff

docs/source/customization.mdx Outdated Show resolved Hide resolved
docs/source/customization.mdx Outdated Show resolved Hide resolved
docs/source/customization.mdx Outdated Show resolved Hide resolved
docs/source/customization.mdx Show resolved Hide resolved
docs/source/customization.mdx Outdated Show resolved Hide resolved
docs/source/customization.mdx Outdated Show resolved Hide resolved
docs/source/customization.mdx Show resolved Hide resolved
docs/source/detoxifying_a_lm.mdx Outdated Show resolved Hide resolved
trl/trainer/ppo_config.py Show resolved Hide resolved
horizon: float = 10000.0
gamma: float = 1.0
lam: float = 0.95
exp_name: str = os.path.basename(__file__)[: -len(".py")]
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps it's a bug in the GitHub diff, but this looks repeated from above

@qgallouedec qgallouedec merged commit 70036bf into main Oct 11, 2024
9 of 10 checks passed
@qgallouedec qgallouedec deleted the migration-ppo branch October 11, 2024 15:28
@sygi
Copy link

sygi commented Oct 18, 2024

Would it be possible to keep the "old" PPO code around until the new trainer achieves feature parity (in particular peft and arbitrary reward support) with the old one?

@Void-025
Copy link

I would also like to have the old PPO code kept around, I was previously using the old ppotrainer.step() function to provide my own reward values for each query/response pair, but there doesn't seem to be an equivalent in PPOv2, unless I'm missing some other way of doing this?

@qgallouedec
Copy link
Member Author

You should use trl==0.11

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.

6 participants