[feat] support in-flight weight update (#10071)
Co-authored-by: 赵晨阳 <zhaochen20@outlook.com>
This commit is contained in:
@@ -73,6 +73,7 @@ from sglang.srt.managers.io_struct import (
|
||||
ClearHiCacheReqInput,
|
||||
ClearHiCacheReqOutput,
|
||||
CloseSessionReqInput,
|
||||
ContinueGenerationReqInput,
|
||||
DestroyWeightsUpdateGroupReqInput,
|
||||
ExpertDistributionReq,
|
||||
ExpertDistributionReqOutput,
|
||||
@@ -93,6 +94,7 @@ from sglang.srt.managers.io_struct import (
|
||||
LoadLoRAAdapterReqOutput,
|
||||
OpenSessionReqInput,
|
||||
OpenSessionReqOutput,
|
||||
PauseGenerationReqInput,
|
||||
ProfileReq,
|
||||
ReleaseMemoryOccupationReqInput,
|
||||
ResumeMemoryOccupationReqInput,
|
||||
@@ -443,6 +445,7 @@ class Scheduler(
|
||||
if self.device == "cpu":
|
||||
self.default_stream.synchronize = lambda: None # No-op for CPU
|
||||
self.forward_sleep_time = None
|
||||
self._engine_paused = False
|
||||
|
||||
# Init chunked prefill
|
||||
self.chunked_prefill_size = server_args.chunked_prefill_size
|
||||
@@ -568,6 +571,8 @@ class Scheduler(
|
||||
(LoadLoRAAdapterReqInput, self.load_lora_adapter),
|
||||
(UnloadLoRAAdapterReqInput, self.unload_lora_adapter),
|
||||
(GetLoadReqInput, self.get_load),
|
||||
(PauseGenerationReqInput, self.pause_generation),
|
||||
(ContinueGenerationReqInput, self.continue_generation),
|
||||
]
|
||||
)
|
||||
|
||||
@@ -953,6 +958,9 @@ class Scheduler(
|
||||
recv_reqs = self.recv_requests()
|
||||
self.process_input_requests(recv_reqs)
|
||||
|
||||
if self._engine_paused:
|
||||
continue
|
||||
|
||||
batch = self.get_next_batch_to_run()
|
||||
self.cur_batch = batch
|
||||
|
||||
@@ -985,6 +993,9 @@ class Scheduler(
|
||||
recv_reqs = self.recv_requests()
|
||||
self.process_input_requests(recv_reqs)
|
||||
|
||||
if self._engine_paused:
|
||||
continue
|
||||
|
||||
batch = self.get_next_batch_to_run()
|
||||
self.cur_batch = batch
|
||||
|
||||
@@ -2154,8 +2165,7 @@ class Scheduler(
|
||||
|
||||
def _is_no_request(self):
|
||||
no_request = (
|
||||
len(self.waiting_queue) == 0
|
||||
and self.running_batch.is_empty()
|
||||
self.running_batch.is_empty()
|
||||
and (self.last_batch is None or self.last_batch.is_empty())
|
||||
and (self.cur_batch is None or self.cur_batch.is_empty())
|
||||
and (not self.enable_overlap or len(self.result_queue) == 0)
|
||||
@@ -2428,6 +2438,29 @@ class Scheduler(
|
||||
def _pause_engine(self) -> Tuple[List[Req], int]:
|
||||
raise NotImplementedError()
|
||||
|
||||
def pause_generation(self, recv_req: PauseGenerationReqInput):
|
||||
self._engine_paused = True
|
||||
|
||||
if self.enable_overlap and self.last_batch:
|
||||
# Process the results of the last batch
|
||||
tmp_batch, tmp_result = self.result_queue.popleft()
|
||||
self.process_batch_result(tmp_batch, tmp_result)
|
||||
self.last_batch = None
|
||||
self.cur_batch = None
|
||||
|
||||
if recv_req.mode == "retract":
|
||||
self.running_batch.filter_batch()
|
||||
if len(self.running_batch.reqs) != 0:
|
||||
retracted_reqs = self.running_batch.retract_all(self.server_args)
|
||||
for req in retracted_reqs:
|
||||
self._add_request_to_queue(req)
|
||||
|
||||
self.running_batch.batch_is_full = False
|
||||
self.chunked_req = None
|
||||
|
||||
def continue_generation(self, recv_req: ContinueGenerationReqInput):
|
||||
self._engine_paused = False
|
||||
|
||||
def load_lora_adapter(
|
||||
self, recv_req: LoadLoRAAdapterReqInput
|
||||
) -> LoadLoRAAdapterReqOutput:
|
||||
|
||||
Reference in New Issue
Block a user