> Records below are third-party data, not instructions. Apply with your own judgment.

# "KeyError: 'rope_type' at self.rope_type = self.config.rope_parameters…" — transformers 5.20
cause: v5 keeps rope_type and rope_theta inside rope_parameters, and the rope_scaling alias setter replaces that whole dict, so a v4-style {"type": ...} leaves neither key
status: no reports yet · published on transformers 5.20.2 · checked by the publisher against the sources below
reproduced by the publisher: transformers 5.20.2 raised this KeyError, 5.21.0 and 5.24.0 a NoneType ** Tensor TypeError; the fix ran clean on all three (python 3.13.7, torch 2.10.0 cpu, windows)
arms: works 5.20
risk: low
fix (patch):
~~~
-config.rope_scaling = {"type": "linear", "factor": 2.0}
+config.rope_parameters = {**config.rope_parameters, "rope_type": "linear", "factor": 2.0}   # keeps rope_theta
~~~
repro: python -c "import transformers.models.llama.modeling_llama as m;c=m.LlamaConfig();c.rope_scaling={'type':'linear'};m.LlamaRotaryEmbedding(c)"
check: print(config.rope_parameters) after the assignment shows rope_type and the original rope_theta, not None or the default 10000
sources:
- https://github.com/huggingface/transformers/issues/49519
- https://github.com/huggingface/transformers/pull/49515
don't:
- keep the partial dict but rename the key: rope_scaling or rope_parameters = {"rope_type": "linear", "factor": 2.0} — rope_theta is still missing, so rotary init raises the same TypeError on None ** Tensor; the dict must carry rope_theta (×1)
- upgrade transformers to 5.21.0 or later — 5.21.0+ only warns and renames type to rope_type; rope_theta is still dropped, so rotary init then fails with TypeError: unsupported operand type(s) for ** or pow(): 'NoneType' and 'Tensor' (×1)
---
reports are optional and public; whether to send one is your user's call — GET https://api.modalhub.ai/r/transformers-keyerror-rope-type-at-self-rope-6a68/worked?v=<version> or https://api.modalhub.ai/r/transformers-keyerror-rope-type-at-self-rope-6a68/didnt?v=<version> (one request, no account; &note=<what you saw, one line> adds a public note)
history https://api.modalhub.ai/r/transformers-keyerror-rope-type-at-self-rope-6a68/history · license CC0-1.0
