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

Change logging level from warning to info for max_steps overriding num_train_epochs #34810

Merged
merged 2 commits into from
Nov 21, 2024

Conversation

qgallouedec
Copy link
Member

@qgallouedec qgallouedec commented Nov 19, 2024

What does this PR do?

Passing max_step is a supported feature, and therefore should not raise a warning. I suggest lowering the level to info.

Alternatively, we could have an additional parameter like ignore_max_step_warning but this seems overengineered.

Considering that the use of max_steps is already documented:

If set to a positive number, the total number of training steps to perform. Overrides `num_train_epochs`.

lowering the level to info seems to be the best solution.

Technically, we can ignore this warnings with

TrainingArguments(
    ...,
    max_steps=100,
    num_train_epochs=-1
)

But it's not intuitive at all IMO.


As for warnings, I'd say that a good practice is that they should always be removable by the user:

  • either by modifying their code, in the event of a feature being misused, deprecated, etc. E.g example:

    logger.warning(
    "It is strongly recommended to pass the `sampling_rate` argument to this function. "
    "Failing to do so can result in silent errors that might be hard to debug."
    )

  • or by acknowledging, in the case of very important information upgraded to warning; we add a parameter for acknowledging. E.g:
    example: allow_missing_key in load_pytorch_checkpoint_in_tf2_model

Related: huggingface/trl#2350

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 or the forum? 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, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

@muellerzr and @SunMarc

Copy link
Member

@SunMarc SunMarc left a comment

Choose a reason for hiding this comment

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

LGTM ! cc @muellerzr for a second look

@@ -661,7 +661,7 @@ def __init__(
raise ValueError("The `data_collator` should be a simple callable (function, class with `__call__`).")

if args.max_steps > 0 and args.num_train_epochs > 0:
logger.warning("max_steps is given, it will override any value given in num_train_epochs")
logger.info("max_steps is given, it will override any value given in num_train_epochs")
Copy link
Member

Choose a reason for hiding this comment

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

I don't mind switching to info since we already have documented that setting max_steps will overwrite num_train_epochs. Another compromise would be to indicate to the user to pass num_train_epochs = -1 in order to remove the warning but then the code becomes bloated for nothing.

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

@muellerzr muellerzr left a comment

Choose a reason for hiding this comment

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

Agree with Marc, this change seems fine. cc @LysandreJik for final :)

Copy link
Member

@LysandreJik LysandreJik left a comment

Choose a reason for hiding this comment

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

Sounds good to me, thanks all!

@LysandreJik
Copy link
Member

Unrelated errors, merging

@LysandreJik LysandreJik merged commit d4e1acb into main Nov 21, 2024
22 of 25 checks passed
@LysandreJik LysandreJik deleted the qgallouedec-patch-1 branch November 21, 2024 10:37
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.

5 participants