repo
stringclasses
454 values
file_path
stringlengths
5
201
extension
stringclasses
1 value
content
stringlengths
8
509k
num_lines
int64
3
16.9k
size_bytes
int64
8
511k
sglang
python/sglang/srt/model_executor/runner_utils/pool.py
.py
# Copyright 2023-2026 SGLang Team # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writin...
41
1,568
sglang
python/sglang/srt/model_executor/runner_utils/shared_read_event.py
.py
"""Shared-read-done event utilities for CUDA graph runners.""" import logging from typing import Optional import torch from sglang.srt.environ import envs from sglang.srt.layers.attention.base_attn_backend import SharedReadBoundary from sglang.srt.model_executor.forward_batch_info import ForwardMode from sglang.srt....
51
1,666
sglang
python/sglang/srt/model_executor/model_runner_components/load_model_utils.py
.py
from __future__ import annotations import datetime import logging import os import socket import threading from typing import TYPE_CHECKING, Any, Optional import msgspec import torch import torch.distributed as dist from sglang.srt.configs.device_config import DeviceConfig from sglang.srt.configs.load_config import ...
365
14,370
sglang
python/sglang/srt/model_executor/model_runner_components/cuda_graph_setup.py
.py
from __future__ import annotations import logging import time from collections import defaultdict from typing import TYPE_CHECKING, Optional import msgspec from sglang.srt.configs.model_config import ModelImpl from sglang.srt.distributed import get_world_group from sglang.srt.distributed.device_communicators.pynccl_...
492
19,013
sglang
python/sglang/srt/model_executor/model_runner_components/ngram_embedding_manager.py
.py
"""Utilities for updating LongCat ngram embedding token tables.""" from __future__ import annotations from dataclasses import dataclass from typing import TYPE_CHECKING, Optional import torch from sglang.kernels.ops.speculative.ngram_embedding import update_token_table from sglang.srt.configs.model_config import Mo...
195
7,669
sglang
python/sglang/srt/model_executor/model_runner_components/weight_exporter.py
.py
from __future__ import annotations import logging from dataclasses import dataclass, field from typing import Any, Callable, Optional import torch import torch.distributed as dist from sglang.srt.platforms import current_platform from sglang.srt.utils import init_custom_process_group from sglang.srt.utils.network im...
158
5,675
sglang
python/sglang/srt/model_executor/model_runner_components/moe_ep_setup.py
.py
from __future__ import annotations import logging from typing import TYPE_CHECKING from sglang.srt.environ import envs from sglang.srt.eplb.expert_location import get_global_expert_location_metadata from sglang.srt.eplb.lplb_solver import ( LPLBSolver, assert_lplb_supported_model, clear_global_lplb_solver...
150
5,628
sglang
python/sglang/srt/model_executor/model_runner_components/kv_pool_runtime.py
.py
from __future__ import annotations import logging from typing import TYPE_CHECKING, Optional import msgspec import torch from sglang.srt.configs.hybrid_arch import mambaish_config from sglang.srt.distributed import get_world_group from sglang.srt.mem_cache.kv_cache_configurator import mm_runtime_reservation_gb from ...
141
5,555
sglang
python/sglang/srt/model_executor/model_runner_components/startup_weight_load.py
.py
from __future__ import annotations import dataclasses import enum import logging import time from typing import TYPE_CHECKING, Optional, Tuple import torch from torch import nn from sglang.srt.configs.device_config import DeviceConfig from sglang.srt.configs.load_config import LoadConfig, LoadFormat from sglang.srt....
589
22,068
sglang
python/sglang/srt/model_executor/model_runner_components/layer_setup.py
.py
from __future__ import annotations from typing import TYPE_CHECKING, Any, NamedTuple import msgspec from torch import nn if TYPE_CHECKING: from sglang.srt.configs.model_config import ModelConfig from sglang.srt.speculative.spec_info import SpeculativeAlgorithm class AttentionAndMoeLayers(NamedTuple): a...
237
8,529
sglang
python/sglang/srt/model_executor/model_runner_components/misc_utils.py
.py
from __future__ import annotations import logging from typing import TYPE_CHECKING, Any, Optional from sglang.srt.configs.model_config import ( dsa_layer_skips_topk, is_deepseek_dsa, is_kimi_k3, ) from sglang.srt.runtime_context import ( attention_backends, get_context, get_schedule, ) from sg...
93
3,177
sglang
python/sglang/srt/model_executor/model_runner_components/weight_updater.py
.py
from __future__ import annotations import gc import logging from dataclasses import dataclass, field from typing import TYPE_CHECKING, Any, Callable, List, Optional, Tuple, Union import torch from sglang.srt.configs.load_config import LoadConfig from sglang.srt.model_loader.loader import DefaultModelLoader, get_mode...
431
16,696
sglang
python/sglang/srt/model_executor/model_runner_components/remote_instance_weight_transporter.py
.py
from __future__ import annotations import logging from dataclasses import dataclass from typing import Any, Callable, Optional import torch from sglang.srt.environ import envs from sglang.srt.model_loader.remote_instance_weight_loader_utils import ( RemoteInstanceWeightLoaderBackend, register_memory_region, ...
118
4,297
sglang
python/sglang/srt/model_executor/model_runner_components/spec_aux_hidden_state.py
.py
from __future__ import annotations import logging from typing import TYPE_CHECKING, Any, Optional import msgspec from sglang.srt.configs.model_config import ModelConfig if TYPE_CHECKING: from sglang.srt.server_args import ServerArgs from sglang.srt.speculative.spec_info import SpeculativeAlgorithm logger =...
224
8,339
sglang
python/sglang/srt/model_executor/model_runner_components/attention_backend_setup.py
.py
from __future__ import annotations import logging from typing import TYPE_CHECKING, Optional import msgspec from sglang.srt.distributed import get_world_group from sglang.srt.environ import envs from sglang.srt.layers.attention.attention_registry import ( ATTENTION_BACKENDS, attn_backend_wrapper, ) from sgla...
258
9,583
sglang
python/sglang/srt/model_loader/gguf_name_maps.py
.py
# Copyright 2023-2026 SGLang Team # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writin...
73
2,875
sglang
python/sglang/srt/model_loader/utils.py
.py
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project # Adapted from https://github.com/vllm-project/vllm/blob/v0.6.4.post1/vllm/model_executor/model_loader/utils.py """Utilities for selecting and loading models.""" import concurrent.futures import contextlib impor...
358
13,973
sglang
python/sglang/srt/model_loader/ci_weight_validation.py
.py
""" CI-specific weight validation and cache cleanup utilities. This module contains validation and cleanup logic that is ONLY used in CI environments. These functions handle: - Validating safetensors files for corruption - Checking for missing shards in sharded models - Cleaning up corrupted files (selective or full c...
1,192
43,682
sglang
python/sglang/srt/model_loader/auto_loader.py
.py
# Copyright 2023-2025 SGLang Team # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writin...
226
7,561
sglang
python/sglang/srt/model_loader/__init__.py
.py
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project # Adapted from https://github.com/vllm-project/vllm/blob/v0.6.4.post1/vllm/model_executor/model_loader/__init__.py from __future__ import annotations from typing import TYPE_CHECKING from torch import nn from ...
43
1,141
sglang
python/sglang/srt/model_loader/remote_instance_weight_loader_utils.py
.py
# SPDX-License-Identifier: Apache-2.0 import enum import importlib import importlib.util import logging import time from typing import List import requests logger = logging.getLogger(__name__) class RemoteInstanceWeightLoaderBackend(str, enum.Enum): NCCL = "nccl" TRANSFER_ENGINE = "transfer_engine" MOD...
195
7,221
sglang
python/sglang/srt/model_loader/loader.py
.py
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project # Adapted from https://github.com/vllm-project/vllm/blob/v0.6.3.post1/vllm/model_executor/model_loader/loader.py from __future__ import annotations # ruff: noqa: SIM117 import collections import concurrent.futur...
4,415
174,926
sglang
python/sglang/srt/model_loader/weight_utils.py
.py
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project # Adapted from https://github.com/vllm-project/vllm/blob/v0.6.4.post1/vllm/model_executor/model_loader/weight_utils.py """Utilities for downloading and initializing model weights.""" import collections import co...
1,973
75,116
sglang
python/sglang/srt/state_capturer/indexer_topk.py
.py
import logging from typing import Optional import numpy as np import pybase64 import torch from sglang.srt.configs.model_config import ModelConfig, get_num_indexer_layers from sglang.srt.runtime_context import get_exec, get_parallel, get_schedule from sglang.srt.state_capturer.base import BaseTopkCapturer logger = l...
134
4,297
sglang
python/sglang/srt/state_capturer/routed_experts.py
.py
from typing import Any, Optional import numpy as np import pybase64 import torch from sglang.srt.configs.model_config import ModelConfig from sglang.srt.layers.dp_attention import ( attn_tp_all_gather_into_tensor, get_dp_local_slice_cpu, is_dp_attention_enabled, ) from sglang.srt.layers.moe import get_moe...
172
6,676
sglang
python/sglang/srt/state_capturer/base.py
.py
import dataclasses import logging from typing import Optional import torch from sglang.srt.mem_cache.memory_pool import ReqToTokenPool from sglang.srt.model_executor.forward_batch_info import ForwardBatch logger = logging.getLogger(__name__) _GB = 1024 * 1024 * 1024 _MB = 1024 * 1024 def get_tensor_size_bytes(t: ...
188
6,187
sglang
python/sglang/srt/observability/trace.py
.py
# Copyright 2023-2024 SGLang Team # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writin...
860
28,544
sglang
python/sglang/srt/observability/utils.py
.py
# Copyright 2023-2025 SGLang Team # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writin...
57
1,904
sglang
python/sglang/srt/observability/forward_pass_metrics.py
.py
""" Forward pass metrics for per-iteration scheduler telemetry. Emits per-iteration scheduling metrics over ZMQ PUB so that external consumers can observe scheduler behavior in real time without polling Prometheus. Uses msgspec.Struct for zero-copy serialization. Data flow:: Scheduler process: Scheduler...
222
5,998
sglang
python/sglang/srt/observability/cpu_monitor.py
.py
import threading import time import psutil def start_cpu_monitor_thread(component: str, interval: float = 5.0) -> threading.Thread: from prometheus_client import Counter cpu_seconds_total = Counter( name="sglang:process_cpu_seconds_total", documentation="Total CPU time consumed by this proce...
32
891
sglang
python/sglang/srt/observability/req_time_stats.py
.py
# Copyright 2023-2024 SGLang Team # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writin...
1,283
46,657
sglang
python/sglang/srt/observability/ray_wrappers.py
.py
# Copyright 2023-2024 SGLang Team # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writin...
309
11,137
sglang
python/sglang/srt/observability/mooncake_trace.py
.py
import time from typing import Union from sglang.srt.observability.req_time_stats import ( RequestStageConfig, convert_time_to_realtime_ns, ) from sglang.srt.observability.trace import TraceNullContext, TraceReqContext class MooncakeRequestStage: MOONCAKE_SEND = RequestStageConfig( "mooncake_send...
69
1,838
sglang
python/sglang/srt/observability/trace_async.py
.py
# Copyright 2023-2024 SGLang Team # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writin...
1,037
37,991
sglang
python/sglang/srt/observability/startup_time.py
.py
from __future__ import annotations from collections.abc import Iterable, Mapping from sglang.srt.model_executor.graph_memory_usage import ( empty_graph_time_usage, merge_graph_time_usage, ) def build_scheduler_startup_time( *, target_load_weight: float, draft_load_weight: float, kv_cache_all...
70
2,112
sglang
python/sglang/srt/observability/startup_func_log_and_timer.py
.py
""" Records startup latency breakdown by context using gauge metrics in seconds """ import logging import time from contextlib import contextmanager from functools import wraps from typing import Any, Callable, Dict, Generator, Optional logger = logging.getLogger(__name__) enable_startup_metrics = False STARTUP_LATE...
151
4,937
sglang
python/sglang/srt/observability/request_metrics_exporter.py
.py
import asyncio import dataclasses import json import logging import os from abc import ABC, abstractmethod from datetime import datetime from typing import List, Optional, Union from sglang.srt.constants import HEALTH_CHECK_RID_PREFIX from sglang.srt.managers.io_struct import EmbeddingReqInput, GenerateReqInput from s...
221
8,363
sglang
python/sglang/srt/observability/label_transform.py
.py
from typing import Optional _PRIORITY_MIN = 0 _PRIORITY_MAX = 31 _LOW_PRIORITY_VALUE = "LOW" _HIGH_PRIORITY_VALUE = "HIGH" UNKNOWN_PRIORITY_VALUE = "UNKNOWN" def transform_priority(priority: Optional[int]) -> str: """Transform the priority to a string for metrics reporting. Limit the range to prevent high c...
28
694
sglang
python/sglang/srt/observability/metrics_collector.py
.py
# Copyright 2023-2024 SGLang Team # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writin...
2,404
95,603
sglang
python/sglang/srt/observability/func_timer.py
.py
# Copyright 2023-2024 SGLang Team # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writin...
102
3,306
sglang
python/sglang/srt/dllm/config.py
.py
from typing import Any from sglang.srt.configs.model_config import ModelConfig from sglang.srt.server_args import ServerArgs class DllmConfig: def __init__( self, algorithm: str, algorithm_config: dict[str, Any], block_size: int, mask_id: int, max_running_requests:...
79
2,595
sglang
python/sglang/srt/dllm/algorithm/low_confidence.py
.py
from typing import Any, List import torch from sglang.srt.dllm.algorithm.base import DllmAlgorithm from sglang.srt.dllm.config import DllmConfig from sglang.srt.model_executor.forward_batch_info import ForwardBatch class LowConfidence(DllmAlgorithm): """Each step unmasks positions whose predicted-token confiden...
56
2,120
sglang
python/sglang/srt/dllm/algorithm/__init__.py
.py
import importlib import logging import pkgutil from sglang.srt.dllm.config import DllmConfig logger = logging.getLogger(__name__) def import_algorithms(): mapping = {} package_name = "sglang.srt.dllm.algorithm" package = importlib.import_module(package_name) for _, name, ispkg in pkgutil.iter_module...
40
1,001
sglang
python/sglang/srt/dllm/algorithm/joint_threshold.py
.py
from typing import Any, List import numpy as np import torch import torch.nn.functional as F from sglang.srt.dllm.algorithm.base import DllmAlgorithm from sglang.srt.dllm.config import DllmConfig from sglang.srt.model_executor.forward_batch_info import ForwardBatch from sglang.srt.utils import is_npu _is_npu = is_np...
319
11,828
sglang
python/sglang/srt/dllm/algorithm/base.py
.py
from __future__ import annotations from typing import Any, List, Optional, Tuple, Union import torch from sglang.srt.dllm.algorithm import get_algorithm from sglang.srt.dllm.config import DllmConfig from sglang.srt.layers.logits_processor import LogitsProcessorOutput from sglang.srt.model_executor.forward_batch_info...
140
5,129
sglang
python/sglang/srt/dllm/mixin/req.py
.py
from __future__ import annotations import enum from array import array from typing import TYPE_CHECKING, Optional from sglang.srt.dllm.config import DllmConfig if TYPE_CHECKING: from sglang.srt.managers.schedule_batch import Req class DllmReqPhase(str, enum.Enum): STAGING_PREFILL = "staging_prefill" ST...
94
3,288
sglang
python/sglang/srt/dllm/mixin/scheduler.py
.py
from __future__ import annotations import logging from array import array from typing import TYPE_CHECKING, List, Optional, Set, Union from sglang.srt.dllm.config import DllmConfig from sglang.srt.dllm.mixin.req import DllmReqPhase from sglang.srt.managers.schedule_batch import Req, ScheduleBatch from sglang.srt.mana...
444
17,002
sglang
python/sglang/srt/function_call/minimax_m2.py
.py
import json import logging import re from typing import Any, Dict, List, Tuple from sglang.srt.entrypoints.openai.protocol import Tool from sglang.srt.function_call.base_format_detector import BaseFormatDetector from sglang.srt.function_call.core_types import ( StreamingParseResult, ToolCallItem, _GetInfoF...
523
20,150
sglang
python/sglang/srt/function_call/base_format_detector.py
.py
import json import logging from abc import ABC, abstractmethod from typing import Any, Dict, List, Literal, Optional, Union import orjson from partial_json_parser.core.exceptions import MalformedJSON from partial_json_parser.core.options import Allow try: from xgrammar import StructuralTag, get_model_structural_t...
446
19,451
sglang
python/sglang/srt/function_call/gemma4_detector.py
.py
import json import logging from typing import List, Optional from sglang.srt.entrypoints.openai.protocol import Tool from sglang.srt.function_call.base_format_detector import BaseFormatDetector from sglang.srt.function_call.core_types import ( StreamingParseResult, ToolCallItem, _GetInfoFunc, ) logger = l...
446
15,969
sglang
python/sglang/srt/function_call/muse_glimmer_detector.py
.py
import json import logging import re from typing import Dict, List, Optional, Set from sglang.srt.entrypoints.openai.protocol import Tool from sglang.srt.environ import envs from sglang.srt.function_call.base_format_detector import BaseFormatDetector from sglang.srt.function_call.core_types import ( StreamingParse...
265
9,297
sglang
python/sglang/srt/function_call/muse_glimmer_format.py
.py
"""Muse Glimmer wire format, shared by its reasoning and function-call detectors.""" import re from typing import Sequence # Channel framing. MESSAGE = "<|message|>" EOM = "<|eom|>" EOT = "<|eot|>" START = "<|start|>" # ATEM payload markers. FUNCTION_CALLS_OPEN = "<atem:function_calls>" FUNCTION_CALLS_CLOSE = "</ate...
55
1,738
sglang
python/sglang/srt/function_call/pythonic_detector.py
.py
import ast import json import logging import re from typing import List from sglang.srt.entrypoints.openai.protocol import Tool from sglang.srt.environ import envs from sglang.srt.function_call.base_format_detector import BaseFormatDetector from sglang.srt.function_call.core_types import ( StreamingParseResult, ...
226
8,619
sglang
python/sglang/srt/function_call/gpt_oss_detector.py
.py
import json import logging import re from typing import List, Optional from sglang.srt.entrypoints.openai.protocol import Tool from sglang.srt.environ import envs from sglang.srt.function_call.base_format_detector import BaseFormatDetector from sglang.srt.function_call.core_types import ( StreamingParseResult, ...
245
9,354
sglang
python/sglang/srt/function_call/utils.py
.py
import ast import threading import warnings from json import JSONDecodeError, JSONDecoder from json.decoder import WHITESPACE from typing import Any, Dict, List, Literal, Optional, Tuple, Union import orjson import partial_json_parser from partial_json_parser.core.options import Allow from sglang.srt.entrypoints.open...
460
15,341
sglang
python/sglang/srt/function_call/hunyuan_detector.py
.py
import json import logging import re from typing import Any, Dict, List, Optional, Set from sglang.srt.entrypoints.openai.protocol import Tool from sglang.srt.environ import envs from sglang.srt.function_call.base_format_detector import BaseFormatDetector from sglang.srt.function_call.core_types import ( Streaming...
544
20,131
sglang
python/sglang/srt/function_call/glm4_moe_detector.py
.py
import json import logging import re from enum import Enum from typing import Any, Dict, List, Optional, Tuple from sglang.srt.entrypoints.openai.protocol import Tool from sglang.srt.function_call.base_format_detector import BaseFormatDetector from sglang.srt.function_call.core_types import ( StreamingParseResult,...
656
26,967
sglang
python/sglang/srt/function_call/gigachat3_detector.py
.py
import json import logging import re from typing import List from sglang.srt.entrypoints.openai.protocol import Tool from sglang.srt.function_call.base_format_detector import BaseFormatDetector from sglang.srt.function_call.core_types import ( StreamingParseResult, ToolCallItem, _GetInfoFunc, ) logger = l...
203
7,124
sglang
python/sglang/srt/function_call/poolside_v1_detector.py
.py
import json import re from enum import Enum, auto from typing import Any, List, Optional from sglang.srt.entrypoints.openai.protocol import Tool from sglang.srt.function_call.base_format_detector import BaseFormatDetector from sglang.srt.function_call.core_types import ( StreamingParseResult, StructureInfo, ...
453
19,516
sglang
python/sglang/srt/function_call/internlm_detector.py
.py
# modified from https://github.com/InternLM/lmdeploy/blob/main/lmdeploy/serve/openai/tool_parser/internlm2_parser.py import json import logging import re from typing import List from sglang.srt.entrypoints.openai.protocol import Tool from sglang.srt.environ import envs from sglang.srt.function_call.base_format_detect...
249
9,619
sglang
python/sglang/srt/function_call/cohere_command4_detector.py
.py
import json import logging from typing import List import orjson from partial_json_parser.core.exceptions import MalformedJSON from partial_json_parser.core.options import Allow from sglang.srt.entrypoints.openai.protocol import Tool from sglang.srt.function_call.base_format_detector import BaseFormatDetector from sg...
149
5,823
sglang
python/sglang/srt/function_call/mistral_detector.py
.py
import json import logging from typing import Any, List, Optional, Tuple from sglang.srt.entrypoints.openai.protocol import Tool from sglang.srt.function_call.base_format_detector import BaseFormatDetector from sglang.srt.function_call.core_types import ( StreamingParseResult, StructureInfo, ToolCallItem, ...
344
12,438
sglang
python/sglang/srt/function_call/kimik3_detector.py
.py
import json import logging import re from typing import List, Literal, Optional, Union from xgrammar import StructuralTag from sglang.srt.entrypoints.openai.protocol import Tool, ToolChoice from sglang.srt.function_call.base_format_detector import BaseFormatDetector from sglang.srt.function_call.core_types import ( ...
235
8,525
sglang
python/sglang/srt/function_call/function_call_parser.py
.py
import inspect import logging from typing import Dict, List, Literal, Optional, Set, Tuple, Type, Union from sglang.srt.entrypoints.openai.protocol import ( LegacyStructuralTagResponseFormat, StructuralTagResponseFormat, StructuresResponseFormat, Tool, ToolCallConstraint, ToolChoice, ) from sgl...
318
13,401
sglang
python/sglang/srt/function_call/minicpm5_detector.py
.py
import json import logging import re from typing import Dict, List, Optional from sglang.srt.entrypoints.openai.protocol import Tool from sglang.srt.function_call.base_format_detector import BaseFormatDetector from sglang.srt.function_call.core_types import ( StreamingParseResult, _GetInfoFunc, ) from sglang.s...
318
12,860
sglang
python/sglang/srt/function_call/lfm2_detector.py
.py
""" Detector for LFM2 (Liquid Foundation Model 2) function call format. Format Structure (Pythonic style): ``` <|tool_call_start|>[function_name(arg1="value1", arg2="value2")]<|tool_call_end|> ``` Multiple tool calls: ``` <|tool_call_start|>[func1(arg="val"), func2(arg="val")]<|tool_call_end|> ``` Also supports JSON...
408
14,616
sglang
python/sglang/srt/function_call/step3_detector.py
.py
import json import logging import re from typing import Any, Dict, List from sglang.srt.entrypoints.openai.protocol import Tool from sglang.srt.function_call.base_format_detector import BaseFormatDetector from sglang.srt.function_call.core_types import ( StreamingParseResult, ToolCallItem, _GetInfoFunc, ) ...
408
16,414
sglang
python/sglang/srt/function_call/kimik2_detector.py
.py
import json import logging import re from typing import List, Literal, Optional, Union from sglang.srt.entrypoints.openai.protocol import Tool, ToolChoice from sglang.srt.function_call.base_format_detector import ( BaseFormatDetector, StructuralTag, get_model_structural_tag, ) from sglang.srt.function_call...
474
18,890
sglang
python/sglang/srt/function_call/kimik3_format.py
.py
from typing import List THINK_OPEN = "<|open|>think<|sep|>" THINK_CLOSE = "<|close|>think<|sep|>" RESPONSE_OPEN = "<|open|>response<|sep|>" RESPONSE_CLOSE = "<|close|>response<|sep|>" TOOLS_OPEN = "<|open|>tools<|sep|>" TOOLS_CLOSE = "<|close|>tools<|sep|>" MESSAGE_CLOSE = "<|close|>message<|sep|>" CALL_OPEN = "<|open...
56
1,787
sglang
python/sglang/srt/function_call/inkling_detector.py
.py
import json import logging from collections.abc import Mapping from typing import List, Optional from xgrammar import StructuralTag from sglang.srt.entrypoints.openai.protocol import Tool from sglang.srt.function_call.base_format_detector import BaseFormatDetector from sglang.srt.function_call.core_types import ( ...
344
14,070
sglang
python/sglang/srt/function_call/minimax_m3.py
.py
import json import logging import re from typing import Any, Dict, List, Optional, Tuple from sglang.srt.entrypoints.openai.protocol import Tool from sglang.srt.function_call.base_format_detector import BaseFormatDetector from sglang.srt.function_call.core_types import ( StreamingParseResult, ToolCallItem, ...
543
20,286
sglang
python/sglang/srt/function_call/llama32_detector.py
.py
import json import logging import re from typing import List from sglang.srt.entrypoints.openai.protocol import Tool from sglang.srt.function_call.base_format_detector import BaseFormatDetector from sglang.srt.function_call.core_types import ( StreamingParseResult, StructureInfo, _GetInfoFunc, ) from sglan...
145
5,572
sglang
python/sglang/srt/function_call/apertus2509_detector.py
.py
import json import logging from typing import Any, List, Optional, Tuple from sglang.srt.entrypoints.openai.protocol import Tool from sglang.srt.environ import envs from sglang.srt.function_call.base_format_detector import BaseFormatDetector from sglang.srt.function_call.core_types import ( StreamingParseResult, ...
268
9,925
sglang
python/sglang/srt/function_call/json_array_parser.py
.py
from typing import List from sglang.srt.entrypoints.openai.protocol import Tool from sglang.srt.function_call.base_format_detector import BaseFormatDetector from sglang.srt.function_call.core_types import StreamingParseResult class JsonArrayParser(BaseFormatDetector): """ Parser for JSON array tool calls whe...
52
1,831
sglang
python/sglang/srt/function_call/deepseekv32_detector.py
.py
import json import logging import re from partial_json_parser.core.exceptions import MalformedJSON from partial_json_parser.core.options import Allow from sglang.srt.entrypoints.openai.protocol import Tool from sglang.srt.function_call.base_format_detector import BaseFormatDetector from sglang.srt.function_call.core_...
389
16,214
sglang
python/sglang/srt/function_call/mimo_detector.py
.py
# Copyright 2023-2024 SGLang Team # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writin...
282
10,340
sglang
python/sglang/srt/function_call/deepseekv4_detector.py
.py
import logging from sglang.srt.function_call.deepseekv32_detector import DeepSeekV32Detector logger = logging.getLogger(__name__) class DeepSeekV4Detector(DeepSeekV32Detector): """ Detector for DeepSeek V4 model function call format. The DeepSeek V4 format uses XML-like DSML tags to delimit function ca...
68
1,991
sglang
python/sglang/srt/function_call/deepseekv31_detector.py
.py
import json import logging import re from typing import List from sglang.srt.entrypoints.openai.protocol import Tool from sglang.srt.function_call.base_format_detector import BaseFormatDetector from sglang.srt.function_call.core_types import ( StreamingParseResult, StructureInfo, ToolCallItem, _GetInfo...
207
8,996
sglang
python/sglang/srt/function_call/deepseekv3_detector.py
.py
import json import logging import re from typing import List from sglang.srt.entrypoints.openai.protocol import Tool from sglang.srt.function_call.base_format_detector import BaseFormatDetector from sglang.srt.function_call.core_types import ( StreamingParseResult, StructureInfo, ToolCallItem, _GetInfo...
212
9,368
sglang
python/sglang/srt/function_call/qwen25_detector.py
.py
import json import logging import re from typing import List from sglang.srt.entrypoints.openai.protocol import Tool from sglang.srt.function_call.base_format_detector import BaseFormatDetector from sglang.srt.function_call.core_types import ( StreamingParseResult, StructureInfo, _GetInfoFunc, ) logger = ...
121
4,775
sglang
python/sglang/srt/function_call/core_types.py
.py
from dataclasses import dataclass from typing import Callable, List, Optional from pydantic import BaseModel class ToolCallItem(BaseModel): """Simple encapsulation of the parsed ToolCall result for easier usage in streaming contexts.""" tool_index: int name: Optional[str] = None parameters: str # J...
35
786
sglang
python/sglang/srt/function_call/kimik3_structural_tag.py
.py
from typing import Any, Dict, List, Literal, Optional, Set, Tuple, Union from xgrammar import StructuralTag from xgrammar.structural_tag import ( AnyTextFormat, AnyTokensFormat, ConstStringFormat, ExcludeTokenFormat, Format, JSONSchemaFormat, OptionalFormat, OrFormat, RegexFormat, ...
626
20,244
sglang
python/sglang/srt/function_call/hermes_detector.py
.py
import json import logging import re from typing import List from sglang.srt.entrypoints.openai.protocol import Tool from sglang.srt.function_call.base_format_detector import BaseFormatDetector from sglang.srt.function_call.core_types import ( StreamingParseResult, StructureInfo, _GetInfoFunc, ) logger = ...
121
4,180
sglang
python/sglang/srt/function_call/qwen3_coder_detector.py
.py
import json import logging import re from typing import Any, List, Optional from sglang.srt.entrypoints.openai.protocol import Tool from sglang.srt.function_call.base_format_detector import BaseFormatDetector from sglang.srt.function_call.core_types import ( StreamingParseResult, ToolCallItem, _GetInfoFunc...
482
20,139
sglang
python/sglang/srt/function_call/glm47_moe_detector.py
.py
import json import logging import re from enum import Enum from functools import lru_cache from typing import Any, Dict, List, Literal, Optional, Tuple, Union from sglang.srt.entrypoints.openai.protocol import Tool, ToolChoice from sglang.srt.function_call.base_format_detector import ( BaseFormatDetector, Stru...
841
32,306
sglang
python/sglang/srt/function_call/trinity_detector.py
.py
import logging from typing import List from sglang.srt.entrypoints.openai.protocol import Tool from sglang.srt.function_call.core_types import StreamingParseResult from sglang.srt.function_call.qwen25_detector import Qwen25Detector logger = logging.getLogger(__name__) class TrinityDetector(Qwen25Detector): """ ...
44
1,573
sglang
python/sglang/srt/ray/__init__.py
.py
from sglang.srt.ray.engine import RayEngine __all__ = ["RayEngine"]
4
69
sglang
python/sglang/srt/ray/data_parallel_controller.py
.py
# Copyright 2023-2024 SGLang Team # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writin...
302
13,309
sglang
python/sglang/srt/ray/engine.py
.py
# Copyright 2023-2024 SGLang Team # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writin...
502
18,285
sglang
python/sglang/srt/ray/scheduler_actor.py
.py
# Copyright 2023-2024 SGLang Team # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writin...
137
4,808
sglang
python/sglang/srt/ray/http_server.py
.py
# Copyright 2023-2024 SGLang Team # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writin...
71
2,432
sglang
python/sglang/srt/hardware_backend/gpu/quantization/gptq_kernels.py
.py
from __future__ import annotations from dataclasses import dataclass from typing import TYPE_CHECKING, Callable, Optional import torch from sglang.srt.layers.moe import MoeRunner, MoeRunnerBackend, get_moe_runner_backend from sglang.srt.layers.moe.moe_runner.marlin import MarlinMoeQuantInfo from sglang.srt.layers.pa...
383
14,136
sglang
python/sglang/srt/hardware_backend/gpu/quantization/awq_kernels.py
.py
from __future__ import annotations from typing import TYPE_CHECKING, Optional import torch from sglang.srt.layers.moe import MoeRunner from sglang.srt.layers.moe.moe_runner.marlin import MarlinMoeQuantInfo from sglang.srt.layers.quantization.marlin_utils import ( apply_awq_marlin_linear, awq_to_marlin_zero_p...
256
9,184
sglang
python/sglang/srt/hardware_backend/cpu/quantization/gptq_kernels.py
.py
# SPDX-License-Identifier: Apache-2.0 from __future__ import annotations from typing import TYPE_CHECKING, Optional import torch from sglang.srt.layers.amx_utils import ( CPUQuantMethod, _amx_process_weight_after_loading, ) from sglang.srt.layers.moe import MoeRunnerConfig if TYPE_CHECKING: from sglang....
100
3,260
sglang
python/sglang/srt/hardware_backend/cpu/quantization/awq_kernels.py
.py
# SPDX-License-Identifier: Apache-2.0 from __future__ import annotations from typing import TYPE_CHECKING, Optional import torch from sglang.srt.layers.amx_utils import ( CPUQuantMethod, _amx_process_weight_after_loading, ) from sglang.srt.layers.moe import MoeRunnerConfig if TYPE_CHECKING: from sglang....
100
3,248
sglang
python/sglang/srt/hardware_backend/xpu/kernels/fla/chunk_fwd.py
.py
import torch import triton import triton.language as tl from sglang.kernels.ops.attention.fla.index import prepare_chunk_indices from sglang.kernels.ops.attention.fla.op import safe_exp from sglang.kernels.ops.attention.fla.utils import ( autotune_cache_kwargs, ) from sglang.kernels.ops.attention.fla.wy_fast impor...
326
12,937
sglang
python/sglang/srt/hardware_backend/xpu/kernels/fla/fused_sigmoid_gating_recurrent.py
.py
from typing import Optional import torch import triton from sglang.kernels.ops.attention.fla.fused_sigmoid_gating_recurrent import ( fused_sigmoid_gating_delta_rule_update_kernel, ) def fused_sigmoid_gating_delta_rule_update( A_log: torch.Tensor, a: torch.Tensor, dt_bias: torch.Tensor, softplus_...
131
4,463
sglang
python/sglang/srt/hardware_backend/xpu/kernels/fla/chunk_delta_h.py
.py
from typing import Optional, Tuple import torch import triton import triton.language as tl from sglang.kernels.ops.attention.fla.index import ( prepare_chunk_indices, prepare_chunk_offsets, ) from sglang.kernels.ops.attention.fla.op import ( exp, exp2, make_tensor_descriptor, safe_exp, ) from ...
295
9,719
sglang
python/sglang/srt/hardware_backend/xpu/graph_runner/xpu_graph_runner.py
.py
# Copyright 2023-2024 SGLang Team # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writin...
170
5,796
sglang
python/sglang/srt/hardware_backend/xpu/graph_runner/xpu_full_graph_backend.py
.py
"""FullXPUGraphBackend — Intel XPU full-graph capture (torch.xpu.XPUGraph). Mirrors FullCudaGraphBackend with XPU-specific differences: - Captures via torch.xpu.graph(xpu_graph=...) into torch.xpu.XPUGraph. - Shares the global graph memory pool with the prefill backend so that decode + prefill graphs occupy ma...
101
3,241