Skip to content

Conversation

lewtun
Copy link
Member

@lewtun lewtun commented Mar 24, 2025

What does this PR do?

This PR exposes a num_completions_to_print arg in the GRPOConfig so that users can control how many completions are printed to the terminal. I found the default (log everything) made the logs very verbose / large.

After discussing with @edbeeching I decided not to expose this for WandB since there we don't have to worry about the logs becoming overloaded.

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.

@@ -905,6 +907,8 @@ def _generate_and_score_completions(
"reward": rewards.tolist(),
}
df = pd.DataFrame(table)
if self.num_completions_to_log is not None:
Copy link
Member Author

Choose a reason for hiding this comment

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

For consistency, I've enabled subsampling here but we could skip it for WandB since it doesn't really matter if there's a lot of completions AFAIK

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think for wandb we should just keep everything? It is more of an issue of the logs being spammed

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds good, I'll revert

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

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 comment What happens with num_samples=0 ?

@lewtun lewtun changed the title Enable number of logged completions to be set Enable number of printed completions to be set Mar 24, 2025
Copy link
Member

@qgallouedec qgallouedec left a comment

Choose a reason for hiding this comment

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

LGTM :)

@qgallouedec
Copy link
Member

The CI failing is not related btw, you can safely ignore

@qgallouedec
Copy link
Member

>>> print_prompt_completions_sample(prompts, completions, rewards, 42, -1)
>>> print_prompt_completions_sample(prompts, completions, rewards, 42, 0)
>>> print_prompt_completions_sample(prompts, completions, rewards, 42, 1)
╭────────────── Step 42 ───────────────╮
│ ┏━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━┓ │
│ ┃ PromptCompletionReward ┃ │
│ ┡━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━┩ │
│ │ The sky isblue.     │   0.12 │ │
│ └────────────┴────────────┴────────┘ │
╰──────────────────────────────────────╯
>>> print_prompt_completions_sample(prompts, completions, rewards, 42, 2)
╭─────────────── Step 42 ────────────────╮
│ ┏━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━┓ │
│ ┃ PromptCompletionReward ┃ │
│ ┡━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━┩ │
│ │ The sky isblue.       │   0.12 │ │
│ ├────────────┼──────────────┼────────┤ │
│ │ The sun isin the sky. │   0.69 │ │
│ └────────────┴──────────────┴────────┘ │
╰────────────────────────────────────────╯
>>> print_prompt_completions_sample(prompts, completions, rewards, 42, 3)
╭─────────────── Step 42 ────────────────╮
│ ┏━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━┓ │
│ ┃ PromptCompletionReward ┃ │
│ ┡━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━┩ │
│ │ The sky isblue.       │   0.12 │ │
│ ├────────────┼──────────────┼────────┤ │
│ │ The sun isin the sky. │   0.69 │ │
│ └────────────┴──────────────┴────────┘ │
╰────────────────────────────────────────╯

@lewtun lewtun merged commit 1a9387b into main Mar 25, 2025
9 of 14 checks passed
@lewtun lewtun deleted the set-log-samples branch March 25, 2025 07:47
toslali-ibm pushed a commit to toslali-ibm/trl that referenced this pull request Mar 25, 2025
Co-authored-by: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>
Co-authored-by: Quentin Gallouédec <gallouedec.quentin@gmail.com>
kashif pushed a commit to kashif/trl that referenced this pull request Mar 28, 2025
Co-authored-by: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>
Co-authored-by: Quentin Gallouédec <gallouedec.quentin@gmail.com>
yxliu-TAMU pushed a commit to mincheolseong/ECEN743-GRPO-Project-Proposal that referenced this pull request Apr 20, 2025
Co-authored-by: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>
Co-authored-by: Quentin Gallouédec <gallouedec.quentin@gmail.com>
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.

4 participants