Test the case when max_new_tokens is very large (#1038)

This commit is contained in:
Lianmin Zheng
2024-08-11 16:41:03 -07:00
committed by GitHub
parent d785412077
commit d84c5e70f7
7 changed files with 100 additions and 14 deletions

View File

@@ -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:

View File

@@ -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:

View File

@@ -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"

View File

@@ -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