Test the case when max_new_tokens is very large (#1038)
This commit is contained in:
@@ -32,7 +32,7 @@ from sglang.srt.managers.io_struct import (
|
||||
)
|
||||
from sglang.srt.managers.schedule_batch import FINISH_MATCHED_STR
|
||||
from sglang.srt.server_args import PortArgs, ServerArgs
|
||||
from sglang.utils import find_printable_text, get_exception_traceback, graceful_registry
|
||||
from sglang.utils import find_printable_text, get_exception_traceback
|
||||
|
||||
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
|
||||
|
||||
@@ -164,8 +164,6 @@ def start_detokenizer_process(
|
||||
port_args: PortArgs,
|
||||
pipe_writer,
|
||||
):
|
||||
graceful_registry(inspect.currentframe().f_code.co_name)
|
||||
|
||||
try:
|
||||
manager = DetokenizerManager(server_args, port_args)
|
||||
except Exception:
|
||||
|
||||
@@ -15,6 +15,7 @@ limitations under the License.
|
||||
|
||||
"""Request policy scheduler"""
|
||||
|
||||
import os
|
||||
import random
|
||||
from collections import defaultdict
|
||||
from contextlib import contextmanager
|
||||
@@ -24,9 +25,11 @@ from sglang.srt.managers.schedule_batch import Req, ScheduleBatch
|
||||
from sglang.srt.mem_cache.base_prefix_cache import BasePrefixCache
|
||||
from sglang.srt.mem_cache.radix_cache import TreeNode
|
||||
|
||||
# Clip the max new tokens for the request whose max_new_tokens is very large.
|
||||
# Clip the estimation of max_new_tokens for the request whose max_new_tokens is very large.
|
||||
# This can prevent the server from being too conservative.
|
||||
CLIP_MAX_NEW_TOKENS = 4096
|
||||
# Note that this only clips the estimation in the scheduler but does not change the stop
|
||||
# condition. The request can still generate tokens until it hits the unclipped max_new_tokens.
|
||||
CLIP_MAX_NEW_TOKENS = int(os.environ.get("SGLANG_CLIP_MAX_NEW_TOKENS", "4096"))
|
||||
|
||||
|
||||
class PolicyScheduler:
|
||||
|
||||
@@ -77,7 +77,7 @@ class FileMetadata:
|
||||
batch_storage: Dict[str, BatchResponse] = {}
|
||||
file_id_request: Dict[str, FileMetadata] = {}
|
||||
file_id_response: Dict[str, FileResponse] = {}
|
||||
# map file id to file path in SGlang backend
|
||||
# map file id to file path in SGLang backend
|
||||
file_id_storage: Dict[str, str] = {}
|
||||
|
||||
|
||||
@@ -335,7 +335,7 @@ async def process_batch(tokenizer_manager, batch_id: str, batch_request: BatchRe
|
||||
}
|
||||
|
||||
except Exception as e:
|
||||
print("error in SGlang:", e)
|
||||
print("error in SGLang:", e)
|
||||
# Update batch status to "failed"
|
||||
retrieve_batch = batch_storage[batch_id]
|
||||
retrieve_batch.status = "failed"
|
||||
|
||||
@@ -64,7 +64,7 @@ class ServerArgs:
|
||||
|
||||
# Other
|
||||
api_key: Optional[str] = None
|
||||
file_storage_pth: str = "SGlang_storage"
|
||||
file_storage_pth: str = "SGLang_storage"
|
||||
|
||||
# Data parallelism
|
||||
dp_size: int = 1
|
||||
|
||||
@@ -398,6 +398,8 @@ def popen_launch_server(
|
||||
timeout: float,
|
||||
api_key: Optional[str] = None,
|
||||
other_args: tuple = (),
|
||||
env: Optional[dict] = None,
|
||||
return_stdout_stderr: bool = False,
|
||||
):
|
||||
_, host, port = base_url.split(":")
|
||||
host = host[2:]
|
||||
@@ -417,7 +419,16 @@ def popen_launch_server(
|
||||
if api_key:
|
||||
command += ["--api-key", api_key]
|
||||
|
||||
process = subprocess.Popen(command, stdout=None, stderr=None)
|
||||
if return_stdout_stderr:
|
||||
process = subprocess.Popen(
|
||||
command,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
env=env,
|
||||
text=True,
|
||||
)
|
||||
else:
|
||||
process = subprocess.Popen(command, stdout=None, stderr=None, env=env)
|
||||
|
||||
start_time = time.time()
|
||||
while time.time() - start_time < timeout:
|
||||
|
||||
Reference in New Issue
Block a user