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
change
sglang
Commits
63dfab1b
Unverified
Commit
63dfab1b
authored
Dec 08, 2024
by
Sangchun Ha (Patrick)
Committed by
GitHub
Dec 08, 2024
Browse files
Fix shape error that occurred when loading lora weight of gemma2 model. (#2330)
parent
ef995dae
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
0 deletions
+34
-0
python/sglang/srt/models/gemma2.py
python/sglang/srt/models/gemma2.py
+34
-0
No files found.
python/sglang/srt/models/gemma2.py
View file @
63dfab1b
...
...
@@ -355,6 +355,40 @@ class Gemma2ForCausalLM(nn.Module):
input_ids
,
hidden_states
,
self
.
model
.
embed_tokens
,
forward_batch
)
def
get_hidden_dim
(
self
,
module_name
):
# return input_dim, output_dim
if
module_name
in
[
"q_proj"
,
"qkv_proj"
]:
return
(
self
.
config
.
hidden_size
,
self
.
config
.
head_dim
*
self
.
config
.
num_attention_heads
,
)
elif
module_name
in
[
"o_proj"
]:
return
(
self
.
config
.
head_dim
*
self
.
config
.
num_attention_heads
,
self
.
config
.
hidden_size
,
)
elif
module_name
in
[
"kv_proj"
]:
return
(
self
.
config
.
hidden_size
,
self
.
config
.
head_dim
*
self
.
config
.
num_key_value_heads
,
)
elif
module_name
==
"gate_up_proj"
:
return
self
.
config
.
hidden_size
,
self
.
config
.
intermediate_size
elif
module_name
==
"down_proj"
:
return
self
.
config
.
intermediate_size
,
self
.
config
.
hidden_size
else
:
raise
NotImplementedError
()
def
get_module_name
(
self
,
name
):
params_mapping
=
{
"q_proj"
:
"qkv_proj"
,
"k_proj"
:
"qkv_proj"
,
"v_proj"
:
"qkv_proj"
,
"gate_proj"
:
"gate_up_proj"
,
"up_proj"
:
"gate_up_proj"
,
}
return
params_mapping
.
get
(
name
,
name
)
def
get_attention_sliding_window_size
(
self
):
return
get_attention_sliding_window_size
(
self
.
config
)
...
...
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