94057c3d3e
PR Test (NPU) / check-changes (push) Has been cancelled
PR Test (NPU) / pr-gate (push) Has been cancelled
PR Test (NPU) / set-image-config (push) Has been cancelled
PR Test (NPU) / stage-b-test-1-npu-a2 (0) (push) Has been cancelled
PR Test (NPU) / stage-b-test-1-npu-a2 (1) (push) Has been cancelled
PR Test (NPU) / stage-b-test-2-npu-a2 (0) (push) Has been cancelled
PR Test (NPU) / stage-b-test-2-npu-a2 (1) (push) Has been cancelled
PR Test (NPU) / stage-b-test-4-npu-a3 (push) Has been cancelled
PR Test (NPU) / stage-b-test-16-npu-a3 (push) Has been cancelled
PR Test (NPU) / multimodal-gen-test-1-npu-a3 (push) Has been cancelled
PR Test (NPU) / multimodal-gen-test-2-npu-a3 (push) Has been cancelled
PR Test (Arm64) / pr-gate (push) Has been cancelled
PR Test (Arm64) / check-changes (push) Has been cancelled
PR Test (Arm64) / build-test (push) Has been cancelled
PR Test (sgl-router) / gate (push) Has been cancelled
PR Test (sgl-router) / tier-1 — lint (push) Has been cancelled
PR Test (sgl-router) / tier-2 — build + test (push) Has been cancelled
PR Test (sgl-router) / tier-3 — docker (placeholder) (push) Has been cancelled
PR Test (sgl-router) / tier-3 — k8s integration (push) Has been cancelled
PR Test (sgl-router) / tier-3 — e2e (push) Has been cancelled
PR Test (sgl-router) / finish (push) Has been cancelled
PR Test (NPU) / single-node-poc (map[name:qwen3_6_27b_w8a8_1p_in64k_out1k_50ms runner:linux-aarch64-a3-2 test_case:test/registered/ascend/performance/qwen3_6_27b/test_npu_qwen3_6_27b_w8a8_1p_in64k_out1k_50ms.py test_type:perf]) (push) Has been cancelled
PR Test (NPU) / pr-test-npu-finish (push) Has been cancelled
PR Test (Xeon) / pr-gate (push) Has been cancelled
PR Test (Xeon) / check-changes (push) Has been cancelled
PR Test (Xeon) / build-test (, xeon-gnr, base-b-test-cpu) (push) Has been cancelled
PR Test (XPU) / check-changes (push) Has been cancelled
PR Test (XPU) / pr-gate (push) Has been cancelled
PR Test (XPU) / stage-a-test-1-gpu-xpu (push) Has been cancelled
PR Test (XPU) / wait-for-stage-a (push) Has been cancelled
PR Test (XPU) / stage-b-test-1-gpu-xpu (push) Has been cancelled
PR Test (XPU) / finish (push) Has been cancelled
CI Model Inventory / build-inventory (push) Has been cancelled
Lint / lint (push) Has been cancelled
PR Benchmark (SMG Components) / Benchmark Compilation Check (push) Has been cancelled
PR Benchmark (SMG Components) / Benchmark - Manual Policy (push) Has been cancelled
PR Benchmark (SMG Components) / Benchmark - Request Processing (push) Has been cancelled
PR Benchmark (SMG Components) / Benchmark Summary (push) Has been cancelled
PR Test (SMG) / build-wheel (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on windows (x86_64 - auto) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on macos (x86_64 - auto) (push) Has been cancelled
PR Test (SMG) / python-unit-tests (push) Has been cancelled
PR Test (SMG) / unit-tests (push) Has been cancelled
PR Test (SMG) / benchmarks (push) Has been cancelled
PR Test (SMG) / chat-completions (push) Has been cancelled
PR Test (SMG) / chat-completions-4gpu (push) Has been cancelled
PR Test (SMG) / e2e (push) Has been cancelled
PR Test (SMG) / docker-build-test (push) Has been cancelled
PR Test (SMG) / k8s-integration (push) Has been cancelled
PR Test (SMG) / finish (push) Has been cancelled
PR Test (SMG) / summarize-benchmarks (push) Has been cancelled
Release SGLang Model Gateway Docker Image / publish (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on macos (aarch64 - auto) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on linux (aarch64 - auto) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on linux (x86_64 - auto) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on linux (aarch64 - musllinux_1_1) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on linux (x86_64 - musllinux_1_1) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / Build SDist (push) Has been cancelled
Release SGLang Model Gateway to PyPI / Upload to PyPI (push) Has been cancelled
Release SGLang Kernels / build-cu129-matrix (aarch64, 12.9, 3.10, arm-kernel-build-node) (push) Has been cancelled
Release SGLang Kernels / build-cu129-matrix (x86_64, 12.9, 3.10, x64-kernel-build-node) (push) Has been cancelled
Release SGLang Kernels / release-cu129 (push) Has been cancelled
Release SGLang Kernels / build-cu130-matrix (aarch64, 13.0, 3.10, arm-kernel-build-node) (push) Has been cancelled
Release SGLang Kernels / build-cu130-matrix (x86_64, 13.0, 3.10, x64-kernel-build-node) (push) Has been cancelled
Release SGLang Kernels / release-cu130 (push) Has been cancelled
Release SGLang Kernels / build-rocm-matrix (3.10, 700) (push) Has been cancelled
Release SGLang Kernels / build-rocm-matrix (3.10, 720) (push) Has been cancelled
Release SGLang Kernels / release-rocm700 (push) Has been cancelled
Release SGLang Kernels / release-rocm720 (push) Has been cancelled
Release SGLang Kernels / build-musa43 (43, 3.10) (push) Has been cancelled
Release SGLang Kernels / release-musa43 (push) Has been cancelled
144 lines
5.0 KiB
Python
144 lines
5.0 KiB
Python
"""
|
|
SGLang SRT Hardware Platform Abstraction.
|
|
|
|
Defines SRTPlatform — the base class for SRT (LLM inference) platform
|
|
backends. SRTPlatform inherits DeviceMixin for shared device operations
|
|
and adds SRT-specific subsystem factory methods, capability flags, and
|
|
configuration lifecycle hooks.
|
|
|
|
Out-of-tree platforms register via setuptools entry_points under the
|
|
"sglang.srt.platforms" group and should subclass SRTPlatform.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import TYPE_CHECKING, Optional, Type
|
|
|
|
from sglang.srt.platforms.device_mixin import DeviceMixin, PlatformEnum
|
|
|
|
if TYPE_CHECKING:
|
|
from sglang.srt.layers.quantization.base_config import QuantizationConfig
|
|
|
|
# Re-export for convenience
|
|
__all__ = ["SRTPlatform", "PlatformEnum"]
|
|
|
|
|
|
class SRTPlatform(DeviceMixin):
|
|
"""
|
|
Base class for SRT hardware platform backends.
|
|
|
|
Inherits device identity queries and operations from DeviceMixin.
|
|
Adds SRT-specific factory methods, capability flags, and lifecycle hooks.
|
|
|
|
OOT platforms should subclass SRTPlatform and override the methods
|
|
relevant to their hardware.
|
|
"""
|
|
|
|
# SRT-specific class-level attribute
|
|
supported_quantization: list[str] = []
|
|
|
|
# ------------------------------------------------------------------
|
|
# Configuration lifecycle
|
|
# ------------------------------------------------------------------
|
|
|
|
def apply_server_args_defaults(self, server_args) -> None:
|
|
"""Apply platform-specific default values to server arguments.
|
|
|
|
Called after ServerArgs is parsed.
|
|
"""
|
|
pass
|
|
|
|
# ------------------------------------------------------------------
|
|
# Subsystem factory methods
|
|
# ------------------------------------------------------------------
|
|
|
|
def get_default_attention_backend(self) -> str:
|
|
"""Return the default attention backend name for this platform."""
|
|
raise NotImplementedError
|
|
|
|
def get_graph_runner_cls(self) -> type:
|
|
"""Return the graph runner class for this platform."""
|
|
raise NotImplementedError
|
|
|
|
def get_mha_kv_pool_cls(self) -> type:
|
|
"""Return the MHA KV pool class for this platform."""
|
|
raise NotImplementedError
|
|
|
|
def get_mla_kv_pool_cls(self) -> type:
|
|
"""Return the MLA KV pool class for this platform."""
|
|
raise NotImplementedError
|
|
|
|
def get_dsa_kv_pool_cls(self) -> type:
|
|
"""Return the DSA KV pool class for this platform (DeepSeek V3.2)."""
|
|
raise NotImplementedError
|
|
|
|
def get_paged_allocator_cls(self) -> type:
|
|
"""Return the paged allocator class for this platform."""
|
|
raise NotImplementedError
|
|
|
|
def get_compile_backend(self, mode: str | None = None) -> str:
|
|
"""Return the compilation backend identifier.
|
|
|
|
``mode`` is an optional hint for the platform (e.g. "npugraph_ex").
|
|
"""
|
|
return "inductor"
|
|
|
|
def get_piecewise_backend_cls(self) -> type:
|
|
"""Return the piecewise compilation backend class for this platform."""
|
|
raise NotImplementedError
|
|
|
|
def get_quantization_config(
|
|
self, quantization: str
|
|
) -> Optional[Type[QuantizationConfig]]:
|
|
"""Return hardware-specific quantization config for the specific
|
|
quantization scheme, raise an error if not supported or return None
|
|
to use the default config."""
|
|
return None
|
|
|
|
# ------------------------------------------------------------------
|
|
# Capability flags (safe conservative defaults)
|
|
# ------------------------------------------------------------------
|
|
|
|
def supports_fp8(self) -> bool:
|
|
"""Whether this platform supports FP8 quantization."""
|
|
return False
|
|
|
|
def is_pin_memory_available(self) -> bool:
|
|
"""Whether pinned memory is available on this platform."""
|
|
return True
|
|
|
|
def support_cuda_graph(self) -> bool:
|
|
"""Whether this platform supports device graph capture and replay.
|
|
Controls CUDA graph (CudaGraphRunner) for the decode path.
|
|
OOT platforms that support graph-style capture should return True.
|
|
"""
|
|
return False
|
|
|
|
def support_piecewise_cuda_graph(self) -> bool:
|
|
"""Whether this platform supports piecewise CUDA graph.
|
|
|
|
Controls PiecewiseCudaGraphRunner for the prefill/extend path
|
|
(torch.compile backend).
|
|
"""
|
|
return False
|
|
|
|
# ------------------------------------------------------------------
|
|
# Initialization
|
|
# ------------------------------------------------------------------
|
|
|
|
def init_backend(self) -> None:
|
|
"""One-time backend initialization. Called in each worker."""
|
|
pass
|
|
|
|
# ------------------------------------------------------------------
|
|
# MultiPlatformOp integration
|
|
# ------------------------------------------------------------------
|
|
|
|
def get_dispatch_key_name(self) -> str:
|
|
"""Return the dispatch key name for MultiPlatformOp.
|
|
|
|
Determines which ``forward_<key>()`` method is selected.
|
|
E.g. "cuda", "npu", "hip", "xpu", "cpu".
|
|
"""
|
|
return "native"
|