fix: exclude broken transformers release#10634
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the transformers dependency constraints in pyproject.toml and src/llamafactory/extras/misc.py to support versions up to 5.7.0 while excluding 4.57.0 and 5.6.0. Feedback highlights that passing multiple inequality constraints (like !=4.57.0 and !=5.6.0) in a single requirement string to check_version will cause the earlier exclusion to be silently overwritten due to Hugging Face's internal version parsing implementation, and suggests splitting them into separate calls.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| def check_dependencies() -> None: | ||
| r"""Check the version of the required packages.""" | ||
| check_version("transformers>=4.55.0,<=5.6.0") | ||
| check_version("transformers>=4.55.0,<=5.7.0,!=4.57.0,!=5.6.0") |
There was a problem hiding this comment.
Due to an implementation detail in Hugging Face's transformers.utils.versions.require_version, passing multiple version constraints with the same operator (such as !=4.57.0 and !=5.6.0) in a single requirement string will result in the earlier constraints being silently overwritten.
Specifically, require_version parses the requirement string and stores the operators in a dictionary keyed by the operator itself (wanted[op] = want_ver). Because of this, wanted["!="] will only retain the last exclusion (5.6.0), and the !=4.57.0 check will be completely ignored at runtime.
To prevent this, we should split the checks into separate check_version calls.
| check_version("transformers>=4.55.0,<=5.7.0,!=4.57.0,!=5.6.0") | |
| check_version("transformers>=4.55.0,<=5.7.0") | |
| check_version("transformers!=4.57.0") | |
| check_version("transformers!=5.6.0") |
|
Updated after the review note. Change made:
Validation rerun:
|
Fixes #10610
The issue thread identifies
transformers==5.6.0as the broken release for the FlashAttention path, and maintainers noted that upgrading Transformers avoids it.This updates the supported Transformers spec in both install metadata and the runtime dependency check:
<=5.7.0!=4.57.0exclusion!=5.6.0so existing broken environments fail the version gate instead of passing silentlyValidation:
uvx ruff check pyproject.toml src\llamafactory\extras\misc.pypy -m py_compile src\llamafactory\extras\misc.pygit diff --check