Skip to content

Introduce compatibility with transformers 5.0.0rc01#3597

Merged
tomaarsen merged 4 commits into
huggingface:mainfrom
tomaarsen:deps/transformers_v5_rc01_support
Dec 15, 2025
Merged

Introduce compatibility with transformers 5.0.0rc01#3597
tomaarsen merged 4 commits into
huggingface:mainfrom
tomaarsen:deps/transformers_v5_rc01_support

Conversation

@tomaarsen

Copy link
Copy Markdown
Member

Hello!

Pull Request overview

  • Introduce compatibility with transformers 5.0.0rc01

Details

The recent transformers 5.0.0rc01 release candidate has a handful of breaking changes that I've now handled with backwards compatibility. There's also a bug introduced in this version, which has been fixed again in huggingface/transformers#42838, causing me to skip a test for exactly the 5.0.0rc01 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 PR introduces backward-compatible support for the transformers 5.0.0rc01 release candidate. The changes address breaking changes in the new transformers version while maintaining compatibility with older versions.

Key changes:

  • Adds version-aware test skipping for a specific bug in transformers 5.0.0rc01 affecting model.half() saving
  • Updates safe_serialization test logic to handle the removal of safe_serialization=False support in transformers v5.0
  • Implements backward-compatible handling of the save_safetensors training argument using hasattr checks

Reviewed changes

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

File Description
tests/test_sentence_transformer.py Adds version checks to skip tests for transformers 5.0.0rc01 bug and conditionally tests safe_serialization=False only for versions < 5.0.0
tests/cross_encoder/test_pretrained.py Adds explicit torch_dtype parameter to ensure consistent float32 behavior across transformers versions
tests/cross_encoder/test_cross_encoder.py Adds version checks to conditionally test safe_serialization=False only for versions < 5.0.0
sentence_transformers/trainer.py Uses hasattr check for backward compatibility when save_safetensors attribute is removed from training args in v5.0

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

@tomaarsen tomaarsen enabled auto-merge (squash) December 15, 2025 11:32
@tomaarsen tomaarsen disabled auto-merge December 15, 2025 12:07
@tomaarsen tomaarsen merged commit e3f8544 into huggingface:main Dec 15, 2025
16 of 17 checks passed
tomaarsen added a commit that referenced this pull request Jan 26, 2026
* Introduce compatibility with transformers 5.0.0.rc01

* Skip test for v5.0.0rc01 linked to bug in v5.0.0rc01

* Add comment to explain why the if hasattr exists

* Skip test when below transformers 5.0.0dev0 instead of 5.0.0
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