[Runtime] Let out-of-tree platforms provide full graph backends (#37969)

Co-authored-by: Xiaoyu Zhang <1182563586@qq.com>
This commit is contained in:
Rumit Desai
2026-09-18 15:42:46 +08:00
committed by GitHub
co-authored by Xiaoyu Zhang
parent c46bf5e990
commit 1fdd6c8921
3 changed files with 207 additions and 6 deletions
@@ -37,9 +37,8 @@ from sglang.srt.model_executor.runner_backend.full_cuda_graph_backend import (
from sglang.srt.model_executor.runner_backend.tc_piecewise_cuda_graph_backend import (
TcPiecewiseCudaGraphBackend,
)
from sglang.srt.runtime_context import (
get_exec,
)
from sglang.srt.platforms import current_platform
from sglang.srt.runtime_context import get_exec
if TYPE_CHECKING:
from sglang.srt.model_executor.runner.base_cuda_graph_runner import (
@@ -99,8 +98,17 @@ def resolve_decode_backend(
"falling back to 'full'."
)
_TC_PIECEWISE_DECODE_FALLBACK_LOGGED = True
return FullCudaGraphBackend(
cuda_graph_runner, enable_memory_saver=enable_memory_saver
full_backend_cls = None
if current_platform.is_out_of_tree():
full_backend_cls = current_platform.get_full_graph_backend_cls()
if full_backend_cls is None:
full_backend_cls = FullCudaGraphBackend
return full_backend_cls(
cuda_graph_runner,
enable_memory_saver=enable_memory_saver,
)
+5 -1
View File
@@ -12,7 +12,7 @@ Out-of-tree platforms register via setuptools entry_points under the
from __future__ import annotations
from typing import TYPE_CHECKING, Optional, Type
from typing import TYPE_CHECKING, Any, Optional, Type
from sglang.srt.platforms.device_mixin import DeviceMixin, PlatformEnum
@@ -60,6 +60,10 @@ class SRTPlatform(DeviceMixin):
"""Return the graph runner class for this platform."""
raise NotImplementedError
def get_full_graph_backend_cls(self) -> type[Any]:
"""Return the full device-graph backend class for this platform."""
return None
def get_mha_kv_pool_cls(self) -> type:
"""Return the MHA KV pool class for this platform."""
raise NotImplementedError