Skip to content

[compat] Allow for both warmup_steps and warmup_ratio until transformers v4 support is dropped#3645

Merged
tomaarsen merged 6 commits into
huggingface:mainfrom
tomaarsen:feat/allow_warmup_steps_and_warmup_ratio
Feb 5, 2026
Merged

[compat] Allow for both warmup_steps and warmup_ratio until transformers v4 support is dropped#3645
tomaarsen merged 6 commits into
huggingface:mainfrom
tomaarsen:feat/allow_warmup_steps_and_warmup_ratio

Conversation

@tomaarsen

Copy link
Copy Markdown
Member

Hello!

Pull Request overview

  • Allow for both warmup_steps and warmup_ratio until transformers v4 support is dropped

Details

Transformers v4.x supports only warmup_ratio with floats and warmup_steps with integers.
Transformers v5.x supports warmup_steps with both floats and integers. warmup_ratio is now deprecated.

I want to keep support for Transformers v4.x and v5.x for the time being, so I'm adding warmup_ratio on the Sentence Transformers side, and pre-processing the Training Arguments so either can be used. I'll move to only warmup_steps when we drop Transformers v4 support in the next major version.

  • Tom Aarsen

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds a compatibility layer to handle the warmup_steps and warmup_ratio arguments across transformers v4 and v5. In transformers v4, warmup_ratio accepts float ratios and warmup_steps accepts integer step counts. In transformers v5+, warmup_ratio is deprecated and warmup_steps now accepts both integers and floats. This PR ensures users can use either argument with both transformers versions until transformers v4 support is dropped.

Changes:

  • Added explicit warmup_ratio field to SentenceTransformerTrainingArguments with deprecation notice
  • Implemented version-specific logic in __post_init__ to convert between warmup_steps and warmup_ratio based on transformers version
  • Added comprehensive tests to verify the compatibility logic works correctly for both transformers v4 and v5

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
sentence_transformers/training_args.py Added warmup_ratio field and post_init compatibility logic to handle warmup arguments across transformers versions
tests/test_training_args.py Added parametrized test to verify warmup_steps/warmup_ratio compatibility across transformers versions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/test_training_args.py
Comment thread tests/test_training_args.py Outdated
Comment thread sentence_transformers/training_args.py Outdated
Comment thread sentence_transformers/training_args.py Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/test_training_args.py
Comment thread sentence_transformers/training_args.py Outdated
@tomaarsen tomaarsen merged commit b099b9e into huggingface:main Feb 5, 2026
26 of 33 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.

2 participants