# Migration Context: Hugging Face Transformers v4 -> v5 # Generated by Changelogs.us: 2026-11-30T03:04:30.631319+00:00 # Target Version: v5.24.1 # Upgrade Command: N/A # Breaking Changes: 35 # Security Fixes: 0 ## Executive Summary Upgrading Hugging Face Transformers from 4 to 5 involves 45 releases with risk rating High. ## Breaking Changes List: - [vv5.0.0] Breaking Changes * **`report_to` now defaults to `"none"`**: - [vv5.0.0] Biggest breaking change is in `transformers chat`. This command starts a terminal UI to interact with a chat model.: - [vv5.0.0] Revert some breaking changes bnb by @SunMarc in #41581: - [vv5.0.0] [Trainer] [Breaking change] `use_cache` default to `False` by @SunMarc in #41585: - [vv5.0.0] added more breaking changes * [cleanup] Don't use Repository in create_dummy_models.py script (#42380) * [cleanup] Remove deprecated load config from file (#42383): - [vv5.1.0] Breaking changes * 🚨 T5Gemma2 model structure (#43633) - Makes sure that the attn implementation is set to all sub-configs. The config.encoder.text_config was not getting its attn set because we aren't passing it to PreTrainedModel.__init__. We can't change the model structure without breaking so I manually re-added a call to self.adjust_attn_implemetation in modeling code: - [vv5.1.0] 🚨 Generation cache preparation (#43679) - Refactors cache initialization in generation to ensure sliding window configurations are now properly respected. Previously, some models (like Afmoe) created caches without passing the model config, causing sliding window limits to be ignored. This is breaking because models with sliding window attention will now enforce their window size limits during generation, which may change generation behavior or require adjusting sequence lengths in existing code.: - [vv5.2.0] Breaking changes * :rotating_light: [`Attn`] New attn mask interface everywhere (#42848): - [vv5.2.0] :rotating_light: This one is quite breaking for super super super old modles: :rotating_light: :rotating_light:: - [vv5.3.0] Breaking changes Tensor parallelism (TP) support for dense and MoE decoder-only models has been fixed and stabilized, requiring users to update their TP configurations and conversion mappings accordingly.: - [vv5.4.0] Breaking changes The dual `BaseImageProcessor`/`BaseImageProcessorFast` design has been replaced with a unified backend architecture, and the `image_processing_utils_fast` module has been removed - users should migrate to the new unified `image_processing_utils` module.: - [vv5.5.0] Breaking changes Mamba and hybrid model caches are now first-class native citizens in the library, so users working with Mamba-based or hybrid (Mamba + attention) models should update their code to use the new native cache classes instead of any previous workarounds.: - [vv5.6.0] Breaking changes The internal `rotary_fn` is no longer registered as a hidden kernel function, so any code referencing `self.rotary_fn(...)` within an Attention module will break and must be updated to call the function directly instead.: - [vv5.8.0] Breaking changes Apex integration has been removed from the library (including RMSNorm usage in T5 and related models), so users relying on Apex for mixed precision or fused ops should migrate to PyTorch's native equivalents instead.: - [vv5.9.0] Breaking changes The `text_embeds` input for SAM3, EdgeTAM, and SAM3-Lite-Text models now expects full text embeddings instead of just pooler outputs, aligning with other models in the library - users must update their inputs accordingly.: - [vv5.10.1] Breaking changes The Gemma4 vision pooler now casts inputs to float32 before scaling to prevent float16 overflow (inf saturation) with large checkpoints, which may cause minor numerical differences in outputs for users running Gemma-4 vision models in float16.: - [vv5.13.0] Breaking changes A broad set of modeling changes have been made to standardize layer declarations, mask/cache construction, and hybrid-attention handling, making many models cleanly exportable (ONNX, `torch.export`, ExecuTorch) and fullgraph-compilable - users relying on internal modeling APIs may need to update their code accordingly.: - [vv5.13.0] The `Kernels` integration has been synced to the latest version, which includes a breaking change where model-type repositories are no longer accepted by the kernels interface - users must migrate to the updated kernel repository format as shown in the updated tests.: - [vv5.14.0] :rotating_light: Breaking changes GPTNeoX now remaps `embed_out` to `lm_head` and GPTBigCode has `_supports_attention_backend = True` enabled for vLLM compatibility; users relying on the previous weight naming or attention backend behavior for these models should update their code accordingly.: - [vv5.15.0] Breaking changes Kernels are now opt-in rather than mandatory for linear attention models (Mamba, GDN, Conv-only, etc.), so users who relied on automatic kernel selection must explicitly enable kernels to maintain previous behavior.: - [vv5.15.0] Fix CUDA Graph breaking host to device copy from scalar tensor allocation (#47547) by @hmellor in [#47547]: - [vv5.16.0] Breaking changes The legacy tensor-parallel implementation has been replaced with a DTensor-native backend, so users relying on the previous TP API for inference or training must migrate to the new DTensor-based interface.: - [vv5.17.0] Breaking changes Vision rotary embeddings (2D/3D) have been standardized into a unified RoPE frequency computation module, so users with custom vision models relying on attention-layer-level or model-specific RoPE grid interleaving logic must migrate to the new centralized `modeling_rope_utils.py` implementation.: - [vv5.18.0] Breaking changes * 🚨 [ROCm] gpt-oss: route FA3 to aiter-flash-attn, generate ROCm fixtures (#46837) by @Abdennacer-Badaoui: - [vv5.18.0] [Zamba] Fix associative scan breaking ONNX export and OOM in integration test (#49092) by @ydshieh: - [vv5.18.0] [Zamba] Fix associative scan breaking ONNX export and OOM in integration test (#49092): - [vv5.19.0] Breaking changes All MoE models whose routers compute logits now return them when `output_router_logits=True`, following the Qwen3-MoE pattern (a `router_logits` recorder on the base model, `MoeModelOutputWithPast` from the backbone, and a MoE causal LM output from the head), so code that relied on the previous outputs or their absence should read the router logits from these output classes.: - [vv5.20.0] Breaking changes 🚨 General breaking notice that inference with EP has regressions in speed; we are working on fixing this ASAP! 🚨: - [vv5.20.0] 🚨 General breaking notice that inference with EP has regressions in speed; we are working on fixing this ASAP! 🚨: - [vv5.21] Breaking changes Fixed Gemma4 processor imports (the Gemma4, Gemma4 unified and EmbeddingGemma2 processors) so `from transformers import *` no longer fails in environments that have `PIL` but not `torch`; no user action is needed.: - [vv5.21] Fix Windows path separators breaking relative imports of Hub custom-generate modules (#48951) by @dltsum in [#48951]: - [vv5.22.0] Breaking changes * 🚨 Separate EP logic into its own file (#49679) by @3outeille: - [vv5.23.0] Breaking changes * 🚨 Remove the `ep_router` expert-parallel style (#49615) by @IlyasMoutawwakil: - [vv5.23.0] 🚨 [serve][breaking] update attn for mac users (#49730) by @SunMarc: - [vv5.24.0] Breaking changes ### Cache renaming: `past_key_values` / `cache_params` → `cache` (#50585, #50730): ## Instructions for AI Assistant: When migrating user code from Hugging Face Transformers 4 to 5, scan for the deprecated APIs and breaking changes above and refactor code to use modern vv5.24.1 idioms.