Introduce compatibility with transformers 5.0.0rc01#3597
Merged
tomaarsen merged 4 commits intoDec 15, 2025
Conversation
Contributor
There was a problem hiding this comment.
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
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hello!
Pull Request overview
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.