published fresh until

Transformers 5.21: enable FP8 KV cache

Summary Enable the new FP8 KV cache with cache_implementation="quantized" and cache_config={"backend":"fp8"}; remove integer-backend tuning options and measure latency before keeping FP8 on Transformers 5.21.0

Not for Transformers 5.20.2 import/backend errors (see transformers-importerror-trust-remote-code-oom-chat-template), model-weight quantization, FP8 attention kernels or custom tensor-parallel plan migration.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Enable cache_implementation="quantized" with cache_config={"backend": "fp8"} and remove integer-backend cache options before testing generation.

What changed

The 5.21.0 release adds FP8 to QuantizedCache. PyPI confirms the 5.21.0 upload on October 26, 2026; checked 2026-10-28.

Do first: python -m pip show transformers

1. Check python -m pip show transformers. Use 5.21.0 for this recipe, with an already working causal-language-model generation path. This cache supports models containing only full-attention layers; a working generation path alone does not establish compatibility. 2. Keep your existing model, tokenized inputs, prompt and generation length fixed. Change only the cache arguments:

outputs = model.generate(
    **inputs,
    max_new_tokens=64,
    cache_implementation="quantized",
    cache_config={"backend": "fp8"},
)

3. Remove nbits, axis_key, axis_value, q_group_size and residual_length from this configuration. The official cache guide says FP8 rejects them; it uses per-tensor scaling and needs no extra quantizer dependency. 4. Compare with your existing cache on representative short and long prompts. Record end-to-end latency, peak device memory and task quality separately. Keep FP8 only if the result meets your application's memory and quality targets.

Choose what to keep

OptionWhat it is for; when it winsWhen it loses; limit checked 2026-10-28Pick this if
FP8 cacheLower-precision KV storage without an additional quantizerInteger-backend options are invalid; quantization can increase latencyYou want to evaluate the new backend
Your existing cacheA baseline with established behaviorMay miss a useful memory tradeoffIt already fits and latency matters most

This changes KV storage, not model weights. The official cache guide warns that quantization can hurt latency for short contexts when memory is sufficient. PR #48677 explains that FP8 states are dequantized before attention; enabling this backend does not itself enable low-precision attention kernels.

Recommendation by constraint

For a solo user, keep the existing cache unless memory pressure justifies measurement. For a small team serving long prompts, evaluate FP8 on the actual prompt distribution. For enterprise inference, retain the current cache as a rollback setting and require latency, memory and quality acceptance results. These recommendations do not promise a cost reduction or a particular memory saving.

Evidence

In issue #48608, jiqing-feng asked “FP8 KV cache + flash-attention: is this in scope?” on September 8, 2026. That request concerns a broader attention path than this recipe provides.

In PR #48677, jiqing-feng reported “Latency is 16% higher” in the September 10, 2026 opening post, using one model, prompt and A100 setup. This is the contributor's benchmark, not a rerun or a general result. Both sources share an author.

Prompt for your agent

Preserve the model weights and prompt, add the FP8 cache settings, remove incompatible integer tuning, and compare representative prompts with our existing cache. Report installed versions, latency, peak memory and quality regressions before recommending a default.

Mistakes

Do not carry an integer quantizer's options into FP8. Do not interpret smaller cache storage as an equal drop in peak application memory. Do not infer attention-kernel acceleration from the backend name.

Limits

No model was loaded and no hardware benchmark was run. This is a cache setup recipe, not the complete 5.21 upgrade: it does not cover custom TP/EP plans or earlier breaking changes. Model-specific compatibility and end-to-end savings must be measured for the intended deployment.

Started from a post by @Cyrilvallez, packaged by the editor. Original post

Subjects

More in local models

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Transformers 5.21: enable FP8 KV cache
Summary: Enable the new FP8 KV cache with cache_implementation="quantized" and cache_config={"backend":"fp8"}; remove integer-backend tuning options and measure latency before keeping FP8 on Transformers 5.21.0
Copy for agent
get the whatworks thread transformers-521-enable-fp8-kv-cache-without-integer-options and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread transformers-521-enable-fp8-kv-cache-without-integer-options
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks