DEV Community

Cover image for Transformers 5.24 vs 5.23: Upgrade Now, Rename Later
Shamuddin
Shamuddin

Posted on Originally published at aitecharchive.com

Transformers 5.24 vs 5.23: Upgrade Now, Rename Later

Verdict: move to Transformers 5.24 and leave your past_key_values code alone for now. Hugging Face tagged v5.24.0 on November 21, 2026 (maintainer Cyrilvallez), and it renames the KV cache argument to cache across the library while auto-translating the old names with a one-time deprecation warning. Two things can still break you today: a new peft floor of 0.22.0 and the removal of modeling_attn_mask_utils.py. If you touch neither, the upgrade from 5.23 is a single pip command, and the rename can wait for a quiet sprint.

TL;DR

  • past_key_values (attention models) and cache_params (Mamba-style models) are now one name: cache.
  • Old names still work. Model forward and prepare_inputs_for_generation accept them until v5.40.0; generate until v6.0.0.
  • Passing an old name and cache in the same call raises an error.
  • peft 0.22.0 or later is required, and the old modeling_attn_mask_utils.py module is gone.
  • Seven new architectures land, including Inkling 2 Mini, Apertus 1.5 and two Sarvam models.
  • Last verified: 2026-11-23.

Should you upgrade to Transformers 5.24 or stay on 5.23?

Upgrade, unless your environment pins peft below 0.22.0 or your code imports the removed attention-mask module. Staying on 5.23 buys you nothing except an unchanged warning log, while 5.24 carries a long list of generate() fixes (covered below) and native support for new checkpoints. The rename is the headline, but it is the least risky part, because the library handles it for you.

The cost of staying put grows with time. The release notes set the hard stop at v5.40.0 for forward calls, so anything you postpone is a deadline rather than a decision. Treating 5.24 as the point where you start seeing warnings, and 5.40 as the point where you must have finished, is a sensible way to plan it.

The bar for this kind of upgrade guide is not arbitrary on our side either. In our own analysis of n=695 AI and developer-tooling keywords (measured November 23, 2026, priced with DataForSEO volume and difficulty data), we applied a winnable bar of 150 to 6,000 monthly searches with a genuine technical term, and only 10.4 percent of the corpus cleared it. A versioned library rename with a two-milestone deprecation window is exactly the shape that clears it.

What exactly does the cache rename change?

Every place that carried a KV cache argument or output field now uses cache. According to the release notes, that covers model forward signatures, generate, prepare_inputs_for_generation, the masking utilities and every ModelOutput. The change was made in PRs #50585 and #50730.

Mamba-style state-space models used cache_params for the same concept. That is folded into cache too, so one name now covers both families.

In practice, the pattern you will see in custom loops looks like this:

# Before (still works in 5.24, with a one-time warning)
out = model(input_ids, past_key_values=cache, use_cache=True)
cache = out.past_key_values

# After
out = model(input_ids, cache=cache, use_cache=True)
cache = out.cache
Enter fullscreen mode Exit fullscreen mode

The one trap is mixing the two spellings. Passing past_key_values and cache together in one call raises an error rather than picking a winner, which is the correct behaviour but will bite anyone who half-migrates a wrapper function.

What breaks in Transformers 5.24 and what does not?

Three things deserve a check before you upgrade:

  1. peft version. The release requires peft 0.22.0 or later. Pipelines that pin an older adapter library will fail at import or resolution time. This is the most likely cause of a failed CI run.
  2. modeling_attn_mask_utils.py. The deprecated module was removed. A search of your repository and any vendored model code for that filename takes seconds, and any hit needs its import rewritten against the current masking utilities.
  3. Code that reads out.past_key_values directly. Output objects now expose cache. The release describes automatic renaming of old names, so this should keep working with a warning, but test any code that serialises or inspects output fields by name.

What does not break: calls that use past_key_values as a keyword to forward or generate, cache_params on Mamba-style models, and existing checkpoints. A corroborating write-up of the release reaches the same reading of the dependency and removal notes.

How do you upgrade to Transformers 5.24 step by step?

  1. Create a branch and record your current versions with pip freeze | grep -E "transformers|peft".
  2. Run pip install -U transformers. Version 5.24.0 is listed on PyPI.
  3. Confirm peft is 0.22.0 or later, upgrading it if not.
  4. Search your code for modeling_attn_mask_utils and fix any imports.
  5. Run your test suite with warnings visible, for example python -W default -m pytest. Collect every deprecation message about the cache rename.
  6. Rename past_key_values and cache_params to cache in your own code when convenient, one call site at a time, never mixing both in one call.

Step 6 is optional today. The deadlines are v5.40.0 for forward and prepare_inputs_for_generation, and v6.0.0 for generate.

Which generate() fixes matter in this release?

Several are worth knowing if you serve models locally, all listed in the release notes:

  • Static cache now works in assisted decoding (#49415), and generate with flex attention and a static cache is fixed.
  • StaticCache allocates values using the value states' dtype, and the cache survives activation checkpointing when gradients are off.
  • Sampled beam search candidates are sorted again before finalisation (#50754), and constrained sampling preserves batch IDs (#50883).
  • generate on MPS is fixed for encoder-decoder models (#51032), which helps Apple Silicon users.
  • TextStreamer no longer drops spaces, and no longer lags on text without spaces such as Chinese, Japanese and Korean (#51036).
  • StopStringCriteria initialises faster and its cache now actually hits (#50780).
  • Continuous batching works under torch.inference_mode().

If you stream tokens to a user interface or rely on stop strings, these are the fixes most likely to change what you observe.

Which new architectures does Transformers 5.24 add?

Seven, per the release notes:

  • Inkling 2 Mini (Thinking Machines Lab): a multimodal text-and-image model with 24 decoder layers in which layers 6 to 17 loop three times, so 24 physical layers behave like 48 logical ones. It routes each token to 8 of 128 experts. A research checkpoint varies the number of loop passes, trading speed against quality. See our Inkling 2 Mini benchmarks and pricing for how it performs.
  • Apertus 1.5 (Swiss AI Initiative): accepts text, images and audio, but generates text only.
  • WavTokenizer: a codec that turns 24 kHz mono audio into discrete tokens at 40 or 75 tokens per second, depending on the checkpoint. Training the codec is not supported.
  • Lara Mini (Translated): 7.2B total and 0.6B active parameters per token, under a non-commercial CC BY-NC-SA 4.0 licence.
  • SarvamMLA and SarvamMoE: the architectures behind Sarvam-105B and Sarvam-30B. Both reuse existing designs (DeepSeek-V3 and GLM-4-MoE) with Sarvam-specific configuration.
  • EXAONE (LG AI Research): identical to Llama, so it loads through LlamaForCausalLM and no longer needs trust_remote_code=True.

The EXAONE change is the quiet security win: one fewer reason to execute remote code on a production host.

Is there a way to run Inkling 2 Mini without the Python stack?

Yes. The official Hugging Face announcement says Inkling 2 Mini is supported in transformers, llama.cpp and MLX, with day-zero support in SGLang. If your concern is the dependency churn above, running it through llama.cpp or MLX avoids the peft floor entirely. For other local-inference comparisons, our notes on CPU-only DeepSeek-class inference, a LoRA-adapted Qwen3 model, quantisation on a 10 GB budget and open-weights video models cover adjacent ground.

FAQ

Q: Will my existing past_key_values code stop working after upgrading to Transformers 5.24?
A: No. The library renames the old argument automatically and logs a one-time deprecation warning. Forward calls and prepare_inputs_for_generation accept the old names until v5.40.0, and generate until v6.0.0.

Q: Can I pass both past_key_values and cache in the same call?
A: No. Supplying an old name together with cache raises an error. Migrate each call site fully to cache rather than mixing the two.

Q: What does Transformers 5.24 require that 5.23 did not?
A: It requires peft 0.22.0 or later, and the deprecated modeling_attn_mask_utils.py module has been removed, so any imports from it must be rewritten.

Q: What happens to cache_params on Mamba-style models?
A: It is unified with past_key_values under the single name cache, with the same deprecation window and automatic renaming.

Q: Do I need trust_remote_code=True for EXAONE models now?
A: No. EXAONE 3.0, 3.5 and Deep load through the native Llama classes, with checkpoint tensors renamed on load and back on save.

Q: Is there an alternative to the Python stack for Inkling 2 Mini?
A: Yes. Hugging Face lists support in llama.cpp and MLX as well as transformers, and SGLang has day-zero support.

This article was produced with AI assistance and checked against the primary release notes. Corrections are welcome.

Top comments (0)