sglang 0.2.5__py3-none-any.whl → 0.2.7__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.
Files changed (81) hide show
  1. sglang/__init__.py +33 -26
  2. sglang/api.py +9 -1
  3. sglang/bench_latency.py +2 -2
  4. sglang/bench_serving.py +10 -1
  5. sglang/check_env.py +1 -1
  6. sglang/lang/backend/litellm.py +1 -1
  7. sglang/lang/backend/openai.py +1 -1
  8. sglang/lang/backend/runtime_endpoint.py +4 -4
  9. sglang/lang/interpreter.py +24 -9
  10. sglang/lang/ir.py +1 -1
  11. sglang/srt/constrained/__init__.py +15 -0
  12. sglang/srt/constrained/base_cache.py +15 -0
  13. sglang/srt/constrained/fsm_cache.py +36 -1
  14. sglang/srt/constrained/jump_forward.py +15 -0
  15. sglang/srt/conversation.py +26 -0
  16. sglang/srt/hf_transformers_utils.py +18 -1
  17. sglang/srt/layers/context_flashattention_nopad.py +15 -0
  18. sglang/srt/layers/extend_attention.py +15 -0
  19. sglang/srt/layers/fused_moe.py +15 -0
  20. sglang/srt/layers/linear.py +15 -0
  21. sglang/srt/layers/logits_processor.py +109 -72
  22. sglang/srt/layers/quantization/__init__.py +15 -0
  23. sglang/srt/layers/quantization/fp8.py +15 -0
  24. sglang/srt/layers/radix_attention.py +21 -3
  25. sglang/srt/layers/token_attention.py +16 -1
  26. sglang/srt/managers/{controller/manager_multi.py → controller_multi.py} +17 -2
  27. sglang/srt/managers/{controller/manager_single.py → controller_single.py} +17 -2
  28. sglang/srt/managers/detokenizer_manager.py +16 -1
  29. sglang/srt/managers/io_struct.py +38 -5
  30. sglang/srt/managers/{controller/schedule_heuristic.py → policy_scheduler.py} +37 -22
  31. sglang/srt/managers/{controller/infer_batch.py → schedule_batch.py} +85 -25
  32. sglang/srt/managers/tokenizer_manager.py +99 -57
  33. sglang/srt/managers/{controller/tp_worker.py → tp_worker.py} +177 -81
  34. sglang/srt/mem_cache/flush_cache.py +33 -0
  35. sglang/srt/{memory_pool.py → mem_cache/memory_pool.py} +16 -1
  36. sglang/srt/{managers/controller → mem_cache}/radix_cache.py +15 -0
  37. sglang/srt/mm_utils.py +15 -0
  38. sglang/srt/model_config.py +20 -0
  39. sglang/srt/{managers/controller → model_executor}/cuda_graph_runner.py +42 -18
  40. sglang/srt/{managers/controller → model_executor}/model_runner.py +51 -16
  41. sglang/srt/model_loader/model_loader.py +15 -0
  42. sglang/srt/model_loader/utils.py +16 -1
  43. sglang/srt/models/chatglm.py +16 -1
  44. sglang/srt/models/commandr.py +16 -1
  45. sglang/srt/models/dbrx.py +16 -1
  46. sglang/srt/models/deepseek.py +16 -1
  47. sglang/srt/models/deepseek_v2.py +532 -0
  48. sglang/srt/models/gemma.py +16 -1
  49. sglang/srt/models/gemma2.py +16 -1
  50. sglang/srt/models/gpt_bigcode.py +16 -1
  51. sglang/srt/models/grok.py +16 -1
  52. sglang/srt/models/internlm2.py +16 -1
  53. sglang/srt/models/llama2.py +16 -1
  54. sglang/srt/models/llama_classification.py +19 -4
  55. sglang/srt/models/llava.py +17 -2
  56. sglang/srt/models/llavavid.py +17 -2
  57. sglang/srt/models/minicpm.py +16 -1
  58. sglang/srt/models/mistral.py +15 -0
  59. sglang/srt/models/mixtral.py +16 -1
  60. sglang/srt/models/mixtral_quant.py +16 -1
  61. sglang/srt/models/qwen.py +16 -1
  62. sglang/srt/models/qwen2.py +16 -1
  63. sglang/srt/models/qwen2_moe.py +16 -1
  64. sglang/srt/models/stablelm.py +16 -1
  65. sglang/srt/models/yivl.py +15 -0
  66. sglang/srt/openai_api/adapter.py +545 -160
  67. sglang/srt/openai_api/protocol.py +65 -1
  68. sglang/srt/sampling_params.py +20 -4
  69. sglang/srt/server.py +90 -37
  70. sglang/srt/server_args.py +76 -17
  71. sglang/srt/utils.py +15 -0
  72. sglang/test/test_programs.py +5 -1
  73. sglang/utils.py +22 -0
  74. sglang/version.py +1 -1
  75. {sglang-0.2.5.dist-info → sglang-0.2.7.dist-info}/METADATA +40 -12
  76. sglang-0.2.7.dist-info/RECORD +93 -0
  77. {sglang-0.2.5.dist-info → sglang-0.2.7.dist-info}/WHEEL +1 -1
  78. sglang/srt/flush_cache.py +0 -18
  79. sglang-0.2.5.dist-info/RECORD +0 -92
  80. {sglang-0.2.5.dist-info → sglang-0.2.7.dist-info}/LICENSE +0 -0
  81. {sglang-0.2.5.dist-info → sglang-0.2.7.dist-info}/top_level.txt +0 -0
sglang/__init__.py CHANGED
@@ -1,4 +1,5 @@
1
1
  # SGL API Components
2
+
2
3
  from sglang.api import (
3
4
  Runtime,
4
5
  assistant,
@@ -14,48 +15,54 @@ from sglang.api import (
14
15
  select,
15
16
  set_default_backend,
16
17
  system,
18
+ system_begin,
19
+ system_end,
17
20
  user,
18
21
  user_begin,
19
22
  user_end,
20
23
  video,
21
24
  )
22
25
 
23
- # Global Configurations
24
- from sglang.global_config import global_config
25
-
26
- # SGL Backends
27
- from sglang.lang.backend.anthropic import Anthropic
28
- from sglang.lang.backend.litellm import LiteLLM
29
- from sglang.lang.backend.openai import OpenAI
30
- from sglang.lang.backend.runtime_endpoint import RuntimeEndpoint
31
- from sglang.lang.backend.vertexai import VertexAI
32
-
33
- from .version import __version__
34
-
35
- # public APIs management
26
+ # SGLang DSL APIs
36
27
  __all__ = [
37
- "global_config",
38
- "Anthropic",
39
- "LiteLLM",
40
- "OpenAI",
41
- "RuntimeEndpoint",
42
- "VertexAI",
43
- "function",
44
28
  "Runtime",
45
- "set_default_backend",
29
+ "assistant",
30
+ "assistant_begin",
31
+ "assistant_end",
46
32
  "flush_cache",
47
- "get_server_args",
33
+ "function",
48
34
  "gen",
49
35
  "gen_int",
50
36
  "gen_string",
37
+ "get_server_args",
51
38
  "image",
52
- "video",
53
39
  "select",
40
+ "set_default_backend",
54
41
  "system",
42
+ "system_begin",
43
+ "system_end",
55
44
  "user",
56
- "assistant",
57
45
  "user_begin",
58
46
  "user_end",
59
- "assistant_begin",
60
- "assistant_end",
47
+ "video",
61
48
  ]
49
+
50
+ # Global Configurations
51
+ from sglang.global_config import global_config
52
+
53
+ __all__ += ["global_config"]
54
+
55
+ from sglang.version import __version__
56
+
57
+ __all__ += ["__version__"]
58
+
59
+ # SGL Backends
60
+ from sglang.lang.backend.runtime_endpoint import RuntimeEndpoint
61
+ from sglang.utils import LazyImport
62
+
63
+ Anthropic = LazyImport("sglang.lang.backend.anthropic", "Anthropic")
64
+ LiteLLM = LazyImport("sglang.lang.backend.litellm", "LiteLLM")
65
+ OpenAI = LazyImport("sglang.lang.backend.openai", "OpenAI")
66
+ VertexAI = LazyImport("sglang.lang.backend.vertexai", "VertexAI")
67
+
68
+ __all__ += ["Anthropic", "LiteLLM", "OpenAI", "VertexAI", "RuntimeEndpoint"]
sglang/api.py CHANGED
@@ -75,7 +75,7 @@ def gen(
75
75
  choices: Optional[List[str]] = None,
76
76
  regex: Optional[str] = None,
77
77
  ):
78
- """Call the model to generate. See the meaning of the arguments in docs/sampling_params.md"""
78
+ """Call the model to generate. See the meaning of the arguments in docs/en/sampling_params.md"""
79
79
 
80
80
  if choices:
81
81
  return SglSelect(name, choices, 0.0 if temperature is None else temperature)
@@ -210,6 +210,14 @@ def assistant(expr: Optional[SglExpr] = None):
210
210
  return _role_common("assistant", expr)
211
211
 
212
212
 
213
+ def system_begin():
214
+ return SglRoleBegin("system")
215
+
216
+
217
+ def system_end():
218
+ return SglRoleEnd("system")
219
+
220
+
213
221
  def user_begin():
214
222
  return SglRoleBegin("user")
215
223
 
sglang/bench_latency.py CHANGED
@@ -37,9 +37,9 @@ import torch
37
37
  import torch.distributed as dist
38
38
 
39
39
  from sglang.srt.hf_transformers_utils import get_tokenizer
40
- from sglang.srt.managers.controller.infer_batch import Batch, ForwardMode, Req
41
- from sglang.srt.managers.controller.model_runner import ModelRunner
40
+ from sglang.srt.managers.schedule_batch import Batch, ForwardMode, Req
42
41
  from sglang.srt.model_config import ModelConfig
42
+ from sglang.srt.model_executor.model_runner import ModelRunner
43
43
  from sglang.srt.sampling_params import SamplingParams
44
44
  from sglang.srt.server_args import ServerArgs
45
45
  from sglang.srt.utils import suppress_other_loggers
sglang/bench_serving.py CHANGED
@@ -1,5 +1,6 @@
1
1
  # Adapted from https://github.com/vllm-project/vllm/blob/6366efc67b0aedd2c1721c14385370e50b297fb3/benchmarks/backend_request_func.py
2
2
  # Adapted from https://github.com/vllm-project/vllm/blob/6366efc67b0aedd2c1721c14385370e50b297fb3/benchmarks/benchmark_serving.py
3
+
3
4
  """
4
5
  Benchmark online serving.
5
6
 
@@ -84,6 +85,9 @@ async def async_request_trt_llm(
84
85
  "min_length": request_func_input.output_len,
85
86
  "end_id": 1048576,
86
87
  }
88
+ if args.disable_ignore_eos:
89
+ del payload["min_length"]
90
+ del payload["end_id"]
87
91
  output = RequestFuncOutput()
88
92
  output.prompt_len = request_func_input.prompt_len
89
93
 
@@ -149,7 +153,7 @@ async def async_request_openai_completions(
149
153
  "best_of": 1,
150
154
  "max_tokens": request_func_input.output_len,
151
155
  "stream": not args.disable_stream,
152
- "ignore_eos": True,
156
+ "ignore_eos": not args.disable_ignore_eos,
153
157
  }
154
158
  headers = {"Authorization": f"Bearer {os.environ.get('OPENAI_API_KEY')}"}
155
159
 
@@ -969,6 +973,11 @@ if __name__ == "__main__":
969
973
  action="store_true",
970
974
  help="Disable streaming mode.",
971
975
  )
976
+ parser.add_argument(
977
+ "--disable-ignore-eos",
978
+ action="store_true",
979
+ help="Disable ignoring EOS.",
980
+ )
972
981
 
973
982
  set_ulimit()
974
983
 
sglang/check_env.py CHANGED
@@ -22,7 +22,7 @@ PACKAGE_LIST = [
22
22
  "huggingface_hub",
23
23
  "interegular",
24
24
  "packaging",
25
- "pillow",
25
+ "PIL",
26
26
  "psutil",
27
27
  "pydantic",
28
28
  "uvicorn",
@@ -61,7 +61,7 @@ class LiteLLM(BaseBackend):
61
61
  model=self.model_name,
62
62
  messages=messages,
63
63
  **self.client_params,
64
- **sampling_params.to_anthropic_kwargs(),
64
+ **sampling_params.to_litellm_kwargs(),
65
65
  )
66
66
  comp = ret.choices[0].message.content
67
67
 
@@ -18,7 +18,7 @@ except ImportError as e:
18
18
  openai = tiktoken = e
19
19
 
20
20
 
21
- logger = logging.getLogger("openai")
21
+ logger = logging.getLogger(__name__)
22
22
 
23
23
 
24
24
  def create_logit_bias_int(tokenizer):
@@ -253,14 +253,14 @@ class RuntimeEndpoint(BaseBackend):
253
253
  r["meta_info"]["normalized_prompt_logprob"] for r in obj
254
254
  ]
255
255
  decision = choices[np.argmax(normalized_prompt_logprobs)]
256
- prefill_token_logprobs = [r["meta_info"]["prefill_token_logprobs"] for r in obj]
257
- decode_token_logprobs = [r["meta_info"]["decode_token_logprobs"] for r in obj]
256
+ input_token_logprobs = [r["meta_info"]["input_token_logprobs"] for r in obj]
257
+ output_token_logprobs = [r["meta_info"]["output_token_logprobs"] for r in obj]
258
258
 
259
259
  return (
260
260
  decision,
261
261
  normalized_prompt_logprobs,
262
- prefill_token_logprobs,
263
- decode_token_logprobs,
262
+ input_token_logprobs,
263
+ output_token_logprobs,
264
264
  )
265
265
 
266
266
  def concatenate_and_append(self, src_rids: List[str], dst_rid: str):
@@ -541,18 +541,19 @@ class StreamExecutor:
541
541
  (
542
542
  decision,
543
543
  normalized_prompt_logprobs,
544
- prefill_token_logprobs,
545
- decode_token_logprobs,
544
+ input_token_logprobs,
545
+ output_token_logprobs,
546
546
  ) = self.backend.select(self, expr.choices, expr.temperature)
547
547
  if expr.name is not None:
548
548
  name = expr.name
549
549
  self.variables[name] = decision
550
550
  self.meta_info[name] = {
551
551
  "normalized_prompt_logprobs": normalized_prompt_logprobs,
552
- "prefill_token_logprobs": prefill_token_logprobs,
553
- "decode_token_logprobs": decode_token_logprobs,
552
+ "input_token_logprobs": input_token_logprobs,
553
+ "output_token_logprobs": output_token_logprobs,
554
554
  }
555
555
  self.variable_event[name].set()
556
+ self.stream_var_event[name].set()
556
557
  self.text_ += decision
557
558
 
558
559
  def _execute_variable(self, expr: SglVariable):
@@ -705,9 +706,9 @@ class ProgramState:
705
706
 
706
707
  def _role_common(self, name: str, expr: Optional[SglExpr] = None):
707
708
  if expr is not None:
708
- self.stream_executor.submit(
709
- SglExprList([SglRoleBegin(name), expr, SglRoleEnd(name)])
710
- )
709
+ role_expr = SglExprList([SglRoleBegin(name), expr, SglRoleEnd(name)])
710
+ self.stream_executor.submit(role_expr)
711
+ return role_expr
711
712
  else:
712
713
 
713
714
  @contextmanager
@@ -778,7 +779,14 @@ class ProgramState:
778
779
  if self.stream_executor.is_finished:
779
780
  break
780
781
  else:
781
- event = self.stream_executor.stream_var_event[var_name]
782
+ event = None
783
+ while not event:
784
+ if var_name in self.stream_executor.stream_var_event:
785
+ event = self.stream_executor.stream_var_event[var_name]
786
+ if self.stream_executor.is_finished:
787
+ yield ""
788
+ return
789
+
782
790
  while True:
783
791
  event.wait()
784
792
  event.clear()
@@ -813,7 +821,14 @@ class ProgramState:
813
821
  if self.stream_executor.is_finished:
814
822
  break
815
823
  else:
816
- event = self.stream_executor.stream_var_event[var_name]
824
+ event = None
825
+ while not event:
826
+ if var_name in self.stream_executor.stream_var_event:
827
+ event = self.stream_executor.stream_var_event[var_name]
828
+ if self.stream_executor.is_finished:
829
+ yield ""
830
+ return
831
+
817
832
  while True:
818
833
  await loop.run_in_executor(None, event.wait)
819
834
  event.clear()
sglang/lang/ir.py CHANGED
@@ -410,7 +410,7 @@ class SglGen(SglExpr):
410
410
  dtype: Optional[type] = None,
411
411
  regex: Optional[str] = None,
412
412
  ):
413
- """Call the model to generate. See the meaning of the arguments in docs/sampling_params.md"""
413
+ """Call the model to generate. See the meaning of the arguments in docs/en/sampling_params.md"""
414
414
  super().__init__()
415
415
  self.name = name
416
416
  self.sampling_params = SglSamplingParams(
@@ -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
  import json
2
17
  from typing import Dict, Optional, Union
3
18
 
@@ -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
  """Base cache class."""
2
17
 
3
18
  import time
@@ -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
  """Cache for the compressed finite state machine."""
2
17
 
3
18
  from sglang.srt.constrained import RegexGuide, TransformerTokenizer
@@ -21,7 +36,27 @@ class FSMCache(BaseCache):
21
36
  tokenizer = AutoTokenizer.from_pretrained(
22
37
  tokenizer_path, **tokenizer_args_dict
23
38
  )
24
- self.outlines_tokenizer = TransformerTokenizer(tokenizer)
39
+ try:
40
+ self.outlines_tokenizer = TransformerTokenizer(tokenizer)
41
+ except AttributeError:
42
+ # FIXME: tmp fix for chatglm2 & chatglm3 (pad_token_id=0)
43
+ origin_pad_token_id = tokenizer.pad_token_id
44
+
45
+ def fset(self, value):
46
+ self._value = value
47
+
48
+ type(tokenizer).pad_token_id = property(
49
+ fget=type(tokenizer).pad_token_id.fget, fset=fset
50
+ )
51
+ self.outlines_tokenizer = TransformerTokenizer(tokenizer)
52
+ self.outlines_tokenizer.tokenizer.pad_token_id = origin_pad_token_id
53
+ self.outlines_tokenizer.pad_token_id = origin_pad_token_id
54
+ self.outlines_tokenizer.pad_token = (
55
+ self.outlines_tokenizer.tokenizer.pad_token
56
+ )
57
+ self.outlines_tokenizer.vocabulary = (
58
+ self.outlines_tokenizer.tokenizer.get_vocab()
59
+ )
25
60
  else:
26
61
  self.outlines_tokenizer = TransformerTokenizer(
27
62
  tokenizer_path, **tokenizer_args_dict
@@ -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
  """
2
17
  Faster constrained decoding.
3
18
  Reference: https://lmsys.org/blog/2024-02-05-compressed-fsm/
@@ -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
  """Conversation templates."""
2
17
 
3
18
  # Adapted from
@@ -421,3 +436,14 @@ register_conv_template(
421
436
  sep2="</s>",
422
437
  )
423
438
  )
439
+
440
+ # Reference: https://github.com/InternLM/lmdeploy/blob/387bf54b4f124e72aab30ae9755f562e435d3d01/lmdeploy/model.py#L425-L442
441
+ register_conv_template(
442
+ Conversation(
443
+ name="internlm2-chat",
444
+ system_template="<|im_start|>system\n{system_message}",
445
+ roles=("<|im_start|>user", "<|im_start|>assistant"),
446
+ sep="\n",
447
+ stop_str=["<|im_end|>", "<|action_end|>"],
448
+ )
449
+ )
@@ -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
  """Utilities for Huggingface Transformers."""
2
17
 
3
18
  import functools
@@ -73,7 +88,9 @@ def get_context_length(config):
73
88
  rope_scaling = getattr(config, "rope_scaling", None)
74
89
  if rope_scaling:
75
90
  rope_scaling_factor = config.rope_scaling["factor"]
76
- if config.rope_scaling["rope_type"] == "llama3":
91
+ if "original_max_position_embeddings" in rope_scaling:
92
+ rope_scaling_factor = 1
93
+ if config.rope_scaling.get("rope_type", None) == "llama3":
77
94
  rope_scaling_factor = 1
78
95
  else:
79
96
  rope_scaling_factor = 1
@@ -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/ModelTC/lightllm/blob/f2a54f0912293f683bf1d1695fd12c4098a5bf82/lightllm/models/llama/triton_kernel/context_flashattention_nopad.py#L1
3
18
  import torch
@@ -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
  import torch
2
17
  import triton
3
18
  import triton.language as tl
@@ -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/layers/fused_moe/fused_moe.py#L1
3
18
  """Fused MoE kernel."""
@@ -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/e76466dde2bc9525d55165ceaa600d298c7bf773/vllm/model_executor/layers/linear.py
2
17
  # FIXME: refactor the linear abstraction
3
18
  from abc import abstractmethod