fix: Restore compatibility with newer Python and transformers versions#204
Merged
fix: Restore compatibility with newer Python and transformers versions#204
Conversation
Version 5.0.0 of transformers changed some of the buffers registered on a model when it is loaded, leading to mismatches when comparing newly-serialized models' keys against older ones. This change permits the extra tensors from <5.0.0 as an acceptable deviation when comparing keys between the deserialized model and reference model, without failing the test suite.
Python 3.14 switched to evaluating annotations lazily, so accessing the __annotations__ attribute directly from a metaclass doesn't work anymore. Co-authored-by: Neil Schemenauer <nas@arctrix.com>
Python 3.15 is removing the ability to construct NamedTuple classes using keyword arguments to specify fields and their types, so this switches to using the still-supported list-of-tuples functional syntax for it instead.
shajrawi
approved these changes
Apr 21, 2026
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.
Compatibility with Python 3.14 & 3.15, and
transformersv5This set of changes provides compatibility with newer Python versions, and improves the test suite's compatibility with
transformersv5.annotationlibrather than directly accessing__annotate_func__, as the latter is proscribed (see e.g. Python 3.14+: Warn against use of__annotate_func__and__annotations_cache__astral-sh/ruff#17859).NamedTupleclass.transformersv5 in the test suite is handled by ignoring keys only present in serialized files fromtransformersv4 and below when running with v5 or above, since those are expected differences.This includes a code version bump to v2.12.1. The changelog is updated accordingly.