sglang 0.2.6__py3-none-any.whl → 0.2.8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sglang/__init__.py +33 -26
- sglang/api.py +9 -1
- sglang/bench_latency.py +2 -2
- sglang/bench_serving.py +10 -1
- sglang/check_env.py +1 -1
- sglang/lang/backend/litellm.py +1 -1
- sglang/lang/backend/openai.py +1 -1
- sglang/lang/interpreter.py +21 -5
- sglang/lang/ir.py +1 -2
- sglang/srt/constrained/__init__.py +15 -0
- sglang/srt/constrained/{base_cache.py → base_tool_cache.py} +17 -2
- sglang/srt/constrained/fsm_cache.py +17 -2
- sglang/srt/constrained/jump_forward.py +17 -2
- sglang/srt/conversation.py +26 -0
- sglang/srt/hf_transformers_utils.py +15 -0
- sglang/srt/layers/context_flashattention_nopad.py +15 -0
- sglang/srt/layers/extend_attention.py +15 -0
- sglang/srt/layers/fused_moe.py +15 -0
- sglang/srt/layers/linear.py +15 -0
- sglang/srt/layers/logits_processor.py +41 -13
- sglang/srt/layers/quantization/__init__.py +15 -0
- sglang/srt/layers/quantization/fp8.py +15 -0
- sglang/srt/layers/radix_attention.py +17 -2
- sglang/srt/layers/token_attention.py +16 -1
- sglang/srt/managers/{controller/manager_multi.py → controller_multi.py} +17 -2
- sglang/srt/managers/{controller/manager_single.py → controller_single.py} +17 -2
- sglang/srt/managers/detokenizer_manager.py +16 -1
- sglang/srt/managers/io_struct.py +36 -3
- sglang/srt/managers/{controller/schedule_heuristic.py → policy_scheduler.py} +37 -22
- sglang/srt/managers/{controller/infer_batch.py → schedule_batch.py} +60 -21
- sglang/srt/managers/tokenizer_manager.py +39 -16
- sglang/srt/managers/{controller/tp_worker.py → tp_worker.py} +159 -46
- sglang/srt/mem_cache/base_cache.py +43 -0
- sglang/srt/mem_cache/chunk_cache.py +60 -0
- sglang/srt/mem_cache/flush_cache.py +33 -0
- sglang/srt/{memory_pool.py → mem_cache/memory_pool.py} +16 -1
- sglang/srt/{managers/controller → mem_cache}/radix_cache.py +20 -2
- sglang/srt/mm_utils.py +15 -0
- sglang/srt/model_config.py +15 -0
- sglang/srt/{managers/controller → model_executor}/cuda_graph_runner.py +16 -1
- sglang/srt/{managers/controller → model_executor}/model_runner.py +49 -14
- sglang/srt/model_loader/model_loader.py +15 -0
- sglang/srt/model_loader/utils.py +16 -1
- sglang/srt/models/chatglm.py +16 -1
- sglang/srt/models/commandr.py +16 -1
- sglang/srt/models/dbrx.py +16 -1
- sglang/srt/models/deepseek.py +16 -1
- sglang/srt/models/deepseek_v2.py +16 -1
- sglang/srt/models/gemma.py +16 -1
- sglang/srt/models/gemma2.py +16 -1
- sglang/srt/models/gpt_bigcode.py +16 -1
- sglang/srt/models/grok.py +16 -1
- sglang/srt/models/internlm2.py +16 -1
- sglang/srt/models/llama2.py +21 -22
- sglang/srt/models/llama_classification.py +16 -1
- sglang/srt/models/llava.py +17 -2
- sglang/srt/models/llavavid.py +17 -2
- sglang/srt/models/minicpm.py +16 -1
- sglang/srt/models/mistral.py +15 -0
- sglang/srt/models/mixtral.py +16 -1
- sglang/srt/models/mixtral_quant.py +16 -1
- sglang/srt/models/qwen.py +16 -1
- sglang/srt/models/qwen2.py +16 -1
- sglang/srt/models/qwen2_moe.py +16 -1
- sglang/srt/models/stablelm.py +16 -1
- sglang/srt/models/yivl.py +15 -0
- sglang/srt/openai_api/adapter.py +569 -131
- sglang/srt/openai_api/protocol.py +84 -2
- sglang/srt/sampling_params.py +15 -0
- sglang/srt/server.py +92 -23
- sglang/srt/server_args.py +52 -11
- sglang/srt/utils.py +15 -0
- sglang/test/test_programs.py +9 -6
- sglang/utils.py +22 -0
- sglang/version.py +1 -1
- {sglang-0.2.6.dist-info → sglang-0.2.8.dist-info}/METADATA +33 -7
- sglang-0.2.8.dist-info/RECORD +95 -0
- {sglang-0.2.6.dist-info → sglang-0.2.8.dist-info}/WHEEL +1 -1
- sglang/srt/flush_cache.py +0 -18
- sglang-0.2.6.dist-info/RECORD +0 -93
- {sglang-0.2.6.dist-info → sglang-0.2.8.dist-info}/LICENSE +0 -0
- {sglang-0.2.6.dist-info → sglang-0.2.8.dist-info}/top_level.txt +0 -0
@@ -1,9 +1,25 @@
|
|
1
|
+
"""
|
2
|
+
Copyright 2023-2024 SGLang Team
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
14
|
+
"""
|
15
|
+
|
1
16
|
"""ModelRunner runs the forward passes of the models."""
|
2
17
|
|
3
18
|
import importlib
|
4
19
|
import importlib.resources
|
5
20
|
import logging
|
6
21
|
import pkgutil
|
22
|
+
import warnings
|
7
23
|
from functools import lru_cache
|
8
24
|
from typing import Optional, Type
|
9
25
|
|
@@ -25,13 +41,13 @@ from vllm.distributed import (
|
|
25
41
|
from vllm.model_executor.models import ModelRegistry
|
26
42
|
|
27
43
|
from sglang.global_config import global_config
|
28
|
-
from sglang.srt.managers.
|
44
|
+
from sglang.srt.managers.schedule_batch import (
|
29
45
|
Batch,
|
30
46
|
ForwardMode,
|
31
47
|
InputMetadata,
|
32
48
|
global_server_args_dict,
|
33
49
|
)
|
34
|
-
from sglang.srt.memory_pool import ReqToTokenPool, TokenToKVPool
|
50
|
+
from sglang.srt.mem_cache.memory_pool import ReqToTokenPool, TokenToKVPool
|
35
51
|
from sglang.srt.server_args import ServerArgs
|
36
52
|
from sglang.srt.utils import (
|
37
53
|
get_available_gpu_memory,
|
@@ -42,7 +58,7 @@ from sglang.srt.utils import (
|
|
42
58
|
monkey_patch_vllm_qvk_linear_loader,
|
43
59
|
)
|
44
60
|
|
45
|
-
logger = logging.getLogger(
|
61
|
+
logger = logging.getLogger(__name__)
|
46
62
|
|
47
63
|
|
48
64
|
class ModelRunner:
|
@@ -75,7 +91,7 @@ class ModelRunner:
|
|
75
91
|
|
76
92
|
# Init torch distributed
|
77
93
|
torch.cuda.set_device(self.gpu_id)
|
78
|
-
logger.info(f"[
|
94
|
+
logger.info(f"[gpu={self.gpu_id}] Init nccl begin.")
|
79
95
|
|
80
96
|
if not server_args.enable_p2p_check:
|
81
97
|
monkey_patch_vllm_p2p_access_check(self.gpu_id)
|
@@ -106,7 +122,11 @@ class ModelRunner:
|
|
106
122
|
|
107
123
|
# Load the model and create memory pool
|
108
124
|
self.load_model()
|
109
|
-
self.init_memory_pool(
|
125
|
+
self.init_memory_pool(
|
126
|
+
total_gpu_memory,
|
127
|
+
server_args.max_num_reqs,
|
128
|
+
server_args.max_total_tokens,
|
129
|
+
)
|
110
130
|
self.init_cublas()
|
111
131
|
self.init_flash_infer()
|
112
132
|
|
@@ -115,7 +135,7 @@ class ModelRunner:
|
|
115
135
|
|
116
136
|
def load_model(self):
|
117
137
|
logger.info(
|
118
|
-
f"[
|
138
|
+
f"[gpu={self.gpu_id}] Load weight begin. "
|
119
139
|
f"avail mem={get_available_gpu_memory(self.gpu_id):.2f} GB"
|
120
140
|
)
|
121
141
|
|
@@ -163,7 +183,7 @@ class ModelRunner:
|
|
163
183
|
cache_config=None,
|
164
184
|
)
|
165
185
|
logger.info(
|
166
|
-
f"[
|
186
|
+
f"[gpu={self.gpu_id}] Load weight end. "
|
167
187
|
f"type={type(self.model).__name__}, "
|
168
188
|
f"dtype={self.dtype}, "
|
169
189
|
f"avail mem={get_available_gpu_memory(self.gpu_id):.2f} GB"
|
@@ -188,8 +208,18 @@ class ModelRunner:
|
|
188
208
|
max_num_token = int(rest_memory * (1 << 30) // cell_size)
|
189
209
|
return max_num_token
|
190
210
|
|
191
|
-
def init_memory_pool(
|
211
|
+
def init_memory_pool(
|
212
|
+
self, total_gpu_memory, max_num_reqs=None, max_total_tokens=None
|
213
|
+
):
|
192
214
|
self.max_total_num_tokens = self.profile_max_num_token(total_gpu_memory)
|
215
|
+
if max_total_tokens is not None:
|
216
|
+
if max_total_tokens > self.max_total_num_tokens:
|
217
|
+
warnings.warn(
|
218
|
+
f"max_total_tokens={max_total_tokens} is larger than the profiled value "
|
219
|
+
f"{self.max_total_num_tokens}. "
|
220
|
+
f"Use the profiled value instead."
|
221
|
+
)
|
222
|
+
self.max_total_num_tokens = min(self.max_total_num_tokens, max_total_tokens)
|
193
223
|
|
194
224
|
if self.max_total_num_tokens <= 0:
|
195
225
|
raise RuntimeError(
|
@@ -197,9 +227,14 @@ class ModelRunner:
|
|
197
227
|
)
|
198
228
|
|
199
229
|
if max_num_reqs is None:
|
200
|
-
max_num_reqs =
|
201
|
-
|
202
|
-
|
230
|
+
max_num_reqs = min(
|
231
|
+
max(
|
232
|
+
int(
|
233
|
+
self.max_total_num_tokens / self.model_config.context_len * 512
|
234
|
+
),
|
235
|
+
2048,
|
236
|
+
),
|
237
|
+
5120,
|
203
238
|
)
|
204
239
|
|
205
240
|
self.req_to_token_pool = ReqToTokenPool(
|
@@ -214,7 +249,7 @@ class ModelRunner:
|
|
214
249
|
layer_num=self.model_config.num_hidden_layers,
|
215
250
|
)
|
216
251
|
logger.info(
|
217
|
-
f"[
|
252
|
+
f"[gpu={self.gpu_id}] Memory pool end. "
|
218
253
|
f"avail mem={get_available_gpu_memory(self.gpu_id):.2f} GB"
|
219
254
|
)
|
220
255
|
|
@@ -258,14 +293,14 @@ class ModelRunner:
|
|
258
293
|
)
|
259
294
|
|
260
295
|
def init_cuda_graphs(self):
|
261
|
-
from sglang.srt.
|
296
|
+
from sglang.srt.model_executor.cuda_graph_runner import CudaGraphRunner
|
262
297
|
|
263
298
|
if self.server_args.disable_cuda_graph or self.server_args.disable_flashinfer:
|
264
299
|
self.cuda_graph_runner = None
|
265
300
|
return
|
266
301
|
|
267
302
|
logger.info(
|
268
|
-
f"[
|
303
|
+
f"[gpu={self.gpu_id}] Capture cuda graph begin. This can take up to several minutes."
|
269
304
|
)
|
270
305
|
batch_size_list = [1, 2, 4] + [i * 8 for i in range(1, 17)]
|
271
306
|
self.cuda_graph_runner = CudaGraphRunner(
|
@@ -1,3 +1,18 @@
|
|
1
|
+
"""
|
2
|
+
Copyright 2023-2024 SGLang Team
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
14
|
+
"""
|
15
|
+
|
1
16
|
# temporarily adapted from https://github.com/vllm-project/vllm/blob/10383887e03412196a2689b9398290719c4797bf/vllm/model_executor/model_loader/loader.py
|
2
17
|
# FIXME: in progress of refactoring the model loader
|
3
18
|
|
sglang/srt/model_loader/utils.py
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
"""
|
2
|
+
Copyright 2023-2024 SGLang Team
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
14
|
+
"""
|
15
|
+
|
1
16
|
# temporarily adapted from vLLM
|
2
17
|
# FIXME: in progress of refactoring the model loader
|
3
18
|
"""Utilities for selecting and loading models."""
|
@@ -23,7 +38,7 @@ from vllm.model_executor.layers.quantization.base_config import QuantizationConf
|
|
23
38
|
|
24
39
|
from sglang.srt.layers.quantization import get_quantization_config
|
25
40
|
|
26
|
-
logger = logging.getLogger(
|
41
|
+
logger = logging.getLogger(__name__)
|
27
42
|
temp_dir = tempfile.gettempdir()
|
28
43
|
|
29
44
|
|
sglang/srt/models/chatglm.py
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
"""
|
2
|
+
Copyright 2023-2024 SGLang Team
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
14
|
+
"""
|
15
|
+
|
1
16
|
# coding=utf-8
|
2
17
|
# Adapted from
|
3
18
|
# https://github.com/THUDM/ChatGLM2-6B
|
@@ -30,7 +45,7 @@ from vllm.transformers_utils.configs import ChatGLMConfig
|
|
30
45
|
|
31
46
|
from sglang.srt.layers.logits_processor import LogitsProcessor
|
32
47
|
from sglang.srt.layers.radix_attention import RadixAttention
|
33
|
-
from sglang.srt.
|
48
|
+
from sglang.srt.model_executor.model_runner import InputMetadata
|
34
49
|
|
35
50
|
LoraConfig = None
|
36
51
|
|
sglang/srt/models/commandr.py
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
"""
|
2
|
+
Copyright 2023-2024 SGLang Team
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
14
|
+
"""
|
15
|
+
|
1
16
|
# coding=utf-8
|
2
17
|
# Copyright 2024 Cohere and the HuggingFace Inc. team. All rights reserved.
|
3
18
|
#
|
@@ -49,7 +64,7 @@ from vllm.model_executor.utils import set_weight_attrs
|
|
49
64
|
|
50
65
|
from sglang.srt.layers.logits_processor import LogitsProcessor
|
51
66
|
from sglang.srt.layers.radix_attention import RadixAttention
|
52
|
-
from sglang.srt.
|
67
|
+
from sglang.srt.model_executor.model_runner import InputMetadata
|
53
68
|
|
54
69
|
|
55
70
|
@torch.compile
|
sglang/srt/models/dbrx.py
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
"""
|
2
|
+
Copyright 2023-2024 SGLang Team
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
14
|
+
"""
|
15
|
+
|
1
16
|
# Adapted from:
|
2
17
|
# https://github.com/vllm-project/vllm/blob/c7f2cf2b7f67bce5842fedfdba508440fe257375/vllm/model_executor/models/dbrx.py#L1
|
3
18
|
# coding=utf-8
|
@@ -30,7 +45,7 @@ from vllm.transformers_utils.configs.dbrx import DbrxConfig
|
|
30
45
|
|
31
46
|
from sglang.srt.layers.logits_processor import LogitsProcessor
|
32
47
|
from sglang.srt.layers.radix_attention import RadixAttention
|
33
|
-
from sglang.srt.
|
48
|
+
from sglang.srt.model_executor.model_runner import InputMetadata
|
34
49
|
|
35
50
|
|
36
51
|
class DbrxRouter(nn.Module):
|
sglang/srt/models/deepseek.py
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
"""
|
2
|
+
Copyright 2023-2024 SGLang Team
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
14
|
+
"""
|
15
|
+
|
1
16
|
# Adapted from:
|
2
17
|
# https://github.com/vllm-project/vllm/blob/14f91fe67c2342f2fe859dc6a5c40810df0e1c61/vllm/model_executor/models/deepseek.py
|
3
18
|
"""Inference-only Deepseek model."""
|
@@ -31,7 +46,7 @@ from vllm.model_executor.model_loader.weight_utils import default_weight_loader
|
|
31
46
|
|
32
47
|
from sglang.srt.layers.logits_processor import LogitsProcessor
|
33
48
|
from sglang.srt.layers.radix_attention import RadixAttention
|
34
|
-
from sglang.srt.managers.
|
49
|
+
from sglang.srt.managers.schedule_batch import InputMetadata
|
35
50
|
|
36
51
|
|
37
52
|
class DeepseekMLP(nn.Module):
|
sglang/srt/models/deepseek_v2.py
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
"""
|
2
|
+
Copyright 2023-2024 SGLang Team
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
14
|
+
"""
|
15
|
+
|
1
16
|
# Adapted from:
|
2
17
|
# https://github.com/vllm-project/vllm/blob/fb6af8bc086328ca6659e72d11ffd4309ce4de22/vllm/model_executor/models/deepseek_v2.py
|
3
18
|
"""Inference-only DeepseekV2 model."""
|
@@ -30,7 +45,7 @@ from vllm.model_executor.model_loader.weight_utils import default_weight_loader
|
|
30
45
|
|
31
46
|
from sglang.srt.layers.logits_processor import LogitsProcessor
|
32
47
|
from sglang.srt.layers.radix_attention import RadixAttention
|
33
|
-
from sglang.srt.
|
48
|
+
from sglang.srt.model_executor.model_runner import InputMetadata
|
34
49
|
|
35
50
|
|
36
51
|
class DeepseekV2MLP(nn.Module):
|
sglang/srt/models/gemma.py
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
"""
|
2
|
+
Copyright 2023-2024 SGLang Team
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
14
|
+
"""
|
15
|
+
|
1
16
|
# Adapted from:
|
2
17
|
# https://github.com/vllm-project/vllm/blob/c7f2cf2b7f67bce5842fedfdba508440fe257375/vllm/model_executor/models/gemma.py#L1
|
3
18
|
"""Inference-only Gemma model compatible with HuggingFace weights."""
|
@@ -22,7 +37,7 @@ from vllm.model_executor.model_loader.weight_utils import default_weight_loader
|
|
22
37
|
|
23
38
|
from sglang.srt.layers.logits_processor import LogitsProcessor
|
24
39
|
from sglang.srt.layers.radix_attention import RadixAttention
|
25
|
-
from sglang.srt.
|
40
|
+
from sglang.srt.model_executor.model_runner import InputMetadata
|
26
41
|
|
27
42
|
|
28
43
|
class GemmaMLP(nn.Module):
|
sglang/srt/models/gemma2.py
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
"""
|
2
|
+
Copyright 2023-2024 SGLang Team
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
14
|
+
"""
|
15
|
+
|
1
16
|
# Adapted from:
|
2
17
|
# https://github.com/vllm-project/vllm/blob/56b325e977435af744f8b3dca7af0ca209663558/vllm/model_executor/models/gemma2.py
|
3
18
|
from typing import Iterable, Optional, Set, Tuple, Union
|
@@ -27,7 +42,7 @@ from vllm.model_executor.sampling_metadata import SamplingMetadata
|
|
27
42
|
|
28
43
|
from sglang.srt.layers.logits_processor import LogitsProcessor
|
29
44
|
from sglang.srt.layers.radix_attention import RadixAttention
|
30
|
-
from sglang.srt.
|
45
|
+
from sglang.srt.model_executor.model_runner import InputMetadata
|
31
46
|
|
32
47
|
|
33
48
|
class GemmaRMSNorm(CustomOp):
|
sglang/srt/models/gpt_bigcode.py
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
"""
|
2
|
+
Copyright 2023-2024 SGLang Team
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
14
|
+
"""
|
15
|
+
|
1
16
|
# Adapted from:
|
2
17
|
# https://github.com/vllm-project/vllm/blob/07eb6f19f3b0ee9f7adf6eb689607028aa40bfd5/vllm/model_executor/models/gpt_bigcode.py
|
3
18
|
"""Inference-only GPTBigCode model compatible with HuggingFace weights."""
|
@@ -20,7 +35,7 @@ from vllm.model_executor.model_loader.weight_utils import default_weight_loader
|
|
20
35
|
|
21
36
|
from sglang.srt.layers.logits_processor import LogitsProcessor
|
22
37
|
from sglang.srt.layers.radix_attention import RadixAttention
|
23
|
-
from sglang.srt.managers.
|
38
|
+
from sglang.srt.managers.schedule_batch import InputMetadata
|
24
39
|
|
25
40
|
|
26
41
|
class GPTBigCodeAttention(nn.Module):
|
sglang/srt/models/grok.py
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
"""
|
2
|
+
Copyright 2023-2024 SGLang Team
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
14
|
+
"""
|
15
|
+
|
1
16
|
# Adapted from
|
2
17
|
# https://github.com/vllm-project/vllm/blob/c7f2cf2b7f67bce5842fedfdba508440fe257375/vllm/model_executor/models/mixtral.py#L1
|
3
18
|
"""Inference-only Grok1 model."""
|
@@ -37,7 +52,7 @@ from vllm.utils import print_warning_once
|
|
37
52
|
from sglang.srt.layers.fused_moe import fused_moe
|
38
53
|
from sglang.srt.layers.logits_processor import LogitsProcessor
|
39
54
|
from sglang.srt.layers.radix_attention import RadixAttention
|
40
|
-
from sglang.srt.
|
55
|
+
from sglang.srt.model_executor.model_runner import InputMetadata
|
41
56
|
|
42
57
|
use_fused = True
|
43
58
|
|
sglang/srt/models/internlm2.py
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
"""
|
2
|
+
Copyright 2023-2024 SGLang Team
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
14
|
+
"""
|
15
|
+
|
1
16
|
# -*- coding: utf-8 -*-
|
2
17
|
# Adapted from https://raw.githubusercontent.com/vllm-project/vllm/7f62077af5159c625fe3ad1c812e6c1a2b93ba3b/vllm/model_executor/models/internlm2.py
|
3
18
|
|
@@ -25,7 +40,7 @@ from vllm.model_executor.model_loader.weight_utils import default_weight_loader
|
|
25
40
|
|
26
41
|
from sglang.srt.layers.logits_processor import LogitsProcessor
|
27
42
|
from sglang.srt.layers.radix_attention import RadixAttention
|
28
|
-
from sglang.srt.
|
43
|
+
from sglang.srt.model_executor.model_runner import InputMetadata
|
29
44
|
|
30
45
|
|
31
46
|
class InternLM2MLP(nn.Module):
|
sglang/srt/models/llama2.py
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
"""
|
2
|
+
Copyright 2023-2024 SGLang Team
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
14
|
+
"""
|
15
|
+
|
1
16
|
# Adapted from
|
2
17
|
# https://github.com/vllm-project/vllm/blob/c7f2cf2b7f67bce5842fedfdba508440fe257375/vllm/model_executor/models/llama.py#L1
|
3
18
|
"""Inference-only LLaMA model compatible with HuggingFace weights."""
|
@@ -11,6 +26,11 @@ from vllm.config import CacheConfig
|
|
11
26
|
from vllm.distributed import get_tensor_model_parallel_world_size
|
12
27
|
from vllm.model_executor.layers.activation import SiluAndMul
|
13
28
|
from vllm.model_executor.layers.layernorm import RMSNorm
|
29
|
+
from vllm.model_executor.layers.linear import (
|
30
|
+
MergedColumnParallelLinear,
|
31
|
+
QKVParallelLinear,
|
32
|
+
RowParallelLinear,
|
33
|
+
)
|
14
34
|
from vllm.model_executor.layers.quantization.base_config import QuantizationConfig
|
15
35
|
from vllm.model_executor.layers.rotary_embedding import get_rope
|
16
36
|
from vllm.model_executor.layers.vocab_parallel_embedding import (
|
@@ -21,11 +41,7 @@ from vllm.model_executor.model_loader.weight_utils import default_weight_loader
|
|
21
41
|
|
22
42
|
from sglang.srt.layers.logits_processor import LogitsProcessor
|
23
43
|
from sglang.srt.layers.radix_attention import RadixAttention
|
24
|
-
from sglang.srt.
|
25
|
-
|
26
|
-
MergedColumnParallelLinear = None
|
27
|
-
QKVParallelLinear = None
|
28
|
-
RowParallelLinear = None
|
44
|
+
from sglang.srt.model_executor.model_runner import InputMetadata
|
29
45
|
|
30
46
|
|
31
47
|
class LlamaMLP(nn.Module):
|
@@ -280,23 +296,6 @@ class LlamaForCausalLM(nn.Module):
|
|
280
296
|
cache_config: Optional[CacheConfig] = None,
|
281
297
|
efficient_weight_load=False,
|
282
298
|
) -> None:
|
283
|
-
global MergedColumnParallelLinear
|
284
|
-
global QKVParallelLinear
|
285
|
-
global RowParallelLinear
|
286
|
-
|
287
|
-
if efficient_weight_load:
|
288
|
-
from sglang.srt.layers.linear import (
|
289
|
-
MergedColumnParallelLinear,
|
290
|
-
QKVParallelLinear,
|
291
|
-
RowParallelLinear,
|
292
|
-
)
|
293
|
-
else:
|
294
|
-
from vllm.model_executor.layers.linear import (
|
295
|
-
MergedColumnParallelLinear,
|
296
|
-
QKVParallelLinear,
|
297
|
-
RowParallelLinear,
|
298
|
-
)
|
299
|
-
|
300
299
|
super().__init__()
|
301
300
|
self.config = config
|
302
301
|
self.quant_config = quant_config
|
@@ -1,3 +1,18 @@
|
|
1
|
+
"""
|
2
|
+
Copyright 2023-2024 SGLang Team
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
14
|
+
"""
|
15
|
+
|
1
16
|
from typing import Iterable, Optional, Tuple
|
2
17
|
|
3
18
|
import torch
|
@@ -10,7 +25,7 @@ from vllm.model_executor.layers.quantization.base_config import QuantizationConf
|
|
10
25
|
from vllm.model_executor.model_loader.weight_utils import default_weight_loader
|
11
26
|
|
12
27
|
from sglang.srt.layers.logits_processor import LogitProcessorOutput
|
13
|
-
from sglang.srt.
|
28
|
+
from sglang.srt.model_executor.model_runner import InputMetadata
|
14
29
|
from sglang.srt.models.llama2 import LlamaModel
|
15
30
|
|
16
31
|
|
sglang/srt/models/llava.py
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
"""
|
2
|
+
Copyright 2023-2024 SGLang Team
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
14
|
+
"""
|
15
|
+
|
1
16
|
"""Inference-only LLaVa model compatible with HuggingFace weights."""
|
2
17
|
|
3
18
|
from typing import Iterable, List, Optional, Tuple
|
@@ -17,13 +32,13 @@ from vllm.config import CacheConfig
|
|
17
32
|
from vllm.model_executor.layers.quantization.base_config import QuantizationConfig
|
18
33
|
from vllm.model_executor.model_loader.weight_utils import default_weight_loader
|
19
34
|
|
20
|
-
from sglang.srt.managers.
|
21
|
-
from sglang.srt.managers.controller.model_runner import InputMetadata
|
35
|
+
from sglang.srt.managers.schedule_batch import ForwardMode
|
22
36
|
from sglang.srt.mm_utils import (
|
23
37
|
get_anyres_image_grid_shape,
|
24
38
|
unpad_image,
|
25
39
|
unpad_image_shape,
|
26
40
|
)
|
41
|
+
from sglang.srt.model_executor.model_runner import InputMetadata
|
27
42
|
from sglang.srt.models.llama2 import LlamaForCausalLM
|
28
43
|
from sglang.srt.models.mistral import MistralForCausalLM
|
29
44
|
from sglang.srt.models.qwen2 import Qwen2ForCausalLM
|
sglang/srt/models/llavavid.py
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
"""
|
2
|
+
Copyright 2023-2024 SGLang Team
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
14
|
+
"""
|
15
|
+
|
1
16
|
"""Inference-only LLaVa video model compatible with HuggingFace weights."""
|
2
17
|
|
3
18
|
from typing import Iterable, List, Optional, Tuple
|
@@ -11,13 +26,13 @@ from vllm.config import CacheConfig
|
|
11
26
|
from vllm.model_executor.layers.quantization.base_config import QuantizationConfig
|
12
27
|
from vllm.model_executor.model_loader.weight_utils import default_weight_loader
|
13
28
|
|
14
|
-
from sglang.srt.managers.
|
15
|
-
from sglang.srt.managers.controller.model_runner import InputMetadata
|
29
|
+
from sglang.srt.managers.schedule_batch import ForwardMode
|
16
30
|
from sglang.srt.mm_utils import (
|
17
31
|
get_anyres_image_grid_shape,
|
18
32
|
unpad_image,
|
19
33
|
unpad_image_shape,
|
20
34
|
)
|
35
|
+
from sglang.srt.model_executor.model_runner import InputMetadata
|
21
36
|
from sglang.srt.models.llama2 import LlamaForCausalLM
|
22
37
|
|
23
38
|
|