From f3bf61105486730699660fac20aed50a92d87272 Mon Sep 17 00:00:00 2001 From: Junrong Lin <33685709+ocss884@users.noreply.github.com> Date: Thu, 15 May 2025 10:15:02 +0800 Subject: [PATCH] feat: add flush cache to EngineBase and HttpServerEngineAdapter (#6009) --- python/sglang/srt/entrypoints/EngineBase.py | 5 +++++ python/sglang/srt/entrypoints/http_server_engine.py | 3 +++ 2 files changed, 8 insertions(+) diff --git a/python/sglang/srt/entrypoints/EngineBase.py b/python/sglang/srt/entrypoints/EngineBase.py index 894a6f065..c7dfafd41 100644 --- a/python/sglang/srt/entrypoints/EngineBase.py +++ b/python/sglang/srt/entrypoints/EngineBase.py @@ -27,6 +27,11 @@ class EngineBase(ABC): """Generate outputs based on given inputs.""" pass + @abstractmethod + def flush_cache(self): + """Flush the cache of the engine.""" + pass + @abstractmethod def update_weights_from_tensor( self, diff --git a/python/sglang/srt/entrypoints/http_server_engine.py b/python/sglang/srt/entrypoints/http_server_engine.py index f4d81a417..f50e13f3c 100644 --- a/python/sglang/srt/entrypoints/http_server_engine.py +++ b/python/sglang/srt/entrypoints/http_server_engine.py @@ -140,3 +140,6 @@ class HttpServerEngineAdapter(EngineBase): def resume_memory_occupation(self): return self._make_request("resume_memory_occupation") + + def flush_cache(self): + return self._make_request("flush_cache")