mirror of
https://git.datalinker.icu/vllm-project/vllm.git
synced 2025-12-13 23:45:01 +08:00
[Model]: Support internlm3 (#12037)
This commit is contained in:
parent
3adf0ffda8
commit
97eb97b5a4
@ -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.
|
- `internlm/internlm2-7b`, `internlm/internlm2-chat-7b`, etc.
|
||||||
- ✅︎
|
- ✅︎
|
||||||
- ✅︎
|
- ✅︎
|
||||||
|
* - `InternLM3ForCausalLM`
|
||||||
|
- InternLM3
|
||||||
|
- `internlm/internlm3-8b-instruct`, etc.
|
||||||
|
- ✅︎
|
||||||
|
- ✅︎
|
||||||
* - `JAISLMHeadModel`
|
* - `JAISLMHeadModel`
|
||||||
- Jais
|
- Jais
|
||||||
- `inceptionai/jais-13b`, `inceptionai/jais-13b-chat`, `inceptionai/jais-30b-v3`, `inceptionai/jais-30b-chat-v3`, etc.
|
- `inceptionai/jais-13b`, `inceptionai/jais-13b-chat`, `inceptionai/jais-30b-v3`, `inceptionai/jais-30b-chat-v3`, etc.
|
||||||
|
|||||||
@ -85,6 +85,8 @@ _TEXT_GENERATION_EXAMPLE_MODELS = {
|
|||||||
trust_remote_code=True),
|
trust_remote_code=True),
|
||||||
"InternLM2VEForCausalLM": _HfExamplesInfo("OpenGVLab/Mono-InternVL-2B",
|
"InternLM2VEForCausalLM": _HfExamplesInfo("OpenGVLab/Mono-InternVL-2B",
|
||||||
trust_remote_code=True),
|
trust_remote_code=True),
|
||||||
|
"InternLM3ForCausalLM": _HfExamplesInfo("internlm/internlm3-8b-instruct",
|
||||||
|
trust_remote_code=True),
|
||||||
"JAISLMHeadModel": _HfExamplesInfo("inceptionai/jais-13b-chat"),
|
"JAISLMHeadModel": _HfExamplesInfo("inceptionai/jais-13b-chat"),
|
||||||
"JambaForCausalLM": _HfExamplesInfo("ai21labs/AI21-Jamba-1.5-Mini"),
|
"JambaForCausalLM": _HfExamplesInfo("ai21labs/AI21-Jamba-1.5-Mini"),
|
||||||
"LlamaForCausalLM": _HfExamplesInfo("meta-llama/Meta-Llama-3-8B"),
|
"LlamaForCausalLM": _HfExamplesInfo("meta-llama/Meta-Llama-3-8B"),
|
||||||
|
|||||||
@ -97,20 +97,19 @@ class LlamaMLP(nn.Module):
|
|||||||
|
|
||||||
class LlamaAttention(nn.Module):
|
class LlamaAttention(nn.Module):
|
||||||
|
|
||||||
def __init__(
|
def __init__(self,
|
||||||
self,
|
config: LlamaConfig,
|
||||||
config: LlamaConfig,
|
hidden_size: int,
|
||||||
hidden_size: int,
|
num_heads: int,
|
||||||
num_heads: int,
|
num_kv_heads: int,
|
||||||
num_kv_heads: int,
|
rope_theta: float = 10000,
|
||||||
rope_theta: float = 10000,
|
rope_scaling: Optional[Dict[str, Any]] = None,
|
||||||
rope_scaling: Optional[Dict[str, Any]] = None,
|
max_position_embeddings: int = 8192,
|
||||||
max_position_embeddings: int = 8192,
|
quant_config: Optional[QuantizationConfig] = None,
|
||||||
quant_config: Optional[QuantizationConfig] = None,
|
bias: bool = False,
|
||||||
bias: bool = False,
|
cache_config: Optional[CacheConfig] = None,
|
||||||
cache_config: Optional[CacheConfig] = None,
|
prefix: str = "",
|
||||||
prefix: str = "",
|
bias_o_proj: bool = False) -> None:
|
||||||
) -> None:
|
|
||||||
super().__init__()
|
super().__init__()
|
||||||
layer_idx = extract_layer_index(prefix)
|
layer_idx = extract_layer_index(prefix)
|
||||||
self.hidden_size = hidden_size
|
self.hidden_size = hidden_size
|
||||||
@ -150,7 +149,7 @@ class LlamaAttention(nn.Module):
|
|||||||
self.o_proj = RowParallelLinear(
|
self.o_proj = RowParallelLinear(
|
||||||
input_size=self.total_num_heads * self.head_dim,
|
input_size=self.total_num_heads * self.head_dim,
|
||||||
output_size=hidden_size,
|
output_size=hidden_size,
|
||||||
bias=bias,
|
bias=bias_o_proj,
|
||||||
quant_config=quant_config,
|
quant_config=quant_config,
|
||||||
prefix=f"{prefix}.o_proj",
|
prefix=f"{prefix}.o_proj",
|
||||||
)
|
)
|
||||||
@ -231,6 +230,11 @@ class LlamaDecoderLayer(nn.Module):
|
|||||||
# Support internlm/internlm-7b with bias
|
# Support internlm/internlm-7b with bias
|
||||||
attention_bias = getattr(config, "attention_bias", False) or getattr(
|
attention_bias = getattr(config, "attention_bias", False) or getattr(
|
||||||
config, "bias", False)
|
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(
|
self.self_attn = LlamaAttention(
|
||||||
config=config,
|
config=config,
|
||||||
hidden_size=self.hidden_size,
|
hidden_size=self.hidden_size,
|
||||||
@ -242,6 +246,7 @@ class LlamaDecoderLayer(nn.Module):
|
|||||||
max_position_embeddings=max_position_embeddings,
|
max_position_embeddings=max_position_embeddings,
|
||||||
quant_config=quant_config,
|
quant_config=quant_config,
|
||||||
bias=attention_bias,
|
bias=attention_bias,
|
||||||
|
bias_o_proj=bias_o_proj,
|
||||||
cache_config=cache_config,
|
cache_config=cache_config,
|
||||||
prefix=f"{prefix}.self_attn",
|
prefix=f"{prefix}.self_attn",
|
||||||
)
|
)
|
||||||
|
|||||||
@ -60,6 +60,7 @@ _TEXT_GENERATION_MODELS = {
|
|||||||
"InternLMForCausalLM": ("llama", "LlamaForCausalLM"),
|
"InternLMForCausalLM": ("llama", "LlamaForCausalLM"),
|
||||||
"InternLM2ForCausalLM": ("internlm2", "InternLM2ForCausalLM"),
|
"InternLM2ForCausalLM": ("internlm2", "InternLM2ForCausalLM"),
|
||||||
"InternLM2VEForCausalLM": ("internlm2_ve", "InternLM2VEForCausalLM"),
|
"InternLM2VEForCausalLM": ("internlm2_ve", "InternLM2VEForCausalLM"),
|
||||||
|
"InternLM3ForCausalLM": ("llama", "LlamaForCausalLM"),
|
||||||
"JAISLMHeadModel": ("jais", "JAISLMHeadModel"),
|
"JAISLMHeadModel": ("jais", "JAISLMHeadModel"),
|
||||||
"JambaForCausalLM": ("jamba", "JambaForCausalLM"),
|
"JambaForCausalLM": ("jamba", "JambaForCausalLM"),
|
||||||
"LlamaForCausalLM": ("llama", "LlamaForCausalLM"),
|
"LlamaForCausalLM": ("llama", "LlamaForCausalLM"),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user