sglang 0.2.0__py3-none-any.whl → 0.2.2__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/bench_serving.py CHANGED
@@ -369,7 +369,7 @@ def sample_random_requests(
369
369
  ) -> List[Tuple[str, int, int]]:
370
370
 
371
371
  input_lens = np.random.randint(
372
- int(input_len * range_ratio),
372
+ max(int(input_len * range_ratio), 1),
373
373
  input_len + 1,
374
374
  size=num_prompts,
375
375
  )
@@ -415,7 +415,7 @@ def sample_random_requests(
415
415
  prompt_token_ids = tokenizer(prompt).input_ids
416
416
  prompt_len = len(prompt_token_ids)
417
417
 
418
- if prompt_len <= input_lens[i]:
418
+ if prompt_len > input_lens[i]:
419
419
  input_ids = prompt_token_ids[: input_lens[i]]
420
420
  else:
421
421
  ratio = (input_lens[i] + prompt_len - 1) // prompt_len
@@ -935,7 +935,7 @@ if __name__ == "__main__":
935
935
  parser.add_argument(
936
936
  "--random-range-ratio",
937
937
  type=float,
938
- default=1.0,
938
+ default=0.0,
939
939
  help="Range of sampled ratio of input/output length, "
940
940
  "used only for random dataset.",
941
941
  )
sglang/global_config.py CHANGED
@@ -17,7 +17,7 @@ class GlobalConfig:
17
17
 
18
18
  # Runtime constants: New generation token ratio estimation
19
19
  self.init_new_token_ratio = 0.7
20
- self.base_min_new_token_ratio = 0.2
20
+ self.base_min_new_token_ratio = 0.1
21
21
  self.new_token_ratio_decay = 0.001
22
22
  self.new_token_ratio_recovery = 0.05
23
23
 
@@ -121,7 +121,7 @@ class ModelRunner:
121
121
  skip_tokenizer_init=True,
122
122
  )
123
123
 
124
- if is_llama3_405b_fp8(self.model_config):
124
+ if is_llama3_405b_fp8(self.model_config) and self.tp_size <= 8:
125
125
  # A temporary hack to fix the num_heads for meta-llama/Meta-Llama-3.1-405B-FP8 checkpoints
126
126
  self.model_config.hf_config.num_key_value_heads = 8
127
127
  vllm_model_config.hf_config.num_key_value_heads = 8
@@ -40,7 +40,10 @@ class GenerateReqInput:
40
40
  self.text is not None and self.input_ids is not None
41
41
  ):
42
42
  raise ValueError("Either text or input_ids should be provided.")
43
- if self.sampling_params.get("n", 1) != 1:
43
+ if (
44
+ isinstance(self.sampling_params, dict)
45
+ and self.sampling_params.get("n", 1) != 1
46
+ ):
44
47
  is_single = False
45
48
  else:
46
49
  if self.text is not None:
@@ -94,9 +94,14 @@ def load_chat_template_for_openai_api(chat_template_arg):
94
94
  async def v1_completions(tokenizer_manager, raw_request: Request):
95
95
  request_json = await raw_request.json()
96
96
  request = CompletionRequest(**request_json)
97
+ prompt = request.prompt
98
+ if isinstance(prompt, str) or isinstance(prompt[0], str):
99
+ prompt_kwargs = {"text": prompt}
100
+ else:
101
+ prompt_kwargs = {"input_ids": prompt}
97
102
 
98
103
  adapted_request = GenerateReqInput(
99
- text=request.prompt,
104
+ **prompt_kwargs,
100
105
  sampling_params={
101
106
  "temperature": request.temperature,
102
107
  "max_new_tokens": request.max_tokens,
sglang/srt/utils.py CHANGED
@@ -626,6 +626,7 @@ def is_llama3_405b_fp8(model_config):
626
626
  and model_config.hf_config.intermediate_size == 53248
627
627
  and model_config.hf_config.num_hidden_layers == 126
628
628
  and model_config.hf_config.num_key_value_heads == 16
629
+ and hasattr(model_config.hf_config, "quantization_config")
629
630
  and model_config.hf_config.quantization_config["quant_method"] == "fbgemm_fp8"
630
631
  ):
631
632
  return True
sglang/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.2.0"
1
+ __version__ = "0.2.2"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sglang
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Summary: SGLang is yet another fast serving framework for large language models and vision language models.
5
5
  License: Apache License
6
6
  Version 2.0, January 2004
@@ -249,7 +249,7 @@ Requires-Dist: outlines >=0.0.44 ; extra == 'srt'
249
249
 
250
250
  --------------------------------------------------------------------------------
251
251
 
252
- | [**Blog**](https://lmsys.org/blog/2024-01-17-sglang/) | [**Paper**](https://arxiv.org/abs/2312.07104) |
252
+ | [**Blog**](https://lmsys.org/blog/2024-07-25-sglang-llama3/) | [**Paper**](https://arxiv.org/abs/2312.07104) |
253
253
 
254
254
  SGLang is a fast serving framework for large language models and vision language models.
255
255
  It makes your interaction with models faster and more controllable by co-designing the backend runtime and frontend language.
@@ -259,13 +259,14 @@ The core features include:
259
259
  - **Flexible Frontend Language**: Enables easy programming of LLM applications with chained generation calls, advanced prompting, control flow, multiple modalities, parallelism, and external interactions.
260
260
 
261
261
  ## News
262
- - [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/)).
263
- - [2024/02] 🔥 SGLang enables **3x faster JSON decoding** with compressed finite state machine ([blog](https://lmsys.org/blog/2024-02-05-compressed-fsm/)).
264
- - [2024/01] SGLang provides up to **5x faster inference** with RadixAttention ([blog](https://lmsys.org/blog/2024-01-17-sglang/)).
262
+ - [2024/07] 🔥 Faster Llama3 Serving with SGLang Runtime (vs. TensorRT-LLM, vLLM) ([blog](https://lmsys.org/blog/2024-07-25-sglang-llama3/)).
263
+ - [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/)).
264
+ - [2024/02] SGLang enables **3x faster JSON decoding** with compressed finite state machine ([blog](https://lmsys.org/blog/2024-02-05-compressed-fsm/)).
265
265
 
266
266
  <details>
267
267
  <summary>More</summary>
268
268
 
269
+ - [2024/01] SGLang provides up to **5x faster inference** with RadixAttention ([blog](https://lmsys.org/blog/2024-01-17-sglang/)).
269
270
  - [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)).
270
271
 
271
272
  </details>
@@ -302,7 +303,8 @@ pip install flashinfer -i https://flashinfer.ai/whl/cu121/torch2.3/
302
303
  ```
303
304
 
304
305
  ### Method 3: Using docker
305
- The docker images are available on Docker Hub as [lmsysorg/sglang](https://hub.docker.com/r/lmsysorg/sglang/tags).
306
+ The docker images are available on Docker Hub as [lmsysorg/sglang](https://hub.docker.com/r/lmsysorg/sglang/tags), built from [Dockerfile](docker).
307
+ Repalce `<secret>` below with your huggingface hub [token](https://huggingface.co/docs/hub/en/security-tokens).
306
308
 
307
309
  ```bash
308
310
  docker run --gpus all \
@@ -311,7 +313,7 @@ docker run --gpus all \
311
313
  --env "HUGGING_FACE_HUB_TOKEN=<secret>" \
312
314
  --ipc=host \
313
315
  lmsysorg/sglang:latest \
314
- python3 -m sglang.launch_server --model-path meta-llama/Meta-Llama-3-8B --host 0.0.0.0 --port 30000
316
+ python3 -m sglang.launch_server --model-path meta-llama/Meta-Llama-3-8B-Instruct --host 0.0.0.0 --port 30000
315
317
  ```
316
318
 
317
319
  ### Common Notes
@@ -399,6 +401,21 @@ python -m sglang.launch_server --model-path meta-llama/Meta-Llama-3-8B-Instruct
399
401
  - To enable fp8 quantization, you can add `--quantization fp8` on a fp16 checkpoint or directly load a fp8 checkpoint without specifying any arguments.
400
402
  - To enable experimental torch.compile support, you can add `--enable-torch-compile`. It accelerates small models on small batch sizes.
401
403
 
404
+ ### Run Llama 3.1 405B
405
+
406
+ ```bash
407
+ # 2 nodes run 405B fp16
408
+ # replace the `172.16.4.52:20000` with your own first node ip address and port, disable CUDA Graph temporarily
409
+ # on the first node
410
+ GLOO_SOCKET_IFNAME=eth0 python3 -m sglang.launch_server --model-path meta-llama/Meta-Llama-3.1-405B-Instruct --tp 16 --nccl-init-addr 172.16.4.52:20000 --nnodes 2 --node-rank 0 --disable-cuda-graph --mem-frac 0.75
411
+
412
+ # on the second
413
+ GLOO_SOCKET_IFNAME=eth0 python3 -m sglang.launch_server --model-path meta-llama/Meta-Llama-3.1-405B-Instruct --tp 16 --nccl-init-addr 172.16.4.52:20000 --nnodes 2 --node-rank 1 --disable-cuda-graph --mem-frac 0.75
414
+
415
+ # single node run 405B fp8
416
+ python -m sglang.launch_server --model-path meta-llama/Meta-Llama-3.1-405B-Instruct-FP8 --tp 8
417
+ ```
418
+
402
419
  ### Supported Models
403
420
 
404
421
  - Llama / Llama 2 / Llama 3 / Llama 3.1
@@ -656,15 +673,12 @@ for out in state.text_iter():
656
673
  - The `choices` argument in `sgl.gen` is implemented by computing the [token-length normalized log probabilities](https://blog.eleuther.ai/multiple-choice-normalization/) of all choices and selecting the one with the highest probability.
657
674
  - The `regex` argument in `sgl.gen` is implemented through autoregressive decoding with logit bias masking, according to the constraints set by the regex. It is compatible with `temperature=0` and `temperature != 0`.
658
675
 
659
- ## Benchmark And Performance
660
- - Llama-7B on NVIDIA A10G, FP16, Tensor Parallelism=1
661
- ![llama_7b](assets/llama_7b.jpg)
662
676
 
663
- - Mixtral-8x7B on NVIDIA A10G, FP16, Tensor Parallelism=8
664
- ![mixtral_8x7b](assets/mixtral_8x7b.jpg)
677
+ ## Benchmark And Performance
678
+ ![8b_throughput](https://lmsys.org/images/blog/sglang_llama3/8b_throughput.svg)
679
+ ![70b_fp8_throughput](https://lmsys.org/images/blog/sglang_llama3/70b_fp8_throughput.svg)
665
680
 
666
- - Learn more about the above [results](docs/benchmark_results.md).
667
- - Synthetic latency and throughput benchmark [scripts](https://github.com/sgl-project/sglang/tree/main/benchmark/latency_throughput).
681
+ Learn more at this [blog](https://lmsys.org/blog/2024-07-25-sglang-llama3/).
668
682
 
669
683
  ## Roadmap
670
684
  [Development Roadmap (2024 Q3)](https://github.com/sgl-project/sglang/issues/634)
@@ -1,13 +1,13 @@
1
1
  sglang/__init__.py,sha256=UV7VlXhXrwi00Zg45iNB9KcnmrwLjdMtjMz06AiafY0,1151
2
2
  sglang/api.py,sha256=1JARbc1wNYF6tODdUpgmNgTyLOvMnxdTBctLvEwzGTY,5565
3
3
  sglang/bench_latency.py,sha256=UPy6WhrddMTDX7HqIeHNhCn5vF0YMOKxJlQRvhMC8zU,10552
4
- sglang/bench_serving.py,sha256=zKGgVX3S-ggUvOxvEM4AszzXRPRVU6NGNnBG5vAAvRY,34577
4
+ sglang/bench_serving.py,sha256=UWhTENnoATPJo3nk59Ktr73CwZgiY_MGaRY6TQk0ozI,34584
5
5
  sglang/check_env.py,sha256=CscuPMlf68dkgZf0m-FiLpUisNNDoihMck4qhLOeV1Q,4124
6
- sglang/global_config.py,sha256=QG-ABVJksKK_llvUx7fSZcmK4GGCs-hBUVcM4LCr7Nw,1749
6
+ sglang/global_config.py,sha256=CyhGL7PE-KlMcg7IHWykzImU1y4NQlpeIlh9lHA77uo,1749
7
7
  sglang/launch_server.py,sha256=Gg8CwNlTCCfg1dF65ZT9ePLxOT9LKtY79GhIPG6PCrU,358
8
8
  sglang/launch_server_llavavid.py,sha256=40uaazMsavKuk6YXFa5v37kdUpFGuealgJJeph1g8gU,1025
9
9
  sglang/utils.py,sha256=arJuwOAEX445M2NL9SAOi6jBNu0-cfU04PLAr-hIH3U,8168
10
- sglang/version.py,sha256=Zn1KFblwuFHiDRdRAiRnDBRkbPttWh44jKa5zG2ov0E,22
10
+ sglang/version.py,sha256=m6kyaNpwBcP1XYcqrelX2oS3PJuOnElOcRdBa9pEb8c,22
11
11
  sglang/lang/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
12
  sglang/lang/chat_template.py,sha256=psIlhaDo70twgLrx5Lgln03metLEA3-FZuixeI0Y7Ao,13309
13
13
  sglang/lang/compiler.py,sha256=UiXUmPR9wBAPtnORrLcyQX8Uh0ZL0nKeV8ZgBozAJPw,7531
@@ -30,7 +30,7 @@ sglang/srt/model_config.py,sha256=lZu1D-XLVMETHS6FBMoPn8Uowa9QFGe95d3SuWrr2q8,52
30
30
  sglang/srt/sampling_params.py,sha256=OI11asr1Bd_E5soDjih614v4flgWxdMZU9HAF0aBafQ,3062
31
31
  sglang/srt/server.py,sha256=IUed6vnXCx7-xbrpEMAaJZ_aa4UubPAQ5pXvcv-xNoY,14607
32
32
  sglang/srt/server_args.py,sha256=aF6L35mEB-FU3BL_ooKuCIcOXLhYLxA9-MjpaOTQRCo,13189
33
- sglang/srt/utils.py,sha256=DZtYSTvtSf_HWZjKZyo8TFiXahz-JfeujJcKBuBkhpQ,22318
33
+ sglang/srt/utils.py,sha256=HvKkGbut8sOxMpGIzYsJ9NEZJg48LOnxyGESaGZmANs,22385
34
34
  sglang/srt/constrained/__init__.py,sha256=5LB3_mDTMW6wcRkFA5J2Rd5HPHHEKRyiELhe4gtlBYM,1472
35
35
  sglang/srt/constrained/base_cache.py,sha256=QQjmFEiT8jlOskJoZobhrDl2TKB-B4b1LPQo9JQCP_w,1405
36
36
  sglang/srt/constrained/fsm_cache.py,sha256=P4qNDHHxpKpTnYL_8V1R6OFXlUwbM6ZcBdzddpcBgb4,1135
@@ -45,13 +45,13 @@ sglang/srt/layers/token_attention.py,sha256=EJ4gjbVLfshOZ_vr1iB-Eq8_B-4F26n_wPDj
45
45
  sglang/srt/layers/quantization/__init__.py,sha256=PQFzdPpul98DvywBA6YMBOnrMjtHE1LMlMpJ7FM8J3I,1971
46
46
  sglang/srt/layers/quantization/fp8.py,sha256=jaqgRFnHC--IL8iqB6Qygi-KXYPYBKKqt_j4Rk55_h4,24946
47
47
  sglang/srt/managers/detokenizer_manager.py,sha256=8rN2cdMr61LWy07lingEqLnNy0W5Rebdn14IsTQ9PCs,5049
48
- sglang/srt/managers/io_struct.py,sha256=Y6jW3p0cNg0jcrEQNki1H8MMEWxwWA4p6Y-xVgUVWaI,5404
48
+ sglang/srt/managers/io_struct.py,sha256=VHy9wdZ3sfZA7fS6iq8lqbxdHL5WkBZNqxpacyZ8_8c,5483
49
49
  sglang/srt/managers/tokenizer_manager.py,sha256=SbivhFhZUR9HU9pLTe93MlYprAFAHzOU3KMBA2piQUk,19308
50
50
  sglang/srt/managers/controller/cuda_graph_runner.py,sha256=0aRqA1_34oJ557Zn8PjpJecex5bBWJdnCmBlcDVvYO0,8509
51
51
  sglang/srt/managers/controller/infer_batch.py,sha256=SKwCwhnZ_CNlG0mVCEc4X0e4HNjJFke-c8zdWP3TzjQ,34186
52
52
  sglang/srt/managers/controller/manager_multi.py,sha256=DT8Y9RF5OyTxlrLEZYz4claNWir3UrVztdOZaVPiA6g,6077
53
53
  sglang/srt/managers/controller/manager_single.py,sha256=2xO_iWK6tWvc0B31nKbe2N3klxwQBJmPTnFhNjzhVSI,4566
54
- sglang/srt/managers/controller/model_runner.py,sha256=WzbyGkMnULuDkZ_SUe-UfOH2OZEQ-IE8aYYdQacy7fM,14349
54
+ sglang/srt/managers/controller/model_runner.py,sha256=4-nBd9_MgIlamjEdLZDepBEykYNR8nL-65Sf1EYsnx0,14371
55
55
  sglang/srt/managers/controller/radix_cache.py,sha256=tx8LEQpqLxipw9UUVj4D1YQLMMDmWnjDYv8oDlOl-co,8210
56
56
  sglang/srt/managers/controller/schedule_heuristic.py,sha256=SQAGzPS3aB_TPj7rnPBhewwyR6W1sVwW4D3zG3JUY00,2714
57
57
  sglang/srt/managers/controller/tp_worker.py,sha256=yjz-Xzl0zEy4QSU-EYneZH5vi3oHtBuXTtYe4VuDp2g,30517
@@ -79,14 +79,14 @@ sglang/srt/models/qwen2.py,sha256=87Tt1Bti-Py3AGudcf7k5ni-OHhtDKPj_Hke44YGw4U,11
79
79
  sglang/srt/models/qwen2_moe.py,sha256=oHNoo45myV5kitkls2GWVzuGt1Q4pRHN2nLlXEltFI8,17581
80
80
  sglang/srt/models/stablelm.py,sha256=Z_XCDSHY_QMz3lZwwkZdIZjEOizZjLYJU9GDi8o08qQ,10802
81
81
  sglang/srt/models/yivl.py,sha256=55KPrQ-dVplI0hh2WCSugjc1luE0J2UAafjZxu_7Xuc,4367
82
- sglang/srt/openai_api/adapter.py,sha256=eirFYVGIp5D-UrQLqW5dRJOQYKmzF9nmgCzFeUOb2z8,15737
82
+ sglang/srt/openai_api/adapter.py,sha256=A0IG9ZKEMkkYCsLrVEspnVWzZHBUbc1vHv747LrF8ew,15920
83
83
  sglang/srt/openai_api/protocol.py,sha256=j7ifIR2SFQxTwaHAd9ksM096vfffcNltzTH4sg7H0RA,5739
84
84
  sglang/test/test_conversation.py,sha256=gF_AyOxQgpPQBPnA57-kq-M0p_zFu-rBDMFgAq655Rw,1596
85
85
  sglang/test/test_openai_protocol.py,sha256=DVx3r6hrb8oRqbo5AYIleldxbqMBTtb-gtORM6t_Y1c,1661
86
86
  sglang/test/test_programs.py,sha256=uefeHUFKT2NJESOujj-CsnPXdw1aQQN2TzUbPCHJjGs,13654
87
87
  sglang/test/test_utils.py,sha256=kD_fQe3WroZ9Kc3NBRKPiZOFJ_JD2uEE9XIvPp6AD9Y,11048
88
- sglang-0.2.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
89
- sglang-0.2.0.dist-info/METADATA,sha256=mk2lWkWZKtTJFXM7e_z2dMdke8WiV67X9aL48lGLRaw,30791
90
- sglang-0.2.0.dist-info/WHEEL,sha256=Wyh-_nZ0DJYolHNn1_hMa4lM7uDedD_RGVwbmTjyItk,91
91
- sglang-0.2.0.dist-info/top_level.txt,sha256=yxhh3pYQkcnA7v3Bg889C2jZhvtJdEincysO7PEB09M,7
92
- sglang-0.2.0.dist-info/RECORD,,
88
+ sglang-0.2.2.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
89
+ sglang-0.2.2.dist-info/METADATA,sha256=8YOVZHxqbQWNbzcsnysHokQdCWobAjoXD6YW-93pwlg,31706
90
+ sglang-0.2.2.dist-info/WHEEL,sha256=Wyh-_nZ0DJYolHNn1_hMa4lM7uDedD_RGVwbmTjyItk,91
91
+ sglang-0.2.2.dist-info/top_level.txt,sha256=yxhh3pYQkcnA7v3Bg889C2jZhvtJdEincysO7PEB09M,7
92
+ sglang-0.2.2.dist-info/RECORD,,
File without changes