Skip to content

Support ratios for logging_steps, eval_steps, and save_steps - #23235

Merged
sgugger merged 10 commits into
huggingface:mainfrom
konstantinjdobler:log-eval-save-arg-ratio
May 9, 2023
Merged

Support ratios for logging_steps, eval_steps, and save_steps#23235
sgugger merged 10 commits into
huggingface:mainfrom
konstantinjdobler:log-eval-save-arg-ratio

Conversation

@konstantinjdobler

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes #23171

Adds support for ratios to the logging_steps, eval_steps, and save_steps arguments, i.e. if they are a float in range [0,1), the steps are calculated as a ratio of total training steps.

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?

@sgugger

@sgugger sgugger left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for your PR! I have a couple of comments, but it's in great shape already!

Comment thread src/transformers/training_args.py Outdated
Comment thread src/transformers/training_args.py Outdated
Comment thread src/transformers/training_args.py Outdated
Comment thread src/transformers/training_args.py Outdated
Comment on lines +1216 to +1221
if (
self.logging_strategy == IntervalStrategy.STEPS
and self.logging_steps > 1
and self.logging_steps != int(self.logging_steps)
):
raise ValueError(f"--logging_steps must be an integer if bigger than 1: {self.logging_steps}")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe here also convert the logging_steps to ints when they are bigger than 1 (same below for the two others).

@HuggingFaceDocBuilderDev

HuggingFaceDocBuilderDev commented May 9, 2023

Copy link
Copy Markdown

The documentation is not available anymore as the PR was closed or merged.

konstantinjdobler and others added 7 commits May 9, 2023 17:29
Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>

@sgugger sgugger left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for iterating!

@sgugger
sgugger merged commit 650a71e into huggingface:main May 9, 2023
gojiteji pushed a commit to gojiteji/transformers that referenced this pull request Jun 5, 2023
…uggingface#23235)

* Ratio option for `logging_steps`, `eval_steps`, `save_steps`

* Add guards if arguments are not set

* Add more detailed comments + formatting

* Update src/transformers/training_args.py

Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>

* Update src/transformers/training_args.py

Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>

* Update src/transformers/training_args.py

Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>

* Convert args values to `int` if bigger than 1

* `black`

* `make fixup`

---------

Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
novice03 pushed a commit to novice03/transformers that referenced this pull request Jun 23, 2023
…uggingface#23235)

* Ratio option for `logging_steps`, `eval_steps`, `save_steps`

* Add guards if arguments are not set

* Add more detailed comments + formatting

* Update src/transformers/training_args.py

Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>

* Update src/transformers/training_args.py

Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>

* Update src/transformers/training_args.py

Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>

* Convert args values to `int` if bigger than 1

* `black`

* `make fixup`

---------

Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.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.

Support logging_ratio, save_ratio, and eval_ratio (like for warmup_ratio)

3 participants