Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
vllm_cscc
Commits
d130b573
Unverified
Commit
d130b573
authored
May 21, 2024
by
HUANG Fei
Committed by
GitHub
May 21, 2024
Browse files
[Model] add rope_scaling support for qwen2 (#4930)
parent
65ae8c2c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
2 deletions
+6
-2
vllm/model_executor/models/qwen2.py
vllm/model_executor/models/qwen2.py
+6
-2
No files found.
vllm/model_executor/models/qwen2.py
View file @
d130b573
...
...
@@ -89,7 +89,8 @@ class Qwen2Attention(nn.Module):
use_sliding_window
:
bool
=
False
,
cache_config
:
Optional
[
CacheConfig
]
=
None
,
quant_config
:
Optional
[
QuantizationConfig
]
=
None
,
sliding_window
:
Optional
[
int
]
=
None
)
->
None
:
sliding_window
:
Optional
[
int
]
=
None
,
rope_scaling
:
Optional
[
Tuple
]
=
None
)
->
None
:
super
().
__init__
()
self
.
hidden_size
=
hidden_size
tp_size
=
get_tensor_model_parallel_world_size
()
...
...
@@ -133,6 +134,7 @@ class Qwen2Attention(nn.Module):
rotary_dim
=
self
.
head_dim
,
max_position
=
max_position
,
base
=
self
.
rope_theta
,
rope_scaling
=
rope_scaling
,
)
self
.
attn
=
Attention
(
self
.
num_heads
,
self
.
head_dim
,
...
...
@@ -169,6 +171,7 @@ class Qwen2DecoderLayer(nn.Module):
self
.
hidden_size
=
config
.
hidden_size
# Requires transformers > 4.32.0
rope_theta
=
getattr
(
config
,
"rope_theta"
,
1000000
)
rope_scaling
=
getattr
(
config
,
"rope_scaling"
,
None
)
use_sliding_window
=
(
config
.
use_sliding_window
and
layer_idx
<
config
.
max_window_layers
)
self
.
self_attn
=
Qwen2Attention
(
...
...
@@ -180,7 +183,8 @@ class Qwen2DecoderLayer(nn.Module):
use_sliding_window
=
use_sliding_window
,
cache_config
=
cache_config
,
quant_config
=
quant_config
,
sliding_window
=
config
.
sliding_window
)
sliding_window
=
config
.
sliding_window
,
rope_scaling
=
rope_scaling
)
self
.
mlp
=
Qwen2MLP
(
hidden_size
=
self
.
hidden_size
,
intermediate_size
=
config
.
intermediate_size
,
...
...
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