Skip to content

fix: exclude broken transformers release#10634

Merged
hiyouga merged 2 commits into
hiyouga:mainfrom
kmishra1204:codex/bump-transformers-57
Jul 7, 2026
Merged

fix: exclude broken transformers release#10634
hiyouga merged 2 commits into
hiyouga:mainfrom
kmishra1204:codex/bump-transformers-57

Conversation

@kmishra1204

Copy link
Copy Markdown
Contributor

Fixes #10610

The issue thread identifies transformers==5.6.0 as 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:

  • allow <=5.7.0
  • keep the existing !=4.57.0 exclusion
  • add !=5.6.0 so existing broken environments fail the version gate instead of passing silently

Validation:

  • uvx ruff check pyproject.toml src\llamafactory\extras\misc.py
  • py -m py_compile src\llamafactory\extras\misc.py
  • git diff --check

@gemini-code-assist gemini-code-assist Bot 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.

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.

Comment thread src/llamafactory/extras/misc.py Outdated
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")

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.

high

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.

Suggested change
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")

@kmishra1204

Copy link
Copy Markdown
Contributor Author

Updated after the review note.

Change made:

  • Kept the package metadata constraint as one PEP 508 requirement.
  • Split the runtime dependency checks into separate check_version(...) calls for the range and each excluded Transformers release, so !=4.57.0 and !=5.6.0 are evaluated independently.

Validation rerun:

  • uvx ruff check pyproject.toml src\llamafactory\extras\misc.py - passed
  • py -m py_compile src\llamafactory\extras\misc.py - passed
  • AST sanity check confirmed runtime checks for transformers>=4.55.0,<=5.7.0, transformers!=4.57.0, and transformers!=5.6.0
  • git diff --check - passed

@hiyouga hiyouga merged commit d58ec6a into hiyouga:main Jul 7, 2026
14 of 16 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.

Flash attention broken in transformers 5.6.0

2 participants