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
97eb97b5
Unverified
Commit
97eb97b5
authored
Jan 15, 2025
by
RunningLeon
Committed by
GitHub
Jan 15, 2025
Browse files
[Model]: Support internlm3 (#12037)
parent
3adf0ffd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
15 deletions
+28
-15
docs/source/models/supported_models.md
docs/source/models/supported_models.md
+5
-0
tests/models/registry.py
tests/models/registry.py
+2
-0
vllm/model_executor/models/llama.py
vllm/model_executor/models/llama.py
+20
-15
vllm/model_executor/models/registry.py
vllm/model_executor/models/registry.py
+1
-0
No files found.
docs/source/models/supported_models.md
View file @
97eb97b5
...
...
@@ -216,6 +216,11 @@ See [this page](#generative-models) for more information on how to use generativ
- `internlm/internlm2-7b`, `internlm/internlm2-chat-7b`, etc.
- ✅︎
- ✅︎
* - `InternLM3ForCausalLM`
- InternLM3
- `internlm/internlm3-8b-instruct`, etc.
- ✅︎
- ✅︎
* - `JAISLMHeadModel`
- Jais
- `inceptionai/jais-13b`, `inceptionai/jais-13b-chat`, `inceptionai/jais-30b-v3`, `inceptionai/jais-30b-chat-v3`, etc.
...
...
tests/models/registry.py
View file @
97eb97b5
...
...
@@ -85,6 +85,8 @@ _TEXT_GENERATION_EXAMPLE_MODELS = {
trust_remote_code
=
True
),
"InternLM2VEForCausalLM"
:
_HfExamplesInfo
(
"OpenGVLab/Mono-InternVL-2B"
,
trust_remote_code
=
True
),
"InternLM3ForCausalLM"
:
_HfExamplesInfo
(
"internlm/internlm3-8b-instruct"
,
trust_remote_code
=
True
),
"JAISLMHeadModel"
:
_HfExamplesInfo
(
"inceptionai/jais-13b-chat"
),
"JambaForCausalLM"
:
_HfExamplesInfo
(
"ai21labs/AI21-Jamba-1.5-Mini"
),
"LlamaForCausalLM"
:
_HfExamplesInfo
(
"meta-llama/Meta-Llama-3-8B"
),
...
...
vllm/model_executor/models/llama.py
View file @
97eb97b5
...
...
@@ -97,20 +97,19 @@ class LlamaMLP(nn.Module):
class
LlamaAttention
(
nn
.
Module
):
def
__init__
(
self
,
config
:
LlamaConfig
,
hidden_size
:
int
,
num_heads
:
int
,
num_kv_heads
:
int
,
rope_theta
:
float
=
10000
,
rope_scaling
:
Optional
[
Dict
[
str
,
Any
]]
=
None
,
max_position_embeddings
:
int
=
8192
,
quant_config
:
Optional
[
QuantizationConfig
]
=
None
,
bias
:
bool
=
False
,
cache_config
:
Optional
[
CacheConfig
]
=
None
,
prefix
:
str
=
""
,
)
->
None
:
def
__init__
(
self
,
config
:
LlamaConfig
,
hidden_size
:
int
,
num_heads
:
int
,
num_kv_heads
:
int
,
rope_theta
:
float
=
10000
,
rope_scaling
:
Optional
[
Dict
[
str
,
Any
]]
=
None
,
max_position_embeddings
:
int
=
8192
,
quant_config
:
Optional
[
QuantizationConfig
]
=
None
,
bias
:
bool
=
False
,
cache_config
:
Optional
[
CacheConfig
]
=
None
,
prefix
:
str
=
""
,
bias_o_proj
:
bool
=
False
)
->
None
:
super
().
__init__
()
layer_idx
=
extract_layer_index
(
prefix
)
self
.
hidden_size
=
hidden_size
...
...
@@ -150,7 +149,7 @@ class LlamaAttention(nn.Module):
self
.
o_proj
=
RowParallelLinear
(
input_size
=
self
.
total_num_heads
*
self
.
head_dim
,
output_size
=
hidden_size
,
bias
=
bias
,
bias
=
bias
_o_proj
,
quant_config
=
quant_config
,
prefix
=
f
"
{
prefix
}
.o_proj"
,
)
...
...
@@ -231,6 +230,11 @@ class LlamaDecoderLayer(nn.Module):
# Support internlm/internlm-7b with bias
attention_bias
=
getattr
(
config
,
"attention_bias"
,
False
)
or
getattr
(
config
,
"bias"
,
False
)
bias_o_proj
=
attention_bias
# support internlm/internlm3-8b with qkv_bias
if
hasattr
(
config
,
'qkv_bias'
):
attention_bias
=
config
.
qkv_bias
self
.
self_attn
=
LlamaAttention
(
config
=
config
,
hidden_size
=
self
.
hidden_size
,
...
...
@@ -242,6 +246,7 @@ class LlamaDecoderLayer(nn.Module):
max_position_embeddings
=
max_position_embeddings
,
quant_config
=
quant_config
,
bias
=
attention_bias
,
bias_o_proj
=
bias_o_proj
,
cache_config
=
cache_config
,
prefix
=
f
"
{
prefix
}
.self_attn"
,
)
...
...
vllm/model_executor/models/registry.py
View file @
97eb97b5
...
...
@@ -60,6 +60,7 @@ _TEXT_GENERATION_MODELS = {
"InternLMForCausalLM"
:
(
"llama"
,
"LlamaForCausalLM"
),
"InternLM2ForCausalLM"
:
(
"internlm2"
,
"InternLM2ForCausalLM"
),
"InternLM2VEForCausalLM"
:
(
"internlm2_ve"
,
"InternLM2VEForCausalLM"
),
"InternLM3ForCausalLM"
:
(
"llama"
,
"LlamaForCausalLM"
),
"JAISLMHeadModel"
:
(
"jais"
,
"JAISLMHeadModel"
),
"JambaForCausalLM"
:
(
"jamba"
,
"JambaForCausalLM"
),
"LlamaForCausalLM"
:
(
"llama"
,
"LlamaForCausalLM"
),
...
...
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