Special logic for healthcheck (#17734)
Co-authored-by: Liangsheng Yin <lsyincs@gmail.com>
This commit is contained in:
@@ -18,7 +18,7 @@ import logging
|
|||||||
import os
|
import os
|
||||||
import signal
|
import signal
|
||||||
from collections import OrderedDict, defaultdict
|
from collections import OrderedDict, defaultdict
|
||||||
from typing import Dict, List, Tuple, Union
|
from typing import Dict, List, Optional, Tuple, Union
|
||||||
|
|
||||||
import psutil
|
import psutil
|
||||||
import pybase64
|
import pybase64
|
||||||
@@ -94,6 +94,10 @@ class DetokenizerManager(MultiHttpWorkerDetokenizerMixin):
|
|||||||
# Init dispatcher
|
# Init dispatcher
|
||||||
self.init_request_dispatcher()
|
self.init_request_dispatcher()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def is_health_check_request(rid: Optional[str]) -> bool:
|
||||||
|
return isinstance(rid, str) and rid.startswith("HEALTH_CHECK")
|
||||||
|
|
||||||
def init_ipc_channels(self, port_args: PortArgs):
|
def init_ipc_channels(self, port_args: PortArgs):
|
||||||
context = zmq.Context(2)
|
context = zmq.Context(2)
|
||||||
self.recv_from_scheduler = get_zmq_socket(
|
self.recv_from_scheduler = get_zmq_socket(
|
||||||
@@ -232,6 +236,8 @@ class DetokenizerManager(MultiHttpWorkerDetokenizerMixin):
|
|||||||
surr_offset=0,
|
surr_offset=0,
|
||||||
read_offset=recv_obj.read_offsets[i],
|
read_offset=recv_obj.read_offsets[i],
|
||||||
)
|
)
|
||||||
|
if not self.is_health_check_request(rid):
|
||||||
|
# for health check requests, we do not store the decode status
|
||||||
self.decode_status[rid] = s
|
self.decode_status[rid] = s
|
||||||
else:
|
else:
|
||||||
s = self.decode_status[rid]
|
s = self.decode_status[rid]
|
||||||
@@ -290,11 +296,20 @@ class DetokenizerManager(MultiHttpWorkerDetokenizerMixin):
|
|||||||
# Incremental decoding
|
# Incremental decoding
|
||||||
output_strs = []
|
output_strs = []
|
||||||
for i in range(bs):
|
for i in range(bs):
|
||||||
|
rid = recv_obj.rids[i]
|
||||||
|
if self.is_health_check_request(rid):
|
||||||
|
s = DecodeStatus(
|
||||||
|
decoded_text=recv_obj.decoded_texts[i],
|
||||||
|
decode_ids=recv_obj.decode_ids[i],
|
||||||
|
surr_offset=0,
|
||||||
|
read_offset=recv_obj.read_offsets[i],
|
||||||
|
)
|
||||||
|
else:
|
||||||
try:
|
try:
|
||||||
s = self.decode_status[recv_obj.rids[i]]
|
s = self.decode_status[rid]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise RuntimeError(
|
raise RuntimeError(
|
||||||
f"Decode status not found for request {recv_obj.rids[i]}. "
|
f"Decode status not found for request {rid}. "
|
||||||
"It may be due to the request being evicted from the decode status due to memory pressure. "
|
"It may be due to the request being evicted from the decode status due to memory pressure. "
|
||||||
"Please increase the maximum number of requests by setting "
|
"Please increase the maximum number of requests by setting "
|
||||||
"the SGLANG_DETOKENIZER_MAX_STATES environment variable to a bigger value than the default value. "
|
"the SGLANG_DETOKENIZER_MAX_STATES environment variable to a bigger value than the default value. "
|
||||||
@@ -312,7 +327,8 @@ class DetokenizerManager(MultiHttpWorkerDetokenizerMixin):
|
|||||||
else:
|
else:
|
||||||
new_text = find_printable_text(new_text)
|
new_text = find_printable_text(new_text)
|
||||||
else:
|
else:
|
||||||
del self.decode_status[recv_obj.rids[i]]
|
if rid in self.decode_status:
|
||||||
|
del self.decode_status[rid]
|
||||||
|
|
||||||
output_str = self.trim_matched_stop(
|
output_str = self.trim_matched_stop(
|
||||||
s.decoded_text + new_text,
|
s.decoded_text + new_text,
|
||||||
|
|||||||
Reference in New Issue
Block a user