ADAPT-Chase commited on
Commit
501448b
·
verified ·
1 Parent(s): dc153a9

Add files using upload-large-folder tool

Browse files
Files changed (21) hide show
  1. .gitattributes +1 -0
  2. tool_server/.venv/lib/python3.12/site-packages/vllm/reasoning/__pycache__/qwen3_reasoning_parser.cpython-312.pyc +0 -0
  3. tool_server/.venv/lib/python3.12/site-packages/vllm/reasoning/__pycache__/step3_reasoning_parser.cpython-312.pyc +0 -0
  4. tool_server/.venv/lib/python3.12/site-packages/vllm/third_party/__pycache__/__init__.cpython-312.pyc +0 -0
  5. tool_server/.venv/lib/python3.12/site-packages/vllm/third_party/__pycache__/pynvml.cpython-312.pyc +3 -0
  6. tool_server/.venv/lib/python3.12/site-packages/vllm/transformers_utils/chat_templates/__init__.py +5 -0
  7. tool_server/.venv/lib/python3.12/site-packages/vllm/transformers_utils/chat_templates/registry.py +60 -0
  8. tool_server/.venv/lib/python3.12/site-packages/vllm/transformers_utils/chat_templates/template_basic.jinja +3 -0
  9. tool_server/.venv/lib/python3.12/site-packages/vllm/transformers_utils/chat_templates/template_blip2.jinja +11 -0
  10. tool_server/.venv/lib/python3.12/site-packages/vllm/transformers_utils/chat_templates/template_chatml.jinja +10 -0
  11. tool_server/.venv/lib/python3.12/site-packages/vllm/transformers_utils/chat_templates/template_deepseek_vl2.jinja +23 -0
  12. tool_server/.venv/lib/python3.12/site-packages/vllm/transformers_utils/chat_templates/template_fuyu.jinja +3 -0
  13. tool_server/.venv/lib/python3.12/site-packages/vllm/transformers_utils/configs/__init__.py +51 -0
  14. tool_server/.venv/lib/python3.12/site-packages/vllm/transformers_utils/configs/arctic.py +207 -0
  15. tool_server/.venv/lib/python3.12/site-packages/vllm/transformers_utils/configs/chatglm.py +72 -0
  16. tool_server/.venv/lib/python3.12/site-packages/vllm/transformers_utils/configs/deepseek_vl2.py +216 -0
  17. tool_server/.venv/lib/python3.12/site-packages/vllm/transformers_utils/configs/eagle.py +82 -0
  18. tool_server/.venv/lib/python3.12/site-packages/vllm/transformers_utils/configs/falcon.py +90 -0
  19. tool_server/.venv/lib/python3.12/site-packages/vllm/transformers_utils/configs/jais.py +238 -0
  20. tool_server/.venv/lib/python3.12/site-packages/vllm/transformers_utils/configs/kimi_vl.py +37 -0
  21. tool_server/.venv/lib/python3.12/site-packages/vllm/transformers_utils/configs/medusa.py +63 -0
.gitattributes CHANGED
@@ -4616,3 +4616,4 @@ tool_server/.venv/lib/python3.12/site-packages/torch/_dynamo/__pycache__/output_
4616
  tool_server/.venv/lib/python3.12/site-packages/torch/_dynamo/__pycache__/trace_rules.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
4617
  tool_server/.venv/lib/python3.12/site-packages/torch/_dynamo/variables/__pycache__/builder.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
4618
  tool_server/.venv/lib/python3.12/site-packages/torch/_dynamo/variables/__pycache__/higher_order_ops.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
 
 
4616
  tool_server/.venv/lib/python3.12/site-packages/torch/_dynamo/__pycache__/trace_rules.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
4617
  tool_server/.venv/lib/python3.12/site-packages/torch/_dynamo/variables/__pycache__/builder.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
4618
  tool_server/.venv/lib/python3.12/site-packages/torch/_dynamo/variables/__pycache__/higher_order_ops.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
4619
+ tool_server/.venv/lib/python3.12/site-packages/vllm/third_party/__pycache__/pynvml.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
tool_server/.venv/lib/python3.12/site-packages/vllm/reasoning/__pycache__/qwen3_reasoning_parser.cpython-312.pyc ADDED
Binary file (6.27 kB). View file
 
tool_server/.venv/lib/python3.12/site-packages/vllm/reasoning/__pycache__/step3_reasoning_parser.cpython-312.pyc ADDED
Binary file (4.88 kB). View file
 
tool_server/.venv/lib/python3.12/site-packages/vllm/third_party/__pycache__/__init__.cpython-312.pyc ADDED
Binary file (186 Bytes). View file
 
tool_server/.venv/lib/python3.12/site-packages/vllm/third_party/__pycache__/pynvml.cpython-312.pyc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b39b196b989dd8a44e513454b3ab159b27b761240f29a4a3a3ac4bb14cf00543
3
+ size 250755
tool_server/.venv/lib/python3.12/site-packages/vllm/transformers_utils/chat_templates/__init__.py ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
+ from .registry import get_chat_template_fallback_path
4
+
5
+ __all__ = ["get_chat_template_fallback_path"]
tool_server/.venv/lib/python3.12/site-packages/vllm/transformers_utils/chat_templates/registry.py ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
+ from pathlib import Path
4
+ from typing import Callable, Optional, Union
5
+
6
+ from vllm.logger import init_logger
7
+
8
+ logger = init_logger(__file__)
9
+
10
+ CHAT_TEMPLATES_DIR = Path(__file__).parent
11
+
12
+ ChatTemplatePath = Union[Path, Callable[[str], Optional[Path]]]
13
+
14
+
15
+ def _get_qwen_chat_template_fallback(
16
+ tokenizer_name_or_path: str) -> Optional[Path]:
17
+ if tokenizer_name_or_path.endswith("-Chat"):
18
+ return CHAT_TEMPLATES_DIR / "template_chatml.jinja"
19
+
20
+ return CHAT_TEMPLATES_DIR / "template_basic.jinja"
21
+
22
+
23
+ # yapf: disable
24
+ _MODEL_TYPE_TO_CHAT_TEMPLATE_FALLBACK: dict[str, ChatTemplatePath] = {
25
+ "blip-2": CHAT_TEMPLATES_DIR / "template_blip2.jinja",
26
+ "chameleon": CHAT_TEMPLATES_DIR / "template_basic.jinja",
27
+ "deepseek_vl_v2": CHAT_TEMPLATES_DIR / "template_deepseek_vl2.jinja",
28
+ "florence2": CHAT_TEMPLATES_DIR / "template_basic.jinja",
29
+ "fuyu": CHAT_TEMPLATES_DIR / "template_fuyu.jinja",
30
+ "paligemma": CHAT_TEMPLATES_DIR / "template_basic.jinja",
31
+ "qwen": _get_qwen_chat_template_fallback,
32
+ }
33
+ # yapf: enable
34
+
35
+
36
+ def register_chat_template_fallback_path(
37
+ model_type: str,
38
+ chat_template: ChatTemplatePath,
39
+ ) -> None:
40
+ if model_type in _MODEL_TYPE_TO_CHAT_TEMPLATE_FALLBACK:
41
+ logger.warning(
42
+ "Model type %s already has a chat template registered. "
43
+ "It will be overwritten by the new chat template %s.", model_type,
44
+ chat_template)
45
+
46
+ _MODEL_TYPE_TO_CHAT_TEMPLATE_FALLBACK[model_type] = chat_template
47
+
48
+
49
+ def get_chat_template_fallback_path(
50
+ model_type: str,
51
+ tokenizer_name_or_path: str,
52
+ ) -> Optional[Path]:
53
+ chat_template = _MODEL_TYPE_TO_CHAT_TEMPLATE_FALLBACK.get(model_type)
54
+ if callable(chat_template):
55
+ chat_template = chat_template(tokenizer_name_or_path)
56
+
57
+ if chat_template is None:
58
+ return None
59
+
60
+ return chat_template
tool_server/.venv/lib/python3.12/site-packages/vllm/transformers_utils/chat_templates/template_basic.jinja ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ {%- for message in messages -%}
2
+ {{- message['content'] -}}
3
+ {%- endfor -%}
tool_server/.venv/lib/python3.12/site-packages/vllm/transformers_utils/chat_templates/template_blip2.jinja ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- for message in messages -%}
2
+ {%- if message['role'] == 'user' -%}
3
+ {{- 'Question: ' + message['content'] + ' ' -}}
4
+ {%- elif message['role'] == 'assistant' -%}
5
+ {{- 'Answer: ' + message['content'] + ' ' -}}
6
+ {%- endif -%}
7
+ {%- endfor -%}
8
+
9
+ {%- if add_generation_prompt -%}
10
+ {{- 'Answer:' -}}
11
+ {% endif %}
tool_server/.venv/lib/python3.12/site-packages/vllm/transformers_utils/chat_templates/template_chatml.jinja ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- for message in messages -%}
2
+ {{- '<|im_start|>' + message['role'] + '\n' + message['content'] -}}
3
+ {%- if (loop.last and add_generation_prompt) or not loop.last -%}
4
+ {{- '<|im_end|>' + '\n' -}}
5
+ {%- endif -%}
6
+ {%- endfor -%}
7
+
8
+ {%- if add_generation_prompt and messages[-1]['role'] != 'assistant' -%}
9
+ {{- '<|im_start|>assistant\n' -}}
10
+ {%- endif -%}
tool_server/.venv/lib/python3.12/site-packages/vllm/transformers_utils/chat_templates/template_deepseek_vl2.jinja ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- if messages[0]['role'] == 'system' -%}
2
+ {%- set system_message = messages[0]['content'] -%}
3
+ {%- set messages = messages[1:] -%}
4
+ {%- else -%}
5
+ {% set system_message = '' -%}
6
+ {%- endif -%}
7
+
8
+ {{ bos_token + system_message }}
9
+ {%- for message in messages -%}
10
+ {%- if (message['role'] == 'user') != (loop.index0 % 2 == 0) -%}
11
+ {{ raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') }}
12
+ {%- endif -%}
13
+
14
+ {%- if message['role'] == 'user' -%}
15
+ {{ '<|User|>: ' + message['content'] + '\n\n' }}
16
+ {%- elif message['role'] == 'assistant' -%}
17
+ {{ '<|Assistant|>: ' + message['content'] + eos_token + '\n\n' }}
18
+ {%- endif -%}
19
+ {%- endfor -%}
20
+
21
+ {%- if add_generation_prompt -%}
22
+ {{ '<|Assistant|>: ' }}
23
+ {%- endif -%}
tool_server/.venv/lib/python3.12/site-packages/vllm/transformers_utils/chat_templates/template_fuyu.jinja ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ {%- for message in messages -%}
2
+ {{- message['content'] + '\n' -}}
3
+ {%- endfor -%}
tool_server/.venv/lib/python3.12/site-packages/vllm/transformers_utils/configs/__init__.py ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
+ """
4
+ Model configs may be defined in this directory for the following reasons:
5
+
6
+ - There is no configuration file defined by HF Hub or Transformers library.
7
+ - There is a need to override the existing config to support vLLM.
8
+ """
9
+
10
+ from vllm.transformers_utils.configs.chatglm import ChatGLMConfig
11
+ from vllm.transformers_utils.configs.deepseek_vl2 import DeepseekVLV2Config
12
+ from vllm.transformers_utils.configs.eagle import EAGLEConfig
13
+ # RWConfig is for the original tiiuae/falcon-40b(-instruct) and
14
+ # tiiuae/falcon-7b(-instruct) models. Newer Falcon models will use the
15
+ # `FalconConfig` class from the official HuggingFace transformers library.
16
+ from vllm.transformers_utils.configs.falcon import RWConfig
17
+ from vllm.transformers_utils.configs.jais import JAISConfig
18
+ from vllm.transformers_utils.configs.kimi_vl import KimiVLConfig
19
+ from vllm.transformers_utils.configs.medusa import MedusaConfig
20
+ from vllm.transformers_utils.configs.mlp_speculator import MLPSpeculatorConfig
21
+ from vllm.transformers_utils.configs.moonvit import MoonViTConfig
22
+ from vllm.transformers_utils.configs.nemotron import NemotronConfig
23
+ from vllm.transformers_utils.configs.nemotron_h import NemotronHConfig
24
+ from vllm.transformers_utils.configs.nemotron_vl import Nemotron_Nano_VL_Config
25
+ from vllm.transformers_utils.configs.ovis import OvisConfig
26
+ from vllm.transformers_utils.configs.speculators.base import SpeculatorsConfig
27
+ from vllm.transformers_utils.configs.step3_vl import (Step3TextConfig,
28
+ Step3VisionEncoderConfig,
29
+ Step3VLConfig)
30
+ from vllm.transformers_utils.configs.ultravox import UltravoxConfig
31
+
32
+ __all__ = [
33
+ "ChatGLMConfig",
34
+ "DeepseekVLV2Config",
35
+ "EAGLEConfig",
36
+ "RWConfig",
37
+ "JAISConfig",
38
+ "MedusaConfig",
39
+ "MLPSpeculatorConfig",
40
+ "MoonViTConfig",
41
+ "KimiVLConfig",
42
+ "NemotronConfig",
43
+ "NemotronHConfig",
44
+ "Nemotron_Nano_VL_Config",
45
+ "OvisConfig",
46
+ "SpeculatorsConfig",
47
+ "UltravoxConfig",
48
+ "Step3VLConfig",
49
+ "Step3VisionEncoderConfig",
50
+ "Step3TextConfig",
51
+ ]
tool_server/.venv/lib/python3.12/site-packages/vllm/transformers_utils/configs/arctic.py ADDED
@@ -0,0 +1,207 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
+
4
+ # yapf: disable
5
+ # ruff: noqa: E501
6
+ # coding=utf-8
7
+ # Copied from
8
+ # https://huggingface.co/Snowflake/snowflake-arctic-instruct/blob/main/configuration_arctic.py
9
+ """ Arctic model configuration"""
10
+
11
+ from dataclasses import asdict, dataclass
12
+ from typing import Any
13
+
14
+ from transformers.configuration_utils import PretrainedConfig
15
+ from transformers.utils import logging
16
+
17
+ logger = logging.get_logger(__name__)
18
+
19
+ ARCTIC_PRETRAINED_CONFIG_ARCHIVE_MAP = {
20
+ "arctic": "https://huggingface.co/Snowflake/snowflake-arctic-instruct/tree/main/config.json",
21
+ }
22
+
23
+
24
+ @dataclass
25
+ class ArcticLoRAConfig:
26
+ lora_r: int = 64
27
+ lora_alpha: float = 16
28
+ shard_base_weights: bool = False
29
+
30
+
31
+ @dataclass
32
+ class ArcticQuantizationConfig:
33
+ q_bits: int = 8
34
+ rounding: str = "nearest"
35
+ mantissa_bits: int = 3
36
+ group_size: int = 128
37
+
38
+
39
+ class ArcticConfig(PretrainedConfig):
40
+ r"""
41
+ This is the configuration class to store the configuration of a [`ArcticModel`]. It is used to instantiate an
42
+ Arctic model according to the specified arguments, defining the model architecture. Instantiating a configuration
43
+ with the defaults will yield a similar configuration to that of the #TODO(rsamdani): add what model has the default config..
44
+
45
+
46
+ Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
47
+ documentation from [`PretrainedConfig`] for more information.
48
+
49
+
50
+ Args:
51
+ vocab_size (`int`, *optional*, defaults to 32000):
52
+ Vocabulary size of the Arctic model. Defines the number of different tokens that can be represented by the
53
+ `inputs_ids` passed when calling [`ArcticModel`]
54
+ hidden_size (`int`, *optional*, defaults to 4096):
55
+ Dimension of the hidden representations.
56
+ intermediate_size (`int`, *optional*, defaults to 14336):
57
+ Dimension of the MLP representations.
58
+ num_hidden_layers (`int`, *optional*, defaults to 32):
59
+ Number of hidden layers in the Transformer encoder.
60
+ num_attention_heads (`int`, *optional*, defaults to 32):
61
+ Number of attention heads for each attention layer in the Transformer encoder.
62
+ num_key_value_heads (`int`, *optional*, defaults to 8):
63
+ This is the number of key_value heads that should be used to implement Grouped Query Attention. If
64
+ `num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA), if
65
+ `num_key_value_heads=1 the model will use Multi Query Attention (MQA) otherwise GQA is used. When
66
+ converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed
67
+ by meanpooling all the original heads within that group. For more details checkout [this
68
+ paper](https://arxiv.org/pdf/2305.13245.pdf). If it is not specified, will default to `8`.
69
+ hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
70
+ The non-linear activation function (function or string) in the decoder.
71
+ max_position_embeddings (`int`, *optional*, defaults to `4096*32`):
72
+ The maximum sequence length that this model might ever be used with. Arctic's sliding window attention
73
+ allows sequence of up to 4096*32 tokens.
74
+ initializer_range (`float`, *optional*, defaults to 0.02):
75
+ The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
76
+ rms_norm_eps (`float`, *optional*, defaults to 1e-05):
77
+ The epsilon used by the rms normalization layers.
78
+ use_cache (`bool`, *optional*, defaults to `True`):
79
+ Whether or not the model should return the last key/values attentions (not used by all models). Only
80
+ relevant if `config.is_decoder=True`.
81
+ pad_token_id (`int`, *optional*):
82
+ The id of the padding token.
83
+ bos_token_id (`int`, *optional*, defaults to 1):
84
+ The id of the "beginning-of-sequence" token.
85
+ eos_token_id (`int`, *optional*, defaults to 2):
86
+ The id of the "end-of-sequence" token.
87
+ tie_word_embeddings (`bool`, *optional*, defaults to `False`):
88
+ Whether the model's input and output word embeddings should be tied.
89
+ rope_theta (`float`, *optional*, defaults to 1000000.0):
90
+ The base period of the RoPE embeddings.
91
+ sliding_window (`int`, *optional*):
92
+ Sliding window attention window size. If not specified, will default to `4096`.
93
+ attention_dropout (`float`, *optional*, defaults to 0.0):
94
+ The dropout ratio for the attention probabilities.
95
+ num_experts_per_tok (`int`, *optional*, defaults to 2):
96
+ The number of experts to root per-token, can be also interpreted as the `top-p` routing
97
+ parameter
98
+ num_local_experts (`int`, *optional*, defaults to 8):
99
+ Number of experts per Sparse MLP layer.
100
+ router_aux_loss_coef (`float`, *optional*, defaults to 0.001):
101
+ The aux loss factor for the total loss.
102
+
103
+ ```python
104
+ >>> from transformers import ArcticModel, ArcticConfig
105
+
106
+ >>> # Initializing a Arctic 7B style configuration TODO(rsamdani): verify which model does the default configuration correspond to.
107
+ >>> configuration = ArcticConfig()
108
+
109
+ >>> # Initializing a model from the Arctic 7B style configuration
110
+ >>> model = ArcticModel(configuration)
111
+
112
+ >>> # Accessing the model configuration
113
+ >>> configuration = model.config
114
+ ```"""
115
+
116
+ model_type = "arctic"
117
+ keys_to_ignore_at_inference = ["past_key_values"]
118
+
119
+ def __init__(
120
+ self,
121
+ vocab_size=32000,
122
+ hidden_size=4096,
123
+ intermediate_size=14336,
124
+ num_hidden_layers=32,
125
+ num_attention_heads=32,
126
+ num_key_value_heads=None,
127
+ hidden_act="silu",
128
+ max_position_embeddings=4096,
129
+ initializer_range=0.02,
130
+ rms_norm_eps=1e-5,
131
+ use_cache=True,
132
+ pad_token_id=None,
133
+ bos_token_id=1,
134
+ eos_token_id=2,
135
+ tie_word_embeddings=False,
136
+ rope_theta=1e6,
137
+ sliding_window=None,
138
+ attention_dropout=0.0,
139
+ num_experts_per_tok=1,
140
+ num_local_experts=8,
141
+ router_aux_loss_coef=0.001,
142
+ moe_layer_frequency=2,
143
+ parallel_attn_mlp_res=False,
144
+ moe_train_capacity_factor=1,
145
+ moe_eval_capacity_factor=1,
146
+ enable_expert_tensor_parallelism=False,
147
+ moe_min_capacity=0,
148
+ moe_token_dropping=True,
149
+ quantization=None,
150
+ **kwargs,
151
+ ):
152
+ self.vocab_size = vocab_size
153
+ self.max_position_embeddings = max_position_embeddings
154
+ self.hidden_size = hidden_size
155
+ self.intermediate_size = intermediate_size
156
+ self.num_hidden_layers = num_hidden_layers
157
+ self.num_attention_heads = num_attention_heads
158
+ self.sliding_window = sliding_window
159
+
160
+ # for backward compatibility
161
+ if num_key_value_heads is None:
162
+ num_key_value_heads = num_attention_heads
163
+
164
+ self.num_key_value_heads = num_key_value_heads
165
+ self.hidden_act = hidden_act
166
+ self.initializer_range = initializer_range
167
+ self.rms_norm_eps = rms_norm_eps
168
+ self.use_cache = use_cache
169
+ self.rope_theta = rope_theta
170
+ self.attention_dropout = attention_dropout
171
+
172
+ self.num_experts_per_tok = num_experts_per_tok
173
+ self.num_local_experts = num_local_experts
174
+ self.router_aux_loss_coef = router_aux_loss_coef
175
+ self.moe_layer_frequency = moe_layer_frequency
176
+ self.moe_train_capacity_factor = moe_train_capacity_factor
177
+ self.moe_eval_capacity_factor = moe_eval_capacity_factor
178
+ self.enable_expert_tensor_parallelism = enable_expert_tensor_parallelism
179
+ self.moe_min_capacity = moe_min_capacity
180
+ self.moe_token_dropping = moe_token_dropping
181
+ self.parallel_attn_mlp_res = parallel_attn_mlp_res
182
+ if isinstance(quantization, dict):
183
+ self.quantization = ArcticQuantizationConfig(**quantization)
184
+ else:
185
+ self.quantization = quantization
186
+
187
+ super().__init__(
188
+ pad_token_id=pad_token_id,
189
+ bos_token_id=bos_token_id,
190
+ eos_token_id=eos_token_id,
191
+ tie_word_embeddings=tie_word_embeddings,
192
+ **kwargs,
193
+ )
194
+
195
+ @classmethod
196
+ def from_dict(cls, config_dict: dict[str, Any], **kwargs) -> "ArcticConfig":
197
+ result = super().from_dict(config_dict, **kwargs)
198
+ config = result[0] if isinstance(result, tuple) else result
199
+ if isinstance(config.quantization, dict):
200
+ config.quantization = ArcticQuantizationConfig(**config.quantization)
201
+ return result
202
+
203
+ def to_dict(self) -> dict[str, Any]:
204
+ ret = super().to_dict()
205
+ if isinstance(ret["quantization"], ArcticQuantizationConfig):
206
+ ret["quantization"] = asdict(ret["quantization"])
207
+ return ret
tool_server/.venv/lib/python3.12/site-packages/vllm/transformers_utils/configs/chatglm.py ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
+
4
+ # Adapted from
5
+ # https://github.com/zai-org/ChatGLM2-6B
6
+ from transformers import PretrainedConfig
7
+
8
+
9
+ class ChatGLMConfig(PretrainedConfig):
10
+ model_type = "chatglm"
11
+ attribute_map = {
12
+ "num_hidden_layers": "num_layers",
13
+ "n_head_kv": "multi_query_group_num",
14
+ }
15
+
16
+ def __init__(self,
17
+ num_layers=28,
18
+ padded_vocab_size=65024,
19
+ hidden_size=4096,
20
+ ffn_hidden_size=13696,
21
+ kv_channels=128,
22
+ num_attention_heads=32,
23
+ seq_length=2048,
24
+ hidden_dropout=0.0,
25
+ attention_dropout=0.0,
26
+ layernorm_epsilon=1e-5,
27
+ rmsnorm=True,
28
+ apply_residual_connection_post_layernorm=False,
29
+ post_layer_norm=True,
30
+ add_bias_linear=False,
31
+ add_qkv_bias=False,
32
+ interleaved_qkv=False,
33
+ bias_dropout_fusion=True,
34
+ multi_query_attention=False,
35
+ multi_query_group_num=1,
36
+ apply_query_key_layer_scaling=True,
37
+ attention_softmax_in_fp32=True,
38
+ fp32_residual_connection=False,
39
+ quantization_bit=0,
40
+ pre_seq_len=None,
41
+ prefix_projection=False,
42
+ **kwargs):
43
+ self.num_layers = num_layers
44
+ self.vocab_size = padded_vocab_size
45
+ self.padded_vocab_size = padded_vocab_size
46
+ self.hidden_size = hidden_size
47
+ self.ffn_hidden_size = ffn_hidden_size
48
+ self.kv_channels = kv_channels
49
+ self.num_attention_heads = num_attention_heads
50
+ self.seq_length = seq_length
51
+ # It is to be compatible with long lora.
52
+ self.max_position_embeddings = seq_length
53
+ self.hidden_dropout = hidden_dropout
54
+ self.attention_dropout = attention_dropout
55
+ self.layernorm_epsilon = layernorm_epsilon
56
+ self.rmsnorm = rmsnorm
57
+ self.apply_residual_connection_post_layernorm = (
58
+ apply_residual_connection_post_layernorm)
59
+ self.post_layer_norm = post_layer_norm
60
+ self.add_bias_linear = add_bias_linear
61
+ self.add_qkv_bias = add_qkv_bias
62
+ self.bias_dropout_fusion = bias_dropout_fusion
63
+ self.multi_query_attention = multi_query_attention
64
+ self.multi_query_group_num = multi_query_group_num
65
+ self.apply_query_key_layer_scaling = apply_query_key_layer_scaling
66
+ self.attention_softmax_in_fp32 = attention_softmax_in_fp32
67
+ self.fp32_residual_connection = fp32_residual_connection
68
+ self.quantization_bit = quantization_bit
69
+ self.pre_seq_len = pre_seq_len
70
+ self.prefix_projection = prefix_projection
71
+ self.interleaved_qkv = interleaved_qkv
72
+ super().__init__(**kwargs)
tool_server/.venv/lib/python3.12/site-packages/vllm/transformers_utils/configs/deepseek_vl2.py ADDED
@@ -0,0 +1,216 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
+
4
+ # adapted from https://github.com/deepseek-ai/DeepSeek-VL2/blob/faf18023f24b962b32d9f0a2d89e402a8d383a78/deepseek_vl2/models/modeling_deepseek_vl_v2.py#L115-L268
5
+
6
+ from transformers.configuration_utils import PretrainedConfig
7
+
8
+
9
+ class VisionEncoderConfig(PretrainedConfig):
10
+ model_type: str = "vision"
11
+
12
+ model_name: str = "vit_so400m_patch14_siglip_384.webli"
13
+ image_size: int = 384
14
+ patch_size: int = 16
15
+ width: int = 1024
16
+ layers: int = 24
17
+ heads: int = 16
18
+ mlp_ratio: int = 4
19
+ global_pool: str = "map"
20
+ ignore_head: bool = True
21
+ class_token: bool = False
22
+ num_classes: int = 0
23
+ use_checkpoint: bool = False
24
+ weight_init: str = "skip"
25
+ deterministic: bool = False
26
+ num_recomputing_layers: int = 0
27
+
28
+ def __init__(self,
29
+ model_name: str = "vit_so400m_patch14_siglip_384.webli",
30
+ image_size: int = 384,
31
+ patch_size: int = 16,
32
+ width: int = 1024,
33
+ layers: int = 24,
34
+ heads: int = 16,
35
+ mlp_ratio: int = 4,
36
+ global_pool: str = "map",
37
+ ignore_head: bool = True,
38
+ class_token: bool = False,
39
+ num_classes: int = 0,
40
+ use_checkpoint: bool = False,
41
+ **kwargs):
42
+ self.model_name = model_name
43
+ self.image_size = image_size
44
+ self.patch_size = patch_size
45
+ self.width = width
46
+ self.layers = layers
47
+ self.heads = heads
48
+ self.mlp_ratio = mlp_ratio
49
+ self.global_pool = global_pool
50
+ self.ignore_head = ignore_head
51
+ self.class_token = class_token
52
+ self.num_classes = num_classes
53
+ self.use_checkpoint = use_checkpoint
54
+
55
+ super().__init__(**kwargs)
56
+
57
+
58
+ class MlpProjectorConfig(PretrainedConfig):
59
+ model_type = "mlp_projector"
60
+ projector_type: str = "downsample_mlp_gelu"
61
+ input_dim: int = 1152
62
+ n_embed: int = 2048
63
+ depth: int = 2
64
+ mlp_ratio: int = 1
65
+ downsample_ratio: int = 2
66
+ token_pooling: bool = False
67
+
68
+ def __init__(self,
69
+ projector_type: str = "downsample_mlp_gelu",
70
+ input_dim: int = 1152,
71
+ n_embed: int = 2048,
72
+ depth: int = 2,
73
+ mlp_ratio: int = 1,
74
+ downsample_ratio: int = 2,
75
+ **kwargs):
76
+ self.projector_type = projector_type
77
+ self.input_dim = input_dim
78
+ self.n_embed = n_embed
79
+ self.depth = depth
80
+ self.mlp_ratio = mlp_ratio
81
+ self.downsample_ratio = downsample_ratio
82
+
83
+ super().__init__(**kwargs)
84
+
85
+
86
+ class DeepseekV2Config(PretrainedConfig):
87
+
88
+ model_type = "deepseek_v2"
89
+ keys_to_ignore_at_inference = ["past_key_values"]
90
+
91
+ def __init__(
92
+ self,
93
+ vocab_size=102400,
94
+ hidden_size=4096,
95
+ intermediate_size=11008,
96
+ moe_intermediate_size=1407,
97
+ num_hidden_layers=30,
98
+ num_attention_heads=32,
99
+ num_key_value_heads=32,
100
+ n_shared_experts=None,
101
+ n_routed_experts=None,
102
+ ep_size=1,
103
+ routed_scaling_factor=1.0,
104
+ kv_lora_rank=512,
105
+ q_lora_rank=1536,
106
+ qk_rope_head_dim=64,
107
+ v_head_dim=128,
108
+ qk_nope_head_dim=128,
109
+ topk_method='gready',
110
+ n_group=None,
111
+ topk_group=None,
112
+ num_experts_per_tok=None,
113
+ moe_layer_freq=1,
114
+ first_k_dense_replace=0,
115
+ norm_topk_prob=False,
116
+ scoring_func='softmax',
117
+ aux_loss_alpha=0.001,
118
+ seq_aux=True,
119
+ hidden_act="silu",
120
+ max_position_embeddings=2048,
121
+ initializer_range=0.02,
122
+ rms_norm_eps=1e-6,
123
+ use_cache=True,
124
+ pad_token_id=None,
125
+ bos_token_id=100000,
126
+ eos_token_id=100001,
127
+ pretraining_tp=1,
128
+ tie_word_embeddings=False,
129
+ rope_theta=10000.0,
130
+ rope_scaling=None,
131
+ attention_bias=False,
132
+ attention_dropout=0.0,
133
+ use_mla=True,
134
+ **kwargs,
135
+ ):
136
+ self.vocab_size = vocab_size
137
+ self.max_position_embeddings = max_position_embeddings
138
+ self.hidden_size = hidden_size
139
+ self.intermediate_size = intermediate_size
140
+ self.moe_intermediate_size = moe_intermediate_size
141
+ self.num_hidden_layers = num_hidden_layers
142
+ self.num_attention_heads = num_attention_heads
143
+ self.n_shared_experts = n_shared_experts
144
+ self.n_routed_experts = n_routed_experts
145
+ self.ep_size = ep_size
146
+ self.routed_scaling_factor = routed_scaling_factor
147
+ self.kv_lora_rank = kv_lora_rank
148
+ self.q_lora_rank = q_lora_rank
149
+ self.qk_rope_head_dim = qk_rope_head_dim
150
+ self.v_head_dim = v_head_dim
151
+ self.qk_nope_head_dim = qk_nope_head_dim
152
+ self.topk_method = topk_method
153
+ self.n_group = n_group
154
+ self.topk_group = topk_group
155
+ self.num_experts_per_tok = num_experts_per_tok
156
+ self.moe_layer_freq = moe_layer_freq
157
+ self.first_k_dense_replace = first_k_dense_replace
158
+ self.norm_topk_prob = norm_topk_prob
159
+ self.scoring_func = scoring_func
160
+ self.aux_loss_alpha = aux_loss_alpha
161
+ self.seq_aux = seq_aux
162
+ # for backward compatibility
163
+ if num_key_value_heads is None:
164
+ num_key_value_heads = num_attention_heads
165
+
166
+ self.num_key_value_heads = num_key_value_heads
167
+ self.hidden_act = hidden_act
168
+ self.initializer_range = initializer_range
169
+ self.rms_norm_eps = float(rms_norm_eps)
170
+ self.pretraining_tp = pretraining_tp
171
+ self.use_cache = use_cache
172
+ self.rope_theta = rope_theta
173
+ self.rope_scaling = rope_scaling
174
+ self.attention_bias = attention_bias
175
+ self.attention_dropout = attention_dropout
176
+ self.use_mla = use_mla
177
+
178
+ super().__init__(
179
+ pad_token_id=pad_token_id,
180
+ bos_token_id=bos_token_id,
181
+ eos_token_id=eos_token_id,
182
+ tie_word_embeddings=tie_word_embeddings,
183
+ **kwargs,
184
+ )
185
+
186
+
187
+ class DeepseekVLV2Config(PretrainedConfig):
188
+ model_type = "deepseek_vl_v2"
189
+ vision_config: VisionEncoderConfig
190
+ projector_config: MlpProjectorConfig
191
+
192
+ tile_tag: str = "2D"
193
+ global_view_pos: str = "head"
194
+ candidate_resolutions: tuple[tuple[int, int]] = ((384, 384), )
195
+
196
+ def __init__(self,
197
+ tile_tag: str = "tile_tag",
198
+ global_view_pos: str = "head",
199
+ candidate_resolutions: tuple[tuple[int,
200
+ int]] = ((384, 384), ),
201
+ **kwargs):
202
+ super().__init__(**kwargs)
203
+
204
+ vision_config = kwargs.get("vision_config", {})
205
+ self.vision_config = VisionEncoderConfig(**vision_config)
206
+
207
+ projector_config = kwargs.get("projector_config", {})
208
+ self.projector_config = MlpProjectorConfig(**projector_config)
209
+
210
+ language_config = kwargs.get("language_config", {})
211
+ self.text_config = DeepseekV2Config(**language_config)
212
+
213
+ self.tile_tag = tile_tag
214
+ self.global_view_pos = global_view_pos
215
+ self.candidate_resolutions = candidate_resolutions
216
+ self.vocab_size = self.text_config.vocab_size
tool_server/.venv/lib/python3.12/site-packages/vllm/transformers_utils/configs/eagle.py ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
+
4
+ import os
5
+ from typing import Optional, Union
6
+
7
+ from transformers import AutoConfig, PretrainedConfig
8
+
9
+ from vllm.transformers_utils.configs.deepseek_vl2 import DeepseekV2Config
10
+
11
+
12
+ class EAGLEConfig(PretrainedConfig):
13
+ model_type = "eagle"
14
+
15
+ def __init__(self,
16
+ model: Union[PretrainedConfig, dict, None] = None,
17
+ truncated_vocab_size: Optional[int] = None,
18
+ method: Optional[str] = 'eagle',
19
+ **kwargs):
20
+
21
+ model_config: Union[PretrainedConfig, DeepseekV2Config, None]
22
+ if isinstance(model, dict):
23
+ archs = model.get("architectures", [])
24
+ target_archs = ["DeepseekV2ForCausalLM", "DeepseekV3ForCausalLM"]
25
+ if any(target_arch in archs for target_arch in target_archs):
26
+ # AutoConfig does not support DeepSeek MoE models yet
27
+ model_config = DeepseekV2Config(**model)
28
+ else:
29
+ model_config = AutoConfig.for_model(**model)
30
+ else:
31
+ model_config = model
32
+
33
+ for k, v in kwargs.items():
34
+ if k != "architectures" and k != "model_type" and hasattr(
35
+ model_config, k):
36
+ setattr(model_config, k, v)
37
+
38
+ self.model = model_config
39
+
40
+ if self.model is None:
41
+ self.truncated_vocab_size = None
42
+ else:
43
+ self.truncated_vocab_size = self.model.vocab_size if \
44
+ truncated_vocab_size is None else truncated_vocab_size
45
+
46
+ # Eagle model name should follow naming convention of
47
+ # LlamaForCausalLM -> EagleLlamaForCausalLM
48
+ # LlamaForCausalLM -> Eagle3LlamaForCausalLM
49
+ if method == "eagle":
50
+ assert self.model is not None, \
51
+ "model should not be None when method is eagle"
52
+ kwargs["architectures"] = [
53
+ f"Eagle{arch}" if not arch.startswith("Eagle") \
54
+ else arch for arch in self.model.architectures
55
+ ]
56
+ elif method == "eagle3":
57
+ assert self.model is not None, \
58
+ "model should not be None when method is eagle3"
59
+ kwargs["architectures"] = [
60
+ arch if arch.startswith("Eagle3") or arch.endswith("Eagle3")
61
+ else f"Eagle3{arch}" for arch in self.model.architectures
62
+ ]
63
+ else:
64
+ raise ValueError(f"Invalid method {method}. \
65
+ Supported methods are eagle and eagle3.")
66
+
67
+ super().__init__(**kwargs)
68
+
69
+ if self.model is not None:
70
+ for k, v in self.model.to_dict().items():
71
+ if k not in kwargs:
72
+ setattr(self, k, v)
73
+
74
+ @classmethod
75
+ def from_pretrained(
76
+ cls,
77
+ pretrained_model_name_or_path: Union[str, os.PathLike],
78
+ **kwargs,
79
+ ) -> "EAGLEConfig":
80
+ config_dict, kwargs = cls.get_config_dict(
81
+ pretrained_model_name_or_path, **kwargs)
82
+ return cls.from_dict(config_dict, **kwargs)
tool_server/.venv/lib/python3.12/site-packages/vllm/transformers_utils/configs/falcon.py ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
+
4
+ # Adapted from
5
+ # https://huggingface.co/tiiuae/falcon-7b/blob/main/configuration_RW.py
6
+ # Copyright 2023 The vLLM team.
7
+ # Copyright 2022 the Big Science Workshop and HuggingFace Inc. team.
8
+ # All rights reserved.
9
+ #
10
+ # Licensed under the Apache License, Version 2.0 (the "License");
11
+ # you may not use this file except in compliance with the License.
12
+ # You may obtain a copy of the License at
13
+ #
14
+ # http://www.apache.org/licenses/LICENSE-2.0
15
+ #
16
+ # Unless required by applicable law or agreed to in writing, software
17
+ # distributed under the License is distributed on an "AS IS" BASIS,
18
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ # See the License for the specific language governing permissions and
20
+ # limitations under the License.
21
+ """Falcon configuration"""
22
+ from transformers.configuration_utils import PretrainedConfig
23
+
24
+
25
+ class RWConfig(PretrainedConfig):
26
+ model_type = "falcon"
27
+ keys_to_ignore_at_inference = ["past_key_values"]
28
+ attribute_map = {
29
+ "num_hidden_layers": "n_layer",
30
+ "num_attention_heads": "n_head",
31
+ "num_kv_heads": "n_head_kv",
32
+ }
33
+
34
+ def __init__(
35
+ self,
36
+ vocab_size=250880,
37
+ hidden_size=64,
38
+ n_layer=2,
39
+ n_head=8,
40
+ layer_norm_epsilon=1e-5,
41
+ initializer_range=0.02,
42
+ use_cache=True,
43
+ bos_token_id=1,
44
+ eos_token_id=2,
45
+ hidden_dropout=0.0,
46
+ attention_dropout=0.0,
47
+ multi_query=True,
48
+ n_head_kv=None,
49
+ alibi=False,
50
+ bias=False,
51
+ parallel_attn=False,
52
+ new_decoder_architecture=False,
53
+ **kwargs,
54
+ ) -> None:
55
+ self.vocab_size = vocab_size
56
+ # Backward compatibility with n_embed kwarg
57
+ n_embed = kwargs.pop("n_embed", None)
58
+ self.hidden_size = hidden_size if n_embed is None else n_embed
59
+ self.n_layer = n_layer
60
+ self.n_head = n_head
61
+ self.layer_norm_epsilon = layer_norm_epsilon
62
+ self.initializer_range = initializer_range
63
+ self.use_cache = use_cache
64
+ self.hidden_dropout = hidden_dropout
65
+ self.attention_dropout = attention_dropout
66
+
67
+ self.bos_token_id = bos_token_id
68
+ self.eos_token_id = eos_token_id
69
+ self.multi_query = multi_query
70
+ self.n_head_kv = 1 if n_head_kv is None else n_head_kv
71
+ self.alibi = alibi
72
+ self.bias = bias
73
+ self.parallel_attn = parallel_attn
74
+ self.new_decoder_architecture = new_decoder_architecture
75
+
76
+ if self.hidden_size == 8192:
77
+ # Hack for falcon-40b
78
+ self.new_decoder_architecture = True
79
+
80
+ super().__init__(bos_token_id=bos_token_id,
81
+ eos_token_id=eos_token_id,
82
+ **kwargs)
83
+
84
+ @property
85
+ def head_dim(self):
86
+ return self.hidden_size // self.n_head
87
+
88
+ @property
89
+ def rotary(self):
90
+ return not self.alibi
tool_server/.venv/lib/python3.12/site-packages/vllm/transformers_utils/configs/jais.py ADDED
@@ -0,0 +1,238 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
+
4
+ # Copyright 2023 The OpenAI Team Authors and HuggingFace Inc. team.
5
+ # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
6
+ # Copyright 2023 Cerebras Systems.
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License");
9
+ # you may not use this file except in compliance with the License.
10
+ # You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+ """JAIS configuration"""
20
+
21
+ from transformers.configuration_utils import PretrainedConfig
22
+ from transformers.utils import logging
23
+
24
+ logger = logging.get_logger(__name__)
25
+
26
+
27
+ class JAISConfig(PretrainedConfig):
28
+ """
29
+ This is the configuration class to store the configuration of a
30
+ [`JAISModel`]. It is used to instantiate a JAIS model according to the
31
+ specified arguments, defining the model architecture.
32
+
33
+ Configuration objects inherit from [`PretrainedConfig`] and can be used
34
+ to control the model outputs. Read the documentation from
35
+ [`PretrainedConfig`] for more information.
36
+
37
+
38
+ Args:
39
+ vocab_size (`int`, *optional*, defaults to 50257):
40
+ Vocabulary size of the JAIS model. Defines the number of different
41
+ tokens that can be represented by the
42
+ `inputs_ids` passed when calling [`JAISModel`].
43
+ n_positions (`int`, *optional*, defaults to 1024):
44
+ The maximum sequence length that this model might ever be used
45
+ with. Typically set this to something large just in case
46
+ (e.g., 512 or 1024 or 2048).
47
+ n_embd (`int`, *optional*, defaults to 768):
48
+ Dimensionality of the embeddings and hidden states.
49
+ n_layer (`int`, *optional*, defaults to 12):
50
+ Number of hidden layers in the Transformer encoder.
51
+ n_head (`int`, *optional*, defaults to 12):
52
+ Number of attention heads for each attention layer in the
53
+ Transformer encoder.
54
+ n_inner (`int`, *optional*, defaults to None):
55
+ Dimensionality of the inner feed-forward layers. `None` will set
56
+ it to 4 times n_embd
57
+ activation_function (`str`, *optional*, defaults to `"gelu"`):
58
+ Activation function, to be selected in the list
59
+ `["relu", "silu", "gelu", "tanh", "gelu_new", "swiglu"]`.
60
+ resid_pdrop (`float`, *optional*, defaults to 0.1):
61
+ The dropout probability for all fully connected layers in
62
+ the embeddings, encoder, and pooler.
63
+ embd_pdrop (`float`, *optional*, defaults to 0.1):
64
+ The dropout ratio for the embeddings.
65
+ attn_pdrop (`float`, *optional*, defaults to 0.1):
66
+ The dropout ratio for the attention.
67
+ layer_norm_epsilon (`float`, *optional*, defaults to 1e-5):
68
+ The epsilon to use in the layer normalization layers.
69
+ initializer_range (`float`, *optional*, defaults to 0.02):
70
+ The standard deviation of the truncated_normal_initializer for
71
+ initializing all weight matrices.
72
+ scale_attn_weights (`bool`, *optional*, defaults to `True`):
73
+ Scale attention weights by dividing by sqrt(hidden_size)..
74
+ use_cache (`bool`, *optional*, defaults to `True`):
75
+ Whether or not the model should return the last key/values
76
+ attentions (not used by all models).
77
+ scale_attn_by_inverse_layer_idx (`bool`, *optional*,
78
+ defaults to `False`):
79
+ Whether to additionally scale attention weights by
80
+ `1 / layer_idx + 1`.
81
+ reorder_and_upcast_attn (`bool`, *optional*, defaults to `False`):
82
+ Whether to scale keys (K) prior to computing attention
83
+ (dot-product)
84
+ and upcast attention dot-product/softmax to float() when training
85
+ with mixed precision.
86
+ position_embedding_type (`str`, *optional*, defaults to `"learned"`):
87
+ Positional embedding can be either `"alibi"` or `"learned"`.
88
+ mup_width_scale (`float`, *optional*, defaults to 1.0):
89
+ muP parameter to scale learning rate and initializers. Calculated
90
+ as (`d_model,0 / d_model`), where
91
+ `d_model` is the model's width and `d_model,0` is the proxy
92
+ model's width.
93
+ mup_embeddings_scale (`float`, *optional*, defaults to 1.0):
94
+ muP parameter to scale token and position embeddings.
95
+ mup_output_alpha (`float`, *optional*, defaults to 1.0):
96
+ muP parameter to scale output logits
97
+ (`output_logits_scale = mup_output_alpha * mup_width_scale`).
98
+ mup_scale_qk_dot_by_d (`bool`, *optional*, defaults to `False`):
99
+ Scale attention weights by dividing by hidden_size instead of
100
+ sqrt(hidden_size). Need to set scale_attn_weights to `True` as
101
+ well.
102
+ alibi_scaling (`dict`, *optional*):
103
+ Dictionary containing the scaling configuration for ALiBi
104
+ embeddings. Currently only supports linear
105
+ scaling strategy. Can specify either the scaling `factor` (must be
106
+ a float greater than 1) for fixed scaling
107
+ or `train_seq_len` for dynamic scaling on input samples with
108
+ sequence length > `train_seq_len`. The expected
109
+ formats are `{"type": strategy name, "factor": scaling factor}` or
110
+ `{"type": strategy name,
111
+ "train_seq_len": training sequence length}`.
112
+ architectures (`list`, *optional*, defaults to ['JAISLMHeadModel']):
113
+ architecture names for Jais.
114
+
115
+ Example:
116
+
117
+ ```python
118
+ >>> from transformers import JAISConfig, JAISModel
119
+
120
+ >>> # Initializing a JAIS configuration
121
+ >>> configuration = JAISConfig()
122
+
123
+ >>> # Initializing a model (with random weights) from the configuration
124
+ >>> model = JAISModel(configuration)
125
+
126
+ >>> # Accessing the model configuration
127
+ >>> configuration = model.config
128
+ ```"""
129
+
130
+ model_type = "jais"
131
+ keys_to_ignore_at_inference = ["past_key_values"]
132
+ attribute_map = {
133
+ "hidden_size": "n_embd",
134
+ "max_position_embeddings": "n_positions",
135
+ "num_attention_heads": "n_head",
136
+ "num_hidden_layers": "n_layer",
137
+ }
138
+
139
+ def __init__(
140
+ self,
141
+ vocab_size=50257,
142
+ n_positions=1024,
143
+ n_embd=768,
144
+ n_layer=12,
145
+ n_head=12,
146
+ n_inner=None,
147
+ activation_function="gelu_new",
148
+ resid_pdrop=0.1,
149
+ embd_pdrop=0.1,
150
+ attn_pdrop=0.1,
151
+ layer_norm_epsilon=1e-5,
152
+ initializer_range=0.02,
153
+ scale_attn_weights=True,
154
+ use_cache=True,
155
+ bos_token_id=50256,
156
+ eos_token_id=50256,
157
+ scale_attn_by_inverse_layer_idx=False,
158
+ reorder_and_upcast_attn=False,
159
+ position_embedding_type="learned",
160
+ mup_width_scale=1.0,
161
+ mup_embeddings_scale=1.0,
162
+ mup_output_alpha=1.0,
163
+ mup_scale_qk_dot_by_d=False,
164
+ alibi_scaling=None,
165
+ architectures=None,
166
+ **kwargs,
167
+ ):
168
+ self.vocab_size = vocab_size
169
+ self.n_positions = n_positions
170
+ self.n_embd = n_embd
171
+ self.n_layer = n_layer
172
+ self.n_head = n_head
173
+ self.n_inner = n_inner
174
+ self.activation_function = activation_function
175
+ self.resid_pdrop = resid_pdrop
176
+ self.embd_pdrop = embd_pdrop
177
+ self.attn_pdrop = attn_pdrop
178
+ self.layer_norm_epsilon = layer_norm_epsilon
179
+ self.initializer_range = initializer_range
180
+ self.scale_attn_weights = scale_attn_weights
181
+ self.use_cache = use_cache
182
+ self.scale_attn_by_inverse_layer_idx = scale_attn_by_inverse_layer_idx
183
+ self.reorder_and_upcast_attn = reorder_and_upcast_attn
184
+
185
+ self.bos_token_id = bos_token_id
186
+ self.eos_token_id = eos_token_id
187
+
188
+ self.position_embedding_type = position_embedding_type
189
+ self.mup_width_scale = mup_width_scale
190
+ self.mup_embeddings_scale = mup_embeddings_scale
191
+ self.mup_output_alpha = mup_output_alpha
192
+ self.mup_scale_qk_dot_by_d = mup_scale_qk_dot_by_d
193
+
194
+ self.alibi_scaling = alibi_scaling
195
+ self._alibi_scaling_validation()
196
+ if architectures is None:
197
+ architectures = ["JAISLMHeadModel"]
198
+
199
+ super().__init__(
200
+ bos_token_id=bos_token_id,
201
+ eos_token_id=eos_token_id,
202
+ architectures=architectures,
203
+ **kwargs,
204
+ )
205
+
206
+ def _alibi_scaling_validation(self):
207
+ """
208
+ Validate the `alibi_scaling` configuration.
209
+ """
210
+ if self.alibi_scaling is None:
211
+ return
212
+
213
+ if (not isinstance(self.alibi_scaling, dict)
214
+ or len(self.alibi_scaling) != 2):
215
+ raise ValueError(
216
+ "`alibi_scaling` must be a dictionary with two fields, "
217
+ "`type` and `factor` or `type` and `train_seq_len`, "
218
+ f"got {self.alibi_scaling}")
219
+ alibi_scaling_type = self.alibi_scaling.get("type", None)
220
+ alibi_scaling_factor = self.alibi_scaling.get("factor", None)
221
+ alibi_dynamic_scaling = self.alibi_scaling.get("train_seq_len", None)
222
+ if alibi_scaling_type is None or alibi_scaling_type != "linear":
223
+ raise ValueError(f"`alibi_scaling`'s type field must be 'linear', "
224
+ f"got {alibi_scaling_type}")
225
+ if (alibi_scaling_factor is not None
226
+ and not isinstance(alibi_scaling_factor, float)
227
+ or (alibi_scaling_factor is not None
228
+ and alibi_scaling_factor <= 1.0)):
229
+ raise ValueError(
230
+ f"`alibi_scaling`'s factor field must be a float > 1.0, "
231
+ f"got {alibi_scaling_factor}")
232
+ if (alibi_dynamic_scaling is not None
233
+ and not isinstance(alibi_dynamic_scaling, int)
234
+ or (alibi_dynamic_scaling is not None
235
+ and alibi_dynamic_scaling <= 1)):
236
+ raise ValueError(
237
+ f"`alibi_scaling`'s `train_seq_len` field must be an "
238
+ f"integer > 1, got {alibi_dynamic_scaling}")
tool_server/.venv/lib/python3.12/site-packages/vllm/transformers_utils/configs/kimi_vl.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
+ # Adapted from https://huggingface.co/moonshotai/Kimi-VL-A3B-Instruct/blob/main/configuration_kimi_vl.py
4
+ from typing import Optional, Union
5
+
6
+ from transformers.configuration_utils import PretrainedConfig
7
+
8
+ from vllm.transformers_utils.configs.deepseek_vl2 import DeepseekV2Config
9
+ from vllm.transformers_utils.configs.moonvit import MoonViTConfig
10
+
11
+
12
+ class KimiVLConfig(PretrainedConfig):
13
+ model_type = "kimi_vl"
14
+
15
+ def __init__(self,
16
+ vision_config: Optional[Union[dict, MoonViTConfig]] = None,
17
+ text_config: Optional[Union[dict, DeepseekV2Config]] = None,
18
+ ignore_index: int = -100,
19
+ media_placeholder_token_id: int = 163605,
20
+ pad_token_id: int = 0,
21
+ **kwargs):
22
+ if vision_config is None:
23
+ vision_config = MoonViTConfig()
24
+ elif isinstance(vision_config, dict):
25
+ vision_config = MoonViTConfig(**vision_config)
26
+ self.vision_config = vision_config
27
+
28
+ if text_config is None:
29
+ text_config = DeepseekV2Config()
30
+ elif isinstance(text_config, dict):
31
+ text_config = DeepseekV2Config(**text_config)
32
+ self.text_config = text_config
33
+
34
+ self.ignore_index = ignore_index
35
+ self.media_placeholder_token_id = media_placeholder_token_id
36
+
37
+ super().__init__(pad_token_id=pad_token_id, **kwargs)
tool_server/.venv/lib/python3.12/site-packages/vllm/transformers_utils/configs/medusa.py ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
+
4
+ import os
5
+ from typing import Optional, Union
6
+
7
+ from transformers import PretrainedConfig
8
+
9
+
10
+ class MedusaConfig(PretrainedConfig):
11
+ model_type = "medusa"
12
+
13
+ def __init__(self,
14
+ hidden_size: int = 4096,
15
+ vocab_size: int = 32001,
16
+ num_heads: int = 5,
17
+ num_hidden_layers: int = 1,
18
+ max_paths: int = 64,
19
+ topk: int = 10,
20
+ truncated_vocab_size: Optional[int] = None,
21
+ **kwargs):
22
+
23
+ self.hidden_size = hidden_size
24
+ self.vocab_size = vocab_size
25
+ self.num_heads = num_heads
26
+ self.num_hidden_layers = num_hidden_layers
27
+ self.max_paths = max_paths
28
+ self.topk = topk
29
+ self.max_seq_len = int(2**20)
30
+ self.truncated_vocab_size = vocab_size if truncated_vocab_size is None\
31
+ else truncated_vocab_size
32
+ if "architectures" not in kwargs:
33
+ kwargs["architectures"] = ["MedusaModel"]
34
+
35
+ super().__init__(**kwargs)
36
+
37
+ @classmethod
38
+ def from_pretrained(
39
+ cls,
40
+ pretrained_model_name_or_path: Union[str, os.PathLike],
41
+ **kwargs,
42
+ ) -> "MedusaConfig":
43
+ config_dict, kwargs = cls.get_config_dict(
44
+ pretrained_model_name_or_path, **kwargs)
45
+ for k in list(config_dict.keys()):
46
+ if 'num' in k:
47
+ if 'heads' in k:
48
+ config_dict["num_heads"] = config_dict.pop(k)
49
+ elif 'layers' in k:
50
+ config_dict["num_hidden_layers"] = config_dict.pop(k)
51
+ return cls.from_dict(config_dict, **kwargs)
52
+
53
+ @property
54
+ def num_attention_heads(self):
55
+ return 0
56
+
57
+ @property
58
+ def num_lookahead_tokens(self):
59
+ return self.num_heads
60
+
61
+ @num_lookahead_tokens.setter
62
+ def num_lookahead_tokens(self, num_lookahead_tokens: int):
63
+ self.num_heads = num_lookahead_tokens