Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
norm
vllm
Commits
63b2206a
"vscode:/vscode.git/clone" did not exist on "f14682a8178650f26544c1d4ac91cc31e0d7f458"
Unverified
Commit
63b2206a
authored
Nov 30, 2023
by
Jee Li
Committed by
GitHub
Nov 29, 2023
Browse files
Avoid multiple instantiations of the RoPE class (#1828)
parent
27feead2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
0 deletions
+8
-0
vllm/model_executor/layers/rotary_embedding.py
vllm/model_executor/layers/rotary_embedding.py
+8
-0
No files found.
vllm/model_executor/layers/rotary_embedding.py
View file @
63b2206a
...
@@ -272,6 +272,9 @@ class YaRNScalingRotaryEmbedding(RotaryEmbedding):
...
@@ -272,6 +272,9 @@ class YaRNScalingRotaryEmbedding(RotaryEmbedding):
return
cache
return
cache
_ROPE_DICT
:
Dict
[
Tuple
,
RotaryEmbedding
]
=
{}
def
get_rope
(
def
get_rope
(
head_size
:
int
,
head_size
:
int
,
rotary_dim
:
int
,
rotary_dim
:
int
,
...
@@ -280,6 +283,10 @@ def get_rope(
...
@@ -280,6 +283,10 @@ def get_rope(
is_neox_style
:
bool
=
True
,
is_neox_style
:
bool
=
True
,
rope_scaling
:
Optional
[
Dict
[
str
,
Any
]]
=
None
,
rope_scaling
:
Optional
[
Dict
[
str
,
Any
]]
=
None
,
)
->
RotaryEmbedding
:
)
->
RotaryEmbedding
:
key
=
(
head_size
,
rotary_dim
,
max_position
,
base
,
is_neox_style
,
rope_scaling
)
if
key
in
_ROPE_DICT
:
return
_ROPE_DICT
[
key
]
if
rope_scaling
is
None
:
if
rope_scaling
is
None
:
rotary_emb
=
RotaryEmbedding
(
head_size
,
rotary_dim
,
max_position
,
base
,
rotary_emb
=
RotaryEmbedding
(
head_size
,
rotary_dim
,
max_position
,
base
,
is_neox_style
)
is_neox_style
)
...
@@ -312,4 +319,5 @@ def get_rope(
...
@@ -312,4 +319,5 @@ def get_rope(
**
extra_kwargs
)
**
extra_kwargs
)
else
:
else
:
raise
ValueError
(
f
"Unknown RoPE scaling type
{
scaling_type
}
"
)
raise
ValueError
(
f
"Unknown RoPE scaling type
{
scaling_type
}
"
)
_ROPE_DICT
[
key
]
=
rotary_emb
return
rotary_emb
return
rotary_emb
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment