I was using the latest transformers (5.9.0) with python 3.13, and got this KeyError: 'default' error at:
|
# HACK: 强制设置为default |
|
self.rope_type = "default" |
|
|
|
self.max_seq_len_cached = config.max_position_embeddings |
|
self.original_max_seq_len = config.max_position_embeddings |
|
|
|
self.config = config |
|
self.rope_init_fn = ROPE_INIT_FUNCTIONS[self.rope_type] |
Where
self.rope_type is hardcoded to "default", and
ROPE_INIT_FUNCTIONS imported with:
from transformers.modeling_rope_utils import ROPE_INIT_FUNCTIONS
However, according to Claude, "default" key only exist on transformers ~4.40–4.42:
transformers 4.43+ use "llama3" or "dynamic"
Some other builds use "linear", "yarn"
A few suggestions from Claude are:
- Using fallback when "default" doesn't exist:
# Try one of these based on what print() shows you
self.rope_init_fn = ROPE_INIT_FUNCTIONS.get("default") \
or ROPE_INIT_FUNCTIONS.get("llama3") \
or list(ROPE_INIT_FUNCTIONS.values())[0]
- Bypass
ROPE_INIT_FUNCTIONS entirely and define the init function directly:
def default_rope_init(config, device):
base = config.rope_theta if hasattr(config, "rope_theta") else 10000.0
dim = config.hidden_size // config.num_attention_heads
inv_freq = 1.0 / (base ** (torch.arange(0, dim, 2, device=device).float() / dim))
return inv_freq, 1.0
self.rope_init_fn = default_rope_init
I was using the latest transformers (5.9.0) with python 3.13, and got this KeyError: 'default' error at:
Lance/modeling/qwen2_5_vl/modeling_qwen2_5_vl.py
Lines 587 to 594 in 3c757d2
Where
self.rope_typeis hardcoded to "default", andROPE_INIT_FUNCTIONSimported with:However, according to Claude, "default" key only exist on transformers ~4.40–4.42:
transformers 4.43+ use "llama3" or "dynamic"
Some other builds use "linear", "yarn"
A few suggestions from Claude are:
ROPE_INIT_FUNCTIONSentirely and define the init function directly: