What this thread does
Do first: Upgrade to v0.1.906-beta (a beta build) for this correction.
Symptom
`NotImplementedError: Make sure that a _reorder_cache function is correctly implemented in transformers.models.llama.modeling_llama to enable beam search is the original beam-search error. The reporter added num_beams=3` during inference. Reported by kiranpedvak. Other users commented on the issue, including yelboudouri; stephenhbarlow.
Cause
Fast decoding returns a tuple cache, but beam search needs cache reordering. The correction reorders the attention paged buffers in place, handles prefill tuples, and delegates Cache objects to their cache method. Reordering only the returned tuple can mix beams.
Fix
1. Use beta build v0.1.906-beta or a later carrying beta for the fast-decode cache correction. 2. Retain the desired num_beams setting; the correction supplies the missing cache reordering rather than requiring single-beam generation.
The v0.1.924-beta source still defines _fast_reorder_cache and installs it on the generation class. Tagged source.
Fixed in
First carrying release v0.1.906-beta (pre-release/build, 2026-10-12); no stable release carries it as of 2026-11-24 per the releases page. PR #13053 by danielhanchen merged 2026-10-09. The release tag is a beta build even though its GitHub API prerelease flag is false.
If it still fails
- Older Transformers report the original NotImplementedError, while the PR records different cache errors on newer Transformers. The correction targets the fast decode cache path; it is not evidence for unrelated generation errors. The carrying releases named here are beta builds.
Not for: Unsloth Studio Windows access-denied errors.
Sources
- NotImplementedError: Make sure that a
_reorder_cachefunction is correctly implemented in transformers.models.llama.modeling_llama to enable beam search for <class 'transformers.models.llama.modeling_llama.LlamaForCausalLM'>, kiranpedvak, opened 2024-10-04; closed as completed on 2026-10-09: "_reorder_cache" - Fix beam search (num_beams > 1) on the fast decode path, danielhanchen, merged 2026-10-09.
- v0.1.906-beta, published 2026-10-12.
- Comment on the source issue, yelboudouri, 2024-10-29; issue closed as completed on 2026-10-09.
- Comment on the source issue, stephenhbarlow, 2024-12-05; issue closed as completed on 2026-10-09.
- Release v0.1.924-beta, published 2026-11-24.
- Behavior at v0.1.924-beta, tagged source read 2026-11-24.
- Releases, beta-build history read 2026-11-24.
Checked
2026-11-24; read the issue and linked comment API records, merged PR API record, release records and tagged source listed above, and release history; no command was run.
Started from a post by @kiranpedvak, packaged by the editor. Original post