A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 15, 13:30 UTC
[Misc] Remove OLMo2 config copy (#17066)
Signed-off-by: Isotr0py <2037008807@qq.com>
Isotr0py committed
Apr 24, 2025 at 21:14 UTC
b0c1f6202d2558c33bdcf252b0e7d47f9b5d19e3
4 files changed
+4
-176
vllm/model_executor/models/olmo2.py
+1
-1
@@ -28,6 +28,7 @@ from typing import Iterable, Optional, Tuple, Union
28
29
import torch
30
from torch import nn
31
+from transformers import Olmo2Config
32
33
from vllm.attention import Attention
34
from vllm.config import VllmConfig
@@ -51,7 +52,6 @@ from vllm.model_executor.models.utils import (
52
make_layers, maybe_prefix)
53
from vllm.model_executor.sampling_metadata import SamplingMetadata
54
from vllm.sequence import IntermediateTensors
54
-from vllm.transformers_utils.configs.olmo2 import Olmo2Config
55
56
57
class Olmo2Attention(nn.Module):
vllm/transformers_utils/config.py
+3
-5
@@ -36,10 +36,9 @@ from vllm.transformers_utils.configs import (ChatGLMConfig, Cohere2Config,
36
KimiVLConfig, MedusaConfig,
37
MllamaConfig, MLPSpeculatorConfig,
38
MPTConfig, NemotronConfig,
39
- NVLM_D_Config, Olmo2Config,
40
- RWConfig, SkyworkR1VChatConfig,
41
- SolarConfig, Telechat2Config,
42
- UltravoxConfig)
39
+ NVLM_D_Config, RWConfig,
40
+ SkyworkR1VChatConfig, SolarConfig,
41
+ Telechat2Config, UltravoxConfig)
42
# yapf: enable
43
from vllm.transformers_utils.utils import check_gguf_file
44
from vllm.utils import resolve_obj_by_qualname
@@ -76,7 +75,6 @@ _CONFIG_REGISTRY: Dict[str, Type[PretrainedConfig]] = {
75
"internvl_chat": InternVLChatConfig,
76
"nemotron": NemotronConfig,
77
"NVLM_D": NVLM_D_Config,
79
- "olmo2": Olmo2Config,
78
"solar": SolarConfig,
79
"skywork_chat": SkyworkR1VChatConfig,
80
"telechat": Telechat2Config,
vllm/transformers_utils/configs/__init__.py
-2
@@ -21,7 +21,6 @@ from vllm.transformers_utils.configs.moonvit import MoonViTConfig
21
from vllm.transformers_utils.configs.mpt import MPTConfig
22
from vllm.transformers_utils.configs.nemotron import NemotronConfig
23
from vllm.transformers_utils.configs.nvlm_d import NVLM_D_Config
24
-from vllm.transformers_utils.configs.olmo2 import Olmo2Config
24
from vllm.transformers_utils.configs.skyworkr1v import SkyworkR1VChatConfig
25
from vllm.transformers_utils.configs.solar import SolarConfig
26
from vllm.transformers_utils.configs.telechat2 import Telechat2Config
@@ -46,7 +45,6 @@ __all__ = [
45
"KimiVLConfig",
46
"NemotronConfig",
47
"NVLM_D_Config",
49
- "Olmo2Config",
48
"SkyworkR1VChatConfig",
49
"SolarConfig",
50
"Telechat2Config",
vllm/transformers_utils/configs/olmo2.py
deleted
-168
@@ -1,168 +0,0 @@
1
-# SPDX-License-Identifier: Apache-2.0
2
-
3
-# yapf: disable
4
-# ruff: noqa: E501
5
-# coding=utf-8
6
-# Copied from
7
-# https://github.com/huggingface/transformers/blob/main/src/transformers/models/olmo2/configuration_olmo2.py
8
-"""OLMo 2 configuration."""
9
-
10
-from transformers.configuration_utils import PretrainedConfig
11
-from transformers.utils import logging
12
-
13
-logger = logging.get_logger(__name__)
14
-
15
-
16
-class Olmo2Config(PretrainedConfig):
17
- r"""
18
- This is the configuration class to store the configuration of a [`Olmo2Model`]. It is used to instantiate an OLMo2
19
- model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
20
- defaults will yield a similar configuration to that of the [allenai/Olmo2-7B-1124-hf](https://huggingface.co/allenai/Olmo2-7B-1124-hf).
21
-
22
- Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
23
- documentation from [`PretrainedConfig`] for more information.
24
-
25
-
26
- Args:
27
- vocab_size (`int`, *optional*, defaults to 50304):
28
- Vocabulary size of the Olmo2 model. Defines the number of different tokens that can be represented by the
29
- `inputs_ids` passed when calling [`Olmo2Model`]
30
- hidden_size (`int`, *optional*, defaults to 4096):
31
- Dimension of the hidden representations.
32
- intermediate_size (`int`, *optional*, defaults to 11008):
33
- Dimension of the MLP representations.
34
- num_hidden_layers (`int`, *optional*, defaults to 32):
35
- Number of hidden layers in the Transformer decoder.
36
- num_attention_heads (`int`, *optional*, defaults to 32):
37
- Number of attention heads for each attention layer in the Transformer decoder.
38
- num_key_value_heads (`int`, *optional*):
39
- This is the number of key_value heads that should be used to implement Grouped Query Attention. If
40
- `num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA), if
41
- `num_key_value_heads=1` the model will use Multi Query Attention (MQA) otherwise GQA is used. When
42
- converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed
43
- by meanpooling all the original heads within that group. For more details checkout [this
44
- paper](https://arxiv.org/pdf/2305.13245.pdf). If it is not specified, will default to
45
- `num_attention_heads`.
46
- hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
47
- The non-linear activation function (function or string) in the decoder.
48
- max_position_embeddings (`int`, *optional*, defaults to 2048):
49
- The maximum sequence length that this model might ever be used with.
50
- initializer_range (`float`, *optional*, defaults to 0.02):
51
- The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
52
- use_cache (`bool`, *optional*, defaults to `True`):
53
- Whether or not the model should return the last key/values attentions (not used by all models). Only
54
- relevant if `config.is_decoder=True`.
55
- pad_token_id (`int`, *optional*, defaults to 1):
56
- Padding token id.
57
- bos_token_id (`int`, *optional*):
58
- Beginning of stream token id.
59
- eos_token_id (`int`, *optional*, defaults to 50279):
60
- End of stream token id.
61
- tie_word_embeddings (`bool`, *optional*, defaults to `False`):
62
- Whether to tie weight embeddings
63
- rope_theta (`float`, *optional*, defaults to 10000.0):
64
- The base period of the RoPE embeddings.
65
- rope_scaling (`Dict`, *optional*):
66
- Dictionary containing the scaling configuration for the RoPE embeddings. Currently supports two scaling
67
- strategies: linear and dynamic. Their scaling factor must be a float greater than 1. The expected format is
68
- `{"type": strategy name, "factor": scaling factor}`. When using this flag, don't update
69
- `max_position_embeddings` to the expected new maximum. See the following thread for more information on how
70
- these scaling strategies behave:
71
- https://www.reddit.com/r/LocalLLaMA/comments/14mrgpr/dynamically_scaled_rope_further_increases/. This is an
72
- experimental feature, subject to breaking API changes in future versions.
73
- attention_bias (`bool`, defaults to `False`, *optional*, defaults to `False`):
74
- Whether to use a bias in the query, key, value and output projection layers during self-attention.
75
- attention_dropout (`float`, *optional*, defaults to 0.0):
76
- The dropout ratio for the attention probabilities.
77
- rms_norm_eps (`float`, *optional*, defaults to 1e-05):
78
- The epsilon used by the rms normalization layers.
79
-
80
- ```python
81
- >>> from transformers import Olmo2Model, Olmo2Config
82
-
83
- >>> # Initializing a Olmo2 7B style configuration
84
- >>> configuration = Olmo2Config()
85
-
86
- >>> # Initializing a model from the Olmo2 7B style configuration
87
- >>> model = Olmo2Model(configuration)
88
-
89
- >>> # Accessing the model configuration
90
- >>> configuration = model.config
91
- ```
92
- """
93
-
94
- model_type = "olmo2"
95
- keys_to_ignore_at_inference = ["past_key_values"]
96
-
97
- def __init__(
98
- self,
99
- vocab_size=50304,
100
- hidden_size=4096,
101
- intermediate_size=11008,
102
- num_hidden_layers=32,
103
- num_attention_heads=32,
104
- num_key_value_heads=None,
105
- hidden_act="silu",
106
- max_position_embeddings=2048,
107
- initializer_range=0.02,
108
- use_cache=True,
109
- pad_token_id=1,
110
- bos_token_id=None,
111
- eos_token_id=50279,
112
- tie_word_embeddings=False,
113
- rope_theta=10000.0,
114
- rope_scaling=None,
115
- attention_bias=False,
116
- attention_dropout=0.0,
117
- rms_norm_eps=1e-5,
118
- **kwargs,
119
- ):
120
- super().__init__(
121
- pad_token_id=pad_token_id,
122
- bos_token_id=bos_token_id,
123
- eos_token_id=eos_token_id,
124
- tie_word_embeddings=tie_word_embeddings,
125
- **kwargs,
126
- )
127
- self.vocab_size = vocab_size
128
- self.max_position_embeddings = max_position_embeddings
129
- self.hidden_size = hidden_size
130
- self.intermediate_size = intermediate_size
131
- self.num_hidden_layers = num_hidden_layers
132
- self.num_attention_heads = num_attention_heads
133
-
134
- # for backward compatibility
135
- if num_key_value_heads is None:
136
- num_key_value_heads = num_attention_heads
137
-
138
- self.num_key_value_heads = num_key_value_heads
139
- self.hidden_act = hidden_act
140
- self.initializer_range = initializer_range
141
- self.use_cache = use_cache
142
- self.rope_theta = rope_theta
143
- self.rope_scaling = rope_scaling
144
- self._rope_scaling_validation()
145
- self.attention_bias = attention_bias
146
- self.attention_dropout = attention_dropout
147
-
148
- self.rms_norm_eps = rms_norm_eps
149
-
150
- def _rope_scaling_validation(self):
151
- """
152
- Validate the `rope_scaling` configuration.
153
- """
154
- if self.rope_scaling is None:
155
- return
156
-
157
- if not isinstance(self.rope_scaling, dict) or len(self.rope_scaling) != 2:
158
- raise ValueError(
159
- "`rope_scaling` must be a dictionary with two fields, `type` and `factor`, " f"got {self.rope_scaling}"
160
- )
161
- rope_scaling_type = self.rope_scaling.get("type", None)
162
- rope_scaling_factor = self.rope_scaling.get("factor", None)
163
- if rope_scaling_type is None or rope_scaling_type not in ["linear", "dynamic"]:
164
- raise ValueError(
165
- f"`rope_scaling`'s type field must be one of ['linear', 'dynamic'], got {rope_scaling_type}"
166
- )
167
- if rope_scaling_factor is None or not isinstance(rope_scaling_factor, float) or rope_scaling_factor <= 1.0:
168
- raise ValueError(f"`rope_scaling`'s factor field must be a float > 1, got {rope_scaling_factor}")