-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
upgrade transformers to 5.4.0 #3562
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
transformers 5.4.0 release notes breaking changes from 5.3.0 Hugging Face💡 Result:
Hugging Face Transformers v5.4.0 was released on 2026-03-27. The full release notes are available at https://github.com/huggingface/transformers/releases/tag/v5.4.0. Breaking changes in v5.4.0 (specific to this minor release from v5.3.0): - Refactor Image Processors to support different backends (PR
#43514): The dual BaseImageProcessor/BaseImageProcessorFast design has been replaced with a unified backend architecture. The image_processing_utils_fast module has been removed. Users should migrate to the new unified ImageProcessor. - Validate config attributes (PR#41250): Added validation for PretrainedConfig attributes, which may cause type checking failures in some cases (see issue#45071). - Initial support for FA4 with breaking changes (PR#42435). - Changes to weight tying behavior. Note: Many broader v5.x breaking changes (e.g., dynamic weight loading, tokenization simplifications, removal of TF/JAX support) were introduced in v5.0.0. For migration from v4.x, refer to MIGRATION_GUIDE_V5.md. Recent issues reported post-v5.4.0 release include breaks for models using remote_code (issue#45020) and PretrainedConfig type checking (issue#45071), dated around 2026-03-28.Citations:
PretrainedConfigtype checking huggingface/transformers#45071remote_codehuggingface/transformers#45020🏁 Script executed:
Repository: axolotl-ai-cloud/axolotl
Length of output: 21244
🏁 Script executed:
Repository: axolotl-ai-cloud/axolotl
Length of output: 139
🏁 Script executed:
Repository: axolotl-ai-cloud/axolotl
Length of output: 3779
🏁 Script executed:
Repository: axolotl-ai-cloud/axolotl
Length of output: 4565
🏁 Script executed:
Repository: axolotl-ai-cloud/axolotl
Length of output: 4092
🏁 Script executed:
Repository: axolotl-ai-cloud/axolotl
Length of output: 499
Verify compatibility of monkey-patched private transformers APIs with 5.4.0 and fix unguarded GradientCheckpointingLayer import.
The codebase extensively monkey-patches and imports private/internal transformers APIs that have no stability guarantee across versions. Upgrading from 5.3.0 to 5.4.0 risks breaking these integrations. Critical concerns:
Unguarded GradientCheckpointingLayer import:
src/axolotl/core/trainers/mixins/activation_checkpointing.py:13imports fromtransformersmain module without version gating, whilesrc/axolotl/monkeypatch/gradient_checkpointing/__init__.py:17guards it with> 4.51.3and imports fromtransformers.modeling_layers. These differ in both path and gating—if transformers doesn't re-export from the main module, this import will fail at runtime.Inconsistent fallback patterns:
_flash_supports_windowhas a three-layer try/except fallback inbatch.py:19-30, but_flash_attention_forward(accessed atbatch.py:170, 177) has no fallback. If transformers 5.4.0 changed these private APIs, only the former would gracefully degrade.Private API registry modifications:
ALL_ATTENTION_FUNCTIONSis modified at multiple sites without version checks or fallbacks.Please add try/except protection to the GradientCheckpointingLayer import in
activation_checkpointing.py, add a fallback for_flash_attention_forwardimport, and confirm all monkey-patched paths still exist in transformers 5.4.0.🤖 Prompt for AI Agents