sglang 0.3.4.post2__py3-none-any.whl → 0.3.5__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/api.py +1 -1
- sglang/bench_latency.py +3 -3
- sglang/bench_server_latency.py +2 -3
- sglang/bench_serving.py +92 -0
- sglang/global_config.py +9 -3
- sglang/lang/chat_template.py +50 -25
- sglang/lang/interpreter.py +9 -1
- sglang/lang/ir.py +11 -2
- sglang/launch_server.py +1 -1
- sglang/srt/configs/model_config.py +51 -13
- sglang/srt/constrained/__init__.py +18 -0
- sglang/srt/constrained/bnf_cache.py +61 -0
- sglang/srt/constrained/grammar.py +190 -0
- sglang/srt/hf_transformers_utils.py +6 -5
- sglang/srt/layers/attention/triton_ops/decode_attention.py +110 -30
- sglang/srt/layers/attention/triton_ops/prefill_attention.py +1 -1
- sglang/srt/layers/fused_moe/fused_moe.py +4 -3
- sglang/srt/layers/fused_moe/layer.py +28 -0
- sglang/srt/layers/quantization/base_config.py +16 -1
- sglang/srt/layers/vocab_parallel_embedding.py +486 -0
- sglang/srt/managers/data_parallel_controller.py +7 -6
- sglang/srt/managers/detokenizer_manager.py +9 -11
- sglang/srt/managers/image_processor.py +4 -3
- sglang/srt/managers/io_struct.py +70 -78
- sglang/srt/managers/schedule_batch.py +33 -49
- sglang/srt/managers/schedule_policy.py +24 -13
- sglang/srt/managers/scheduler.py +137 -80
- sglang/srt/managers/tokenizer_manager.py +224 -336
- sglang/srt/managers/tp_worker.py +5 -5
- sglang/srt/mem_cache/flush_cache.py +1 -1
- sglang/srt/model_executor/cuda_graph_runner.py +7 -4
- sglang/srt/model_executor/model_runner.py +8 -17
- sglang/srt/models/baichuan.py +4 -4
- sglang/srt/models/chatglm.py +4 -4
- sglang/srt/models/commandr.py +1 -1
- sglang/srt/models/dbrx.py +5 -5
- sglang/srt/models/deepseek.py +4 -4
- sglang/srt/models/deepseek_v2.py +4 -4
- sglang/srt/models/exaone.py +4 -4
- sglang/srt/models/gemma.py +1 -1
- sglang/srt/models/gemma2.py +1 -1
- sglang/srt/models/gpt2.py +287 -0
- sglang/srt/models/gpt_bigcode.py +1 -1
- sglang/srt/models/grok.py +4 -4
- sglang/srt/models/internlm2.py +4 -4
- sglang/srt/models/llama.py +15 -7
- sglang/srt/models/llama_embedding.py +2 -10
- sglang/srt/models/llama_reward.py +5 -0
- sglang/srt/models/minicpm.py +4 -4
- sglang/srt/models/minicpm3.py +4 -4
- sglang/srt/models/mixtral.py +7 -5
- sglang/srt/models/mixtral_quant.py +4 -4
- sglang/srt/models/mllama.py +5 -5
- sglang/srt/models/olmo.py +4 -4
- sglang/srt/models/olmoe.py +4 -4
- sglang/srt/models/qwen.py +4 -4
- sglang/srt/models/qwen2.py +4 -4
- sglang/srt/models/qwen2_moe.py +4 -4
- sglang/srt/models/qwen2_vl.py +4 -8
- sglang/srt/models/stablelm.py +4 -4
- sglang/srt/models/torch_native_llama.py +4 -4
- sglang/srt/models/xverse.py +4 -4
- sglang/srt/models/xverse_moe.py +4 -4
- sglang/srt/openai_api/adapter.py +52 -66
- sglang/srt/sampling/sampling_batch_info.py +7 -13
- sglang/srt/server.py +31 -35
- sglang/srt/server_args.py +34 -5
- sglang/srt/utils.py +40 -56
- sglang/test/runners.py +2 -1
- sglang/test/test_utils.py +73 -25
- sglang/utils.py +62 -1
- sglang/version.py +1 -1
- sglang-0.3.5.dist-info/METADATA +344 -0
- {sglang-0.3.4.post2.dist-info → sglang-0.3.5.dist-info}/RECORD +77 -73
- {sglang-0.3.4.post2.dist-info → sglang-0.3.5.dist-info}/WHEEL +1 -1
- sglang-0.3.4.post2.dist-info/METADATA +0 -899
- {sglang-0.3.4.post2.dist-info → sglang-0.3.5.dist-info}/LICENSE +0 -0
- {sglang-0.3.4.post2.dist-info → sglang-0.3.5.dist-info}/top_level.txt +0 -0
sglang/test/runners.py
CHANGED
@@ -273,6 +273,7 @@ class SRTRunner:
|
|
273
273
|
disable_cuda_graph=disable_cuda_graph,
|
274
274
|
disable_radix_cache=disable_radix_cache,
|
275
275
|
)
|
276
|
+
self.tokenizer = get_tokenizer(model_path)
|
276
277
|
|
277
278
|
def forward(
|
278
279
|
self,
|
@@ -366,7 +367,7 @@ class SRTRunner:
|
|
366
367
|
return ModelOutput(embed_logits=logits)
|
367
368
|
else:
|
368
369
|
scores = [x["embedding"][0] for x in response]
|
369
|
-
return ModelOutput(scores=
|
370
|
+
return ModelOutput(scores=scores)
|
370
371
|
|
371
372
|
def __enter__(self):
|
372
373
|
return self
|
sglang/test/test_utils.py
CHANGED
@@ -7,6 +7,7 @@ import random
|
|
7
7
|
import subprocess
|
8
8
|
import threading
|
9
9
|
import time
|
10
|
+
from concurrent.futures import ThreadPoolExecutor
|
10
11
|
from functools import partial
|
11
12
|
from types import SimpleNamespace
|
12
13
|
from typing import Callable, List, Optional
|
@@ -495,7 +496,7 @@ def run_unittest_files(files: List[str], timeout_per_file: float):
|
|
495
496
|
)
|
496
497
|
assert ret_code == 0
|
497
498
|
except TimeoutError:
|
498
|
-
kill_child_process(process.pid)
|
499
|
+
kill_child_process(process.pid, include_self=True)
|
499
500
|
time.sleep(5)
|
500
501
|
print(
|
501
502
|
f"\nTimeout after {timeout_per_file} seconds when running {filename}\n",
|
@@ -563,7 +564,7 @@ def run_bench_serving(
|
|
563
564
|
try:
|
564
565
|
res = run_benchmark(args)
|
565
566
|
finally:
|
566
|
-
kill_child_process(process.pid)
|
567
|
+
kill_child_process(process.pid, include_self=True)
|
567
568
|
|
568
569
|
assert res["completed"] == num_prompts
|
569
570
|
return res
|
@@ -596,7 +597,7 @@ def run_bench_latency(model, other_args):
|
|
596
597
|
lastline = output.split("\n")[-3]
|
597
598
|
output_throughput = float(lastline.split(" ")[-2])
|
598
599
|
finally:
|
599
|
-
kill_child_process(process.pid)
|
600
|
+
kill_child_process(process.pid, include_self=True)
|
600
601
|
|
601
602
|
return output_throughput
|
602
603
|
|
@@ -656,11 +657,12 @@ def read_output(output_lines):
|
|
656
657
|
time.sleep(0.1)
|
657
658
|
|
658
659
|
|
659
|
-
def
|
660
|
+
def run_and_check_memory_leak(
|
661
|
+
workload_func,
|
660
662
|
disable_radix_cache,
|
661
|
-
enable_mixed_chunk
|
662
|
-
enable_overlap
|
663
|
-
chunked_prefill_size
|
663
|
+
enable_mixed_chunk,
|
664
|
+
enable_overlap,
|
665
|
+
chunked_prefill_size,
|
664
666
|
):
|
665
667
|
other_args = ["--chunked-prefill-size", str(chunked_prefill_size)]
|
666
668
|
if disable_radix_cache:
|
@@ -690,25 +692,12 @@ def run_mmlu_test(
|
|
690
692
|
t = threading.Thread(target=read_output, args=(output_lines,))
|
691
693
|
t.start()
|
692
694
|
|
693
|
-
# Run the
|
694
|
-
|
695
|
-
base_url=base_url,
|
696
|
-
model=model,
|
697
|
-
eval_name="mmlu",
|
698
|
-
num_examples=128,
|
699
|
-
num_threads=128,
|
700
|
-
)
|
701
|
-
|
702
|
-
try:
|
703
|
-
metrics = run_eval(args)
|
704
|
-
print(f"{metrics=}")
|
705
|
-
assert metrics["score"] >= 0.65
|
706
|
-
finally:
|
707
|
-
pass
|
695
|
+
# Run the workload
|
696
|
+
workload_func(base_url, model)
|
708
697
|
|
709
698
|
# Clean up everything
|
710
|
-
kill_child_process(process.pid)
|
711
|
-
kill_child_process(process.pid)
|
699
|
+
kill_child_process(process.pid, include_self=True)
|
700
|
+
kill_child_process(process.pid, include_self=True)
|
712
701
|
stdout.close()
|
713
702
|
stderr.close()
|
714
703
|
if os.path.exists(STDOUT_FILENAME):
|
@@ -727,4 +716,63 @@ def run_mmlu_test(
|
|
727
716
|
has_leak = True
|
728
717
|
|
729
718
|
assert has_new_server
|
730
|
-
|
719
|
+
assert not has_leak
|
720
|
+
|
721
|
+
|
722
|
+
def run_mmlu_test(
|
723
|
+
disable_radix_cache=False,
|
724
|
+
enable_mixed_chunk=False,
|
725
|
+
enable_overlap=False,
|
726
|
+
chunked_prefill_size=32,
|
727
|
+
):
|
728
|
+
def workload_func(base_url, model):
|
729
|
+
# Run the eval
|
730
|
+
args = SimpleNamespace(
|
731
|
+
base_url=base_url,
|
732
|
+
model=model,
|
733
|
+
eval_name="mmlu",
|
734
|
+
num_examples=128,
|
735
|
+
num_threads=128,
|
736
|
+
)
|
737
|
+
|
738
|
+
try:
|
739
|
+
metrics = run_eval(args)
|
740
|
+
print(f"{metrics=}")
|
741
|
+
assert metrics["score"] >= 0.65
|
742
|
+
finally:
|
743
|
+
pass
|
744
|
+
|
745
|
+
run_and_check_memory_leak(workload_func, disable_radix_cache, enable_mixed_chunk, enable_overlap, chunked_prefill_size)
|
746
|
+
|
747
|
+
|
748
|
+
def run_mulit_request_test(
|
749
|
+
disable_radix_cache=False,
|
750
|
+
enable_mixed_chunk=False,
|
751
|
+
enable_overlap=False,
|
752
|
+
chunked_prefill_size=32,
|
753
|
+
):
|
754
|
+
|
755
|
+
def workload_func(base_url, model):
|
756
|
+
def run_one(_):
|
757
|
+
prompt = """
|
758
|
+
System: You are a helpful assistant.
|
759
|
+
User: What is the capital of France?
|
760
|
+
Assistant: The capital of France is
|
761
|
+
"""
|
762
|
+
|
763
|
+
response = requests.post(
|
764
|
+
f"{base_url}/generate",
|
765
|
+
json={
|
766
|
+
"text": prompt,
|
767
|
+
"sampling_params": {
|
768
|
+
"temperature": 0,
|
769
|
+
"max_new_tokens": 8,
|
770
|
+
},
|
771
|
+
},
|
772
|
+
)
|
773
|
+
ret = response.json()
|
774
|
+
|
775
|
+
with ThreadPoolExecutor(2) as executor:
|
776
|
+
list(executor.map(run_one, list(range(4))))
|
777
|
+
|
778
|
+
run_and_check_memory_leak(workload_func, disable_radix_cache, enable_mixed_chunk, enable_overlap, chunked_prefill_size)
|
sglang/utils.py
CHANGED
@@ -1,12 +1,15 @@
|
|
1
1
|
"""Common utilities."""
|
2
2
|
|
3
3
|
import base64
|
4
|
+
import gc
|
4
5
|
import importlib
|
5
6
|
import json
|
6
7
|
import logging
|
7
8
|
import os
|
8
9
|
import signal
|
10
|
+
import subprocess
|
9
11
|
import sys
|
12
|
+
import time
|
10
13
|
import traceback
|
11
14
|
import urllib.request
|
12
15
|
from concurrent.futures import ThreadPoolExecutor
|
@@ -16,6 +19,7 @@ from typing import Optional, Union
|
|
16
19
|
|
17
20
|
import numpy as np
|
18
21
|
import requests
|
22
|
+
from IPython.display import HTML, display
|
19
23
|
from tqdm import tqdm
|
20
24
|
|
21
25
|
logger = logging.getLogger(__name__)
|
@@ -151,7 +155,7 @@ def encode_video_base64(video_path: str, num_frames: int = 16):
|
|
151
155
|
frame_indices = np.linspace(0, total_frames - 1, num_frames, dtype=int)
|
152
156
|
|
153
157
|
frames = []
|
154
|
-
for
|
158
|
+
for _ in range(total_frames):
|
155
159
|
ret, frame = cap.read()
|
156
160
|
if ret:
|
157
161
|
frames.append(frame)
|
@@ -294,3 +298,60 @@ def download_and_cache_file(url: str, filename: Optional[str] = None):
|
|
294
298
|
bar.update(len(chunk))
|
295
299
|
|
296
300
|
return filename
|
301
|
+
|
302
|
+
|
303
|
+
def execute_shell_command(command: str) -> subprocess.Popen:
|
304
|
+
"""
|
305
|
+
Execute a shell command and return the process handle
|
306
|
+
|
307
|
+
Args:
|
308
|
+
command: Shell command as a string (can include \\ line continuations)
|
309
|
+
Returns:
|
310
|
+
subprocess.Popen: Process handle
|
311
|
+
"""
|
312
|
+
# Replace \ newline with space and split
|
313
|
+
command = command.replace("\\\n", " ").replace("\\", " ")
|
314
|
+
parts = command.split()
|
315
|
+
|
316
|
+
return subprocess.Popen(parts, text=True, stderr=subprocess.STDOUT)
|
317
|
+
|
318
|
+
|
319
|
+
def wait_for_server(base_url: str, timeout: int = None) -> None:
|
320
|
+
"""Wait for the server to be ready by polling the /v1/models endpoint.
|
321
|
+
|
322
|
+
Args:
|
323
|
+
base_url: The base URL of the server
|
324
|
+
timeout: Maximum time to wait in seconds. None means wait forever.
|
325
|
+
"""
|
326
|
+
start_time = time.time()
|
327
|
+
while True:
|
328
|
+
try:
|
329
|
+
response = requests.get(
|
330
|
+
f"{base_url}/v1/models",
|
331
|
+
headers={"Authorization": "Bearer None"},
|
332
|
+
)
|
333
|
+
if response.status_code == 200:
|
334
|
+
time.sleep(5)
|
335
|
+
print_highlight(
|
336
|
+
"""\n
|
337
|
+
NOTE: Typically, the server runs in a separate terminal.
|
338
|
+
In this notebook, we run the server and notebook code together, so their outputs are combined.
|
339
|
+
To improve clarity, the server logs are displayed in the original black color, while the notebook outputs are highlighted in blue.
|
340
|
+
"""
|
341
|
+
)
|
342
|
+
break
|
343
|
+
|
344
|
+
if timeout and time.time() - start_time > timeout:
|
345
|
+
raise TimeoutError("Server did not become ready within timeout period")
|
346
|
+
except requests.exceptions.RequestException:
|
347
|
+
time.sleep(1)
|
348
|
+
|
349
|
+
|
350
|
+
def terminate_process(process):
|
351
|
+
from sglang.srt.utils import kill_child_process
|
352
|
+
kill_child_process(process.pid, include_self=True)
|
353
|
+
|
354
|
+
|
355
|
+
def print_highlight(html_content: str):
|
356
|
+
html_content = str(html_content).replace("\n", "<br>")
|
357
|
+
display(HTML(f"<strong style='color: #00008B;'>{html_content}</strong>"))
|
sglang/version.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = "0.3.
|
1
|
+
__version__ = "0.3.5"
|
@@ -0,0 +1,344 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: sglang
|
3
|
+
Version: 0.3.5
|
4
|
+
Summary: SGLang is yet another fast serving framework for large language models and vision language models.
|
5
|
+
License: Apache License
|
6
|
+
Version 2.0, January 2004
|
7
|
+
http://www.apache.org/licenses/
|
8
|
+
|
9
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
10
|
+
|
11
|
+
1. Definitions.
|
12
|
+
|
13
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
14
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
15
|
+
|
16
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
17
|
+
the copyright owner that is granting the License.
|
18
|
+
|
19
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
20
|
+
other entities that control, are controlled by, or are under common
|
21
|
+
control with that entity. For the purposes of this definition,
|
22
|
+
"control" means (i) the power, direct or indirect, to cause the
|
23
|
+
direction or management of such entity, whether by contract or
|
24
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
25
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
26
|
+
|
27
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
28
|
+
exercising permissions granted by this License.
|
29
|
+
|
30
|
+
"Source" form shall mean the preferred form for making modifications,
|
31
|
+
including but not limited to software source code, documentation
|
32
|
+
source, and configuration files.
|
33
|
+
|
34
|
+
"Object" form shall mean any form resulting from mechanical
|
35
|
+
transformation or translation of a Source form, including but
|
36
|
+
not limited to compiled object code, generated documentation,
|
37
|
+
and conversions to other media types.
|
38
|
+
|
39
|
+
"Work" shall mean the work of authorship, whether in Source or
|
40
|
+
Object form, made available under the License, as indicated by a
|
41
|
+
copyright notice that is included in or attached to the work
|
42
|
+
(an example is provided in the Appendix below).
|
43
|
+
|
44
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
45
|
+
form, that is based on (or derived from) the Work and for which the
|
46
|
+
editorial revisions, annotations, elaborations, or other modifications
|
47
|
+
represent, as a whole, an original work of authorship. For the purposes
|
48
|
+
of this License, Derivative Works shall not include works that remain
|
49
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
50
|
+
the Work and Derivative Works thereof.
|
51
|
+
|
52
|
+
"Contribution" shall mean any work of authorship, including
|
53
|
+
the original version of the Work and any modifications or additions
|
54
|
+
to that Work or Derivative Works thereof, that is intentionally
|
55
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
56
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
57
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
58
|
+
means any form of electronic, verbal, or written communication sent
|
59
|
+
to the Licensor or its representatives, including but not limited to
|
60
|
+
communication on electronic mailing lists, source code control systems,
|
61
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
62
|
+
Licensor for the purpose of discussing and improving the Work, but
|
63
|
+
excluding communication that is conspicuously marked or otherwise
|
64
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
65
|
+
|
66
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
67
|
+
on behalf of whom a Contribution has been received by Licensor and
|
68
|
+
subsequently incorporated within the Work.
|
69
|
+
|
70
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
71
|
+
this License, each Contributor hereby grants to You a perpetual,
|
72
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
73
|
+
copyright license to reproduce, prepare Derivative Works of,
|
74
|
+
publicly display, publicly perform, sublicense, and distribute the
|
75
|
+
Work and such Derivative Works in Source or Object form.
|
76
|
+
|
77
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
78
|
+
this License, each Contributor hereby grants to You a perpetual,
|
79
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
80
|
+
(except as stated in this section) patent license to make, have made,
|
81
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
82
|
+
where such license applies only to those patent claims licensable
|
83
|
+
by such Contributor that are necessarily infringed by their
|
84
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
85
|
+
with the Work to which such Contribution(s) was submitted. If You
|
86
|
+
institute patent litigation against any entity (including a
|
87
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
88
|
+
or a Contribution incorporated within the Work constitutes direct
|
89
|
+
or contributory patent infringement, then any patent licenses
|
90
|
+
granted to You under this License for that Work shall terminate
|
91
|
+
as of the date such litigation is filed.
|
92
|
+
|
93
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
94
|
+
Work or Derivative Works thereof in any medium, with or without
|
95
|
+
modifications, and in Source or Object form, provided that You
|
96
|
+
meet the following conditions:
|
97
|
+
|
98
|
+
(a) You must give any other recipients of the Work or
|
99
|
+
Derivative Works a copy of this License; and
|
100
|
+
|
101
|
+
(b) You must cause any modified files to carry prominent notices
|
102
|
+
stating that You changed the files; and
|
103
|
+
|
104
|
+
(c) You must retain, in the Source form of any Derivative Works
|
105
|
+
that You distribute, all copyright, patent, trademark, and
|
106
|
+
attribution notices from the Source form of the Work,
|
107
|
+
excluding those notices that do not pertain to any part of
|
108
|
+
the Derivative Works; and
|
109
|
+
|
110
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
111
|
+
distribution, then any Derivative Works that You distribute must
|
112
|
+
include a readable copy of the attribution notices contained
|
113
|
+
within such NOTICE file, excluding those notices that do not
|
114
|
+
pertain to any part of the Derivative Works, in at least one
|
115
|
+
of the following places: within a NOTICE text file distributed
|
116
|
+
as part of the Derivative Works; within the Source form or
|
117
|
+
documentation, if provided along with the Derivative Works; or,
|
118
|
+
within a display generated by the Derivative Works, if and
|
119
|
+
wherever such third-party notices normally appear. The contents
|
120
|
+
of the NOTICE file are for informational purposes only and
|
121
|
+
do not modify the License. You may add Your own attribution
|
122
|
+
notices within Derivative Works that You distribute, alongside
|
123
|
+
or as an addendum to the NOTICE text from the Work, provided
|
124
|
+
that such additional attribution notices cannot be construed
|
125
|
+
as modifying the License.
|
126
|
+
|
127
|
+
You may add Your own copyright statement to Your modifications and
|
128
|
+
may provide additional or different license terms and conditions
|
129
|
+
for use, reproduction, or distribution of Your modifications, or
|
130
|
+
for any such Derivative Works as a whole, provided Your use,
|
131
|
+
reproduction, and distribution of the Work otherwise complies with
|
132
|
+
the conditions stated in this License.
|
133
|
+
|
134
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
135
|
+
any Contribution intentionally submitted for inclusion in the Work
|
136
|
+
by You to the Licensor shall be under the terms and conditions of
|
137
|
+
this License, without any additional terms or conditions.
|
138
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
139
|
+
the terms of any separate license agreement you may have executed
|
140
|
+
with Licensor regarding such Contributions.
|
141
|
+
|
142
|
+
6. Trademarks. This License does not grant permission to use the trade
|
143
|
+
names, trademarks, service marks, or product names of the Licensor,
|
144
|
+
except as required for reasonable and customary use in describing the
|
145
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
146
|
+
|
147
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
148
|
+
agreed to in writing, Licensor provides the Work (and each
|
149
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
150
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
151
|
+
implied, including, without limitation, any warranties or conditions
|
152
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
153
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
154
|
+
appropriateness of using or redistributing the Work and assume any
|
155
|
+
risks associated with Your exercise of permissions under this License.
|
156
|
+
|
157
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
158
|
+
whether in tort (including negligence), contract, or otherwise,
|
159
|
+
unless required by applicable law (such as deliberate and grossly
|
160
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
161
|
+
liable to You for damages, including any direct, indirect, special,
|
162
|
+
incidental, or consequential damages of any character arising as a
|
163
|
+
result of this License or out of the use or inability to use the
|
164
|
+
Work (including but not limited to damages for loss of goodwill,
|
165
|
+
work stoppage, computer failure or malfunction, or any and all
|
166
|
+
other commercial damages or losses), even if such Contributor
|
167
|
+
has been advised of the possibility of such damages.
|
168
|
+
|
169
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
170
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
171
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
172
|
+
or other liability obligations and/or rights consistent with this
|
173
|
+
License. However, in accepting such obligations, You may act only
|
174
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
175
|
+
of any other Contributor, and only if You agree to indemnify,
|
176
|
+
defend, and hold each Contributor harmless for any liability
|
177
|
+
incurred by, or claims asserted against, such Contributor by reason
|
178
|
+
of your accepting any such warranty or additional liability.
|
179
|
+
|
180
|
+
END OF TERMS AND CONDITIONS
|
181
|
+
|
182
|
+
APPENDIX: How to apply the Apache License to your work.
|
183
|
+
|
184
|
+
To apply the Apache License to your work, attach the following
|
185
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
186
|
+
replaced with your own identifying information. (Don't include
|
187
|
+
the brackets!) The text should be enclosed in the appropriate
|
188
|
+
comment syntax for the file format. We also recommend that a
|
189
|
+
file or class name and description of purpose be included on the
|
190
|
+
same "printed page" as the copyright notice for easier
|
191
|
+
identification within third-party archives.
|
192
|
+
|
193
|
+
Copyright [yyyy] [name of copyright owner]
|
194
|
+
|
195
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
196
|
+
you may not use this file except in compliance with the License.
|
197
|
+
You may obtain a copy of the License at
|
198
|
+
|
199
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
200
|
+
|
201
|
+
Unless required by applicable law or agreed to in writing, software
|
202
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
203
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
204
|
+
See the License for the specific language governing permissions and
|
205
|
+
limitations under the License.
|
206
|
+
|
207
|
+
Project-URL: Homepage, https://github.com/sgl-project/sglang
|
208
|
+
Project-URL: Bug Tracker, https://github.com/sgl-project/sglang/issues
|
209
|
+
Classifier: Programming Language :: Python :: 3
|
210
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
211
|
+
Requires-Python: >=3.8
|
212
|
+
Description-Content-Type: text/markdown
|
213
|
+
License-File: LICENSE
|
214
|
+
Requires-Dist: requests
|
215
|
+
Requires-Dist: tqdm
|
216
|
+
Requires-Dist: numpy
|
217
|
+
Requires-Dist: IPython
|
218
|
+
Provides-Extra: all
|
219
|
+
Requires-Dist: sglang[srt]; extra == "all"
|
220
|
+
Requires-Dist: sglang[openai]; extra == "all"
|
221
|
+
Requires-Dist: sglang[anthropic]; extra == "all"
|
222
|
+
Requires-Dist: sglang[litellm]; extra == "all"
|
223
|
+
Provides-Extra: all_hip
|
224
|
+
Requires-Dist: sglang[srt_hip]; extra == "all-hip"
|
225
|
+
Requires-Dist: sglang[openai]; extra == "all-hip"
|
226
|
+
Requires-Dist: sglang[anthropic]; extra == "all-hip"
|
227
|
+
Requires-Dist: sglang[litellm]; extra == "all-hip"
|
228
|
+
Provides-Extra: all_xpu
|
229
|
+
Requires-Dist: sglang[srt_xpu]; extra == "all-xpu"
|
230
|
+
Requires-Dist: sglang[openai]; extra == "all-xpu"
|
231
|
+
Requires-Dist: sglang[anthropic]; extra == "all-xpu"
|
232
|
+
Requires-Dist: sglang[litellm]; extra == "all-xpu"
|
233
|
+
Provides-Extra: anthropic
|
234
|
+
Requires-Dist: anthropic>=0.20.0; extra == "anthropic"
|
235
|
+
Provides-Extra: dev
|
236
|
+
Requires-Dist: sglang[all]; extra == "dev"
|
237
|
+
Requires-Dist: sglang[test]; extra == "dev"
|
238
|
+
Provides-Extra: dev_hip
|
239
|
+
Requires-Dist: sglang[all_hip]; extra == "dev-hip"
|
240
|
+
Requires-Dist: sglang[test]; extra == "dev-hip"
|
241
|
+
Provides-Extra: dev_xpu
|
242
|
+
Requires-Dist: sglang[all_xpu]; extra == "dev-xpu"
|
243
|
+
Requires-Dist: sglang[test]; extra == "dev-xpu"
|
244
|
+
Provides-Extra: litellm
|
245
|
+
Requires-Dist: litellm>=1.0.0; extra == "litellm"
|
246
|
+
Provides-Extra: openai
|
247
|
+
Requires-Dist: openai>=1.0; extra == "openai"
|
248
|
+
Requires-Dist: tiktoken; extra == "openai"
|
249
|
+
Provides-Extra: runtime_common
|
250
|
+
Requires-Dist: aiohttp; extra == "runtime-common"
|
251
|
+
Requires-Dist: decord; extra == "runtime-common"
|
252
|
+
Requires-Dist: fastapi; extra == "runtime-common"
|
253
|
+
Requires-Dist: hf-transfer; extra == "runtime-common"
|
254
|
+
Requires-Dist: huggingface-hub; extra == "runtime-common"
|
255
|
+
Requires-Dist: interegular; extra == "runtime-common"
|
256
|
+
Requires-Dist: orjson; extra == "runtime-common"
|
257
|
+
Requires-Dist: packaging; extra == "runtime-common"
|
258
|
+
Requires-Dist: pillow; extra == "runtime-common"
|
259
|
+
Requires-Dist: psutil; extra == "runtime-common"
|
260
|
+
Requires-Dist: pydantic; extra == "runtime-common"
|
261
|
+
Requires-Dist: python-multipart; extra == "runtime-common"
|
262
|
+
Requires-Dist: torchao; extra == "runtime-common"
|
263
|
+
Requires-Dist: uvicorn; extra == "runtime-common"
|
264
|
+
Requires-Dist: uvloop; extra == "runtime-common"
|
265
|
+
Requires-Dist: zmq; extra == "runtime-common"
|
266
|
+
Requires-Dist: outlines>=0.0.44; extra == "runtime-common"
|
267
|
+
Requires-Dist: modelscope; extra == "runtime-common"
|
268
|
+
Provides-Extra: srt
|
269
|
+
Requires-Dist: sglang[runtime_common]; extra == "srt"
|
270
|
+
Requires-Dist: torch; extra == "srt"
|
271
|
+
Requires-Dist: vllm==0.6.3.post1; extra == "srt"
|
272
|
+
Provides-Extra: srt_hip
|
273
|
+
Requires-Dist: sglang[runtime_common]; extra == "srt-hip"
|
274
|
+
Requires-Dist: torch; extra == "srt-hip"
|
275
|
+
Requires-Dist: vllm==0.6.3.dev13; extra == "srt-hip"
|
276
|
+
Provides-Extra: srt_xpu
|
277
|
+
Requires-Dist: sglang[runtime_common]; extra == "srt-xpu"
|
278
|
+
Provides-Extra: test
|
279
|
+
Requires-Dist: jsonlines; extra == "test"
|
280
|
+
Requires-Dist: matplotlib; extra == "test"
|
281
|
+
Requires-Dist: pandas; extra == "test"
|
282
|
+
Requires-Dist: sentence-transformers; extra == "test"
|
283
|
+
Requires-Dist: accelerate; extra == "test"
|
284
|
+
Requires-Dist: peft; extra == "test"
|
285
|
+
|
286
|
+
<div align="center" id="sglangtop">
|
287
|
+
<img src="https://raw.githubusercontent.com/sgl-project/sglang/main/assets/logo.png" alt="logo" width="400" margin="10px"></img>
|
288
|
+
|
289
|
+
[](https://pypi.org/project/sglang)
|
290
|
+

|
291
|
+
[](https://github.com/sgl-project/sglang/tree/main/LICENSE)
|
292
|
+
[](https://github.com/sgl-project/sglang/issues)
|
293
|
+
[](https://github.com/sgl-project/sglang/issues)
|
294
|
+
|
295
|
+
</div>
|
296
|
+
|
297
|
+
--------------------------------------------------------------------------------
|
298
|
+
|
299
|
+
| [**Blog**](https://lmsys.org/blog/2024-07-25-sglang-llama3/) | [**Documentation**](https://sgl-project.github.io/) | [**Join Slack**](https://join.slack.com/t/sgl-fru7574/shared_invite/zt-2ngly9muu-t37XiH87qvD~6rVBTkTEHw) |
|
300
|
+
[**Join Bi-Weekly Development Meeting**](https://docs.google.com/document/d/1xEow4eIM152xNcRxqZz9VEcOiTQo8-CEuuQ5qTmkt-E/edit?usp=sharing) |
|
301
|
+
|
302
|
+
## News
|
303
|
+
- [2024/10] 🔥 The First SGLang Online Meetup ([slides](https://github.com/sgl-project/sgl-learning-materials?tab=readme-ov-file#the-first-sglang-online-meetup)).
|
304
|
+
- [2024/09] SGLang v0.3 Release: 7x Faster DeepSeek MLA, 1.5x Faster torch.compile, Multi-Image/Video LLaVA-OneVision ([blog](https://lmsys.org/blog/2024-09-04-sglang-v0-3/)).
|
305
|
+
- [2024/07] Faster Llama3 Serving with SGLang Runtime (vs. TensorRT-LLM, vLLM) ([blog](https://lmsys.org/blog/2024-07-25-sglang-llama3/)).
|
306
|
+
|
307
|
+
<details>
|
308
|
+
<summary>More</summary>
|
309
|
+
|
310
|
+
- [2024/02] SGLang enables **3x faster JSON decoding** with compressed finite state machine ([blog](https://lmsys.org/blog/2024-02-05-compressed-fsm/)).
|
311
|
+
- [2024/04] SGLang is used by the official **LLaVA-NeXT (video)** release ([blog](https://llava-vl.github.io/blog/2024-04-30-llava-next-video/)).
|
312
|
+
- [2024/01] SGLang provides up to **5x faster inference** with RadixAttention ([blog](https://lmsys.org/blog/2024-01-17-sglang/)).
|
313
|
+
- [2024/01] SGLang powers the serving of the official **LLaVA v1.6** release demo ([usage](https://github.com/haotian-liu/LLaVA?tab=readme-ov-file#demo)).
|
314
|
+
|
315
|
+
</details>
|
316
|
+
|
317
|
+
## About
|
318
|
+
SGLang is a fast serving framework for large language models and vision language models.
|
319
|
+
It makes your interaction with models faster and more controllable by co-designing the backend runtime and frontend language.
|
320
|
+
The core features include:
|
321
|
+
|
322
|
+
- **Fast Backend Runtime**: Provides efficient serving with RadixAttention for prefix caching, jump-forward constrained decoding, continuous batching, token attention (paged attention), tensor parallelism, FlashInfer kernels, chunked prefill, and quantization (INT4/FP8/AWQ/GPTQ).
|
323
|
+
- **Flexible Frontend Language**: Offers an intuitive interface for programming LLM applications, including chained generation calls, advanced prompting, control flow, multi-modal inputs, parallelism, and external interactions.
|
324
|
+
- **Extensive Model Support**: Supports a wide range of generative models (Llama, Gemma, Mistral, QWen, DeepSeek, LLaVA, etc.) and embedding models (e5-mistral), with easy extensibility for integrating new models.
|
325
|
+
- **Active Community**: SGLang is open-source and backed by an active community with industry adoption.
|
326
|
+
|
327
|
+
## Install
|
328
|
+
See [https://sgl-project.github.io/start/install.html](https://sgl-project.github.io/start/install.html)
|
329
|
+
|
330
|
+
## Backend: SGLang Runtime (SRT)
|
331
|
+
See [https://sgl-project.github.io/backend/backend.html](https://sgl-project.github.io/backend/backend.html)
|
332
|
+
|
333
|
+
## Frontend: Structured Generation Language (SGLang)
|
334
|
+
See [https://sgl-project.github.io/frontend/frontend.html](https://sgl-project.github.io/frontend/frontend.html)
|
335
|
+
|
336
|
+
## Benchmark And Performance
|
337
|
+
Learn more in our release blogs: [v0.2 blog](https://lmsys.org/blog/2024-07-25-sglang-llama3/), [v0.3 blog](https://lmsys.org/blog/2024-09-04-sglang-v0-3/)
|
338
|
+
|
339
|
+
## Roadmap
|
340
|
+
[Development Roadmap (2024 Q4)](https://github.com/sgl-project/sglang/issues/1487)
|
341
|
+
|
342
|
+
## Citation And Acknowledgment
|
343
|
+
Please cite our paper, [SGLang: Efficient Execution of Structured Language Model Programs](https://arxiv.org/abs/2312.07104), if you find the project useful.
|
344
|
+
We also learned from the design and reused code from the following projects: [Guidance](https://github.com/guidance-ai/guidance), [vLLM](https://github.com/vllm-project/vllm), [LightLLM](https://github.com/ModelTC/lightllm), [FlashInfer](https://github.com/flashinfer-ai/flashinfer), [Outlines](https://github.com/outlines-dev/outlines), and [LMQL](https://github.com/eth-sri/lmql).
|