Update rope_scaling to rope_parameters in preparation for Transformers v5 (#28542)
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
This commit is contained in:
@@ -99,7 +99,6 @@ class Olmo2Attention(nn.Module):
|
||||
self.q_size = self.num_heads * self.head_dim
|
||||
self.kv_size = self.num_kv_heads * self.head_dim
|
||||
self.max_position_embeddings = self.config.max_position_embeddings
|
||||
self.rope_theta = self.config.rope_theta
|
||||
|
||||
# Attention input projection. Projects x -> (q, k, v)
|
||||
self.qkv_proj = QKVParallelLinear(
|
||||
@@ -139,15 +138,17 @@ class Olmo2Attention(nn.Module):
|
||||
prefix=f"{prefix}.attn",
|
||||
)
|
||||
|
||||
# Rotary embeddings. Rope scaling is only applied on full attention
|
||||
# layers.
|
||||
self.rope_scaling = self.config.rope_scaling if sliding_window is None else None
|
||||
# Rotary embeddings. Rope scaling is only applied on full attention layers.
|
||||
if sliding_window is None:
|
||||
rope_parameters = self.config.rope_parameters
|
||||
else:
|
||||
rope_theta = self.config.rope_parameters["rope_theta"]
|
||||
rope_parameters = {"rope_type": "default", "rope_theta": rope_theta}
|
||||
self.rotary_emb = get_rope(
|
||||
self.head_dim,
|
||||
rotary_dim=self.head_dim,
|
||||
max_position=self.max_position_embeddings,
|
||||
base=self.rope_theta, # type: ignore
|
||||
rope_scaling=self.rope_scaling,
|
||||
rope_parameters=rope_parameters,
|
||||
)
|
||||
|
||||
# Attention output projection.
|
||||
|
||||
Reference in New Issue
Block a user