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
xdb4_94051
vllm
Commits
e5452ddf
Unverified
Commit
e5452ddf
authored
Nov 30, 2023
by
Woosuk Kwon
Committed by
GitHub
Nov 30, 2023
Browse files
Normalize head weights for Baichuan 2 (#1876)
parent
d06980df
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
2 deletions
+13
-2
README.md
README.md
+1
-1
docs/source/models/supported_models.rst
docs/source/models/supported_models.rst
+1
-1
vllm/model_executor/models/baichuan.py
vllm/model_executor/models/baichuan.py
+11
-0
No files found.
README.md
View file @
e5452ddf
...
@@ -47,7 +47,7 @@ vLLM is flexible and easy to use with:
...
@@ -47,7 +47,7 @@ vLLM is flexible and easy to use with:
vLLM seamlessly supports many Hugging Face models, including the following architectures:
vLLM seamlessly supports many Hugging Face models, including the following architectures:
-
Aquila & Aquila2 (
`BAAI/AquilaChat2-7B`
,
`BAAI/AquilaChat2-34B`
,
`BAAI/Aquila-7B`
,
`BAAI/AquilaChat-7B`
, etc.)
-
Aquila & Aquila2 (
`BAAI/AquilaChat2-7B`
,
`BAAI/AquilaChat2-34B`
,
`BAAI/Aquila-7B`
,
`BAAI/AquilaChat-7B`
, etc.)
-
Baichuan (
`baichuan-inc/Baichuan
-7B
`
,
`baichuan-inc/Baichuan-
13B-Chat
`
, etc.)
-
Baichuan
& Baichuan2
(
`baichuan-inc/Baichuan
2-13B-Chat
`
,
`baichuan-inc/Baichuan-
7B
`
, etc.)
-
BLOOM (
`bigscience/bloom`
,
`bigscience/bloomz`
, etc.)
-
BLOOM (
`bigscience/bloom`
,
`bigscience/bloomz`
, etc.)
-
ChatGLM (
`THUDM/chatglm2-6b`
,
`THUDM/chatglm3-6b`
, etc.)
-
ChatGLM (
`THUDM/chatglm2-6b`
,
`THUDM/chatglm3-6b`
, etc.)
-
Falcon (
`tiiuae/falcon-7b`
,
`tiiuae/falcon-40b`
,
`tiiuae/falcon-rw-7b`
, etc.)
-
Falcon (
`tiiuae/falcon-7b`
,
`tiiuae/falcon-40b`
,
`tiiuae/falcon-rw-7b`
, etc.)
...
...
docs/source/models/supported_models.rst
View file @
e5452ddf
...
@@ -19,7 +19,7 @@ Alongside each architecture, we include some popular models that use it.
...
@@ -19,7 +19,7 @@ Alongside each architecture, we include some popular models that use it.
- :code:`BAAI/Aquila-7B`, :code:`BAAI/AquilaChat-7B`, etc.
- :code:`BAAI/Aquila-7B`, :code:`BAAI/AquilaChat-7B`, etc.
* - :code:`BaiChuanForCausalLM`
* - :code:`BaiChuanForCausalLM`
- Baichuan
- Baichuan
- :code:`baichuan-inc/Baichuan
-7B
`, :code:`baichuan-inc/Baichuan-
13B-Chat
`, etc.
- :code:`baichuan-inc/Baichuan
2-13B-Chat
`, :code:`baichuan-inc/Baichuan-
7B
`, etc.
* - :code:`ChatGLMModel`
* - :code:`ChatGLMModel`
- ChatGLM
- ChatGLM
- :code:`THUDM/chatglm2-6b`, :code:`THUDM/chatglm3-6b`, etc.
- :code:`THUDM/chatglm2-6b`, :code:`THUDM/chatglm3-6b`, etc.
...
...
vllm/model_executor/models/baichuan.py
View file @
e5452ddf
...
@@ -341,6 +341,17 @@ class BaiChuanBaseForCausalLM(nn.Module):
...
@@ -341,6 +341,17 @@ class BaiChuanBaseForCausalLM(nn.Module):
model_name_or_path
,
cache_dir
,
load_format
,
revision
):
model_name_or_path
,
cache_dir
,
load_format
,
revision
):
if
"rotary_emb.inv_freq"
in
name
:
if
"rotary_emb.inv_freq"
in
name
:
continue
continue
if
name
==
"lm_head.weight"
:
# Unlike Baichuan, Baichuan2 normalizes the head weights. Refer to:
# https://huggingface.co/baichuan-inc/Baichuan2-7B-Chat/blob/84603cde5ebffb6084e476cfaeceaf0b8b91fe54/modeling_baichuan.py#L508
# Distinguish between Baichuan and Baichuan2 by checking the
# vocab size. This is suggested by
# https://github.com/vllm-project/vllm/pull/1022#discussion_r1325652704
is_baichuan2
=
self
.
config
.
vocab_size
==
125696
if
is_baichuan2
:
loaded_weight
=
torch
.
nn
.
functional
.
normalize
(
loaded_weight
)
for
(
param_name
,
weight_name
,
shard_id
)
in
stacked_params_mapping
:
for
(
param_name
,
weight_name
,
shard_id
)
in
stacked_params_mapping
:
if
weight_name
not
in
name
:
if
weight_name
not
in
name
:
continue
continue
...
...
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