Support HTTP2 server (#21700)
This commit is contained in:
@@ -326,6 +326,7 @@ class ServerArgs:
|
||||
ssl_ca_certs: Optional[str] = None
|
||||
ssl_keyfile_password: Optional[str] = None
|
||||
enable_ssl_refresh: bool = False
|
||||
enable_http2: bool = False
|
||||
|
||||
# Quantization and data type
|
||||
dtype: str = "auto"
|
||||
@@ -923,6 +924,26 @@ class ServerArgs:
|
||||
"to be specified."
|
||||
)
|
||||
|
||||
if self.enable_http2:
|
||||
try:
|
||||
import granian # noqa: F401
|
||||
except ImportError:
|
||||
raise ValueError(
|
||||
"--enable-http2 requires the 'granian' package. "
|
||||
'Install it with: pip install "sglang[http2]"'
|
||||
)
|
||||
if self.enable_ssl_refresh:
|
||||
raise ValueError(
|
||||
"--enable-ssl-refresh is not supported with --enable-http2. "
|
||||
"Granian does not support SSL certificate hot-reloading. "
|
||||
"Use Uvicorn (the default) or handle certificate rotation externally."
|
||||
)
|
||||
if self.tokenizer_worker_num > 1:
|
||||
raise ValueError(
|
||||
"--enable-http2 does not yet support --tokenizer-worker-num > 1. "
|
||||
"Multi-worker HTTP/2 support will be added in a future release."
|
||||
)
|
||||
|
||||
def _handle_deprecated_args(self):
|
||||
# Handle deprecated tool call parsers
|
||||
deprecated_tool_call_parsers = {"qwen25": "qwen", "glm45": "glm"}
|
||||
@@ -3865,6 +3886,14 @@ class ServerArgs:
|
||||
help="Enable automatic SSL certificate hot-reloading when cert/key "
|
||||
"files change on disk. Requires --ssl-certfile and --ssl-keyfile.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--enable-http2",
|
||||
action="store_true",
|
||||
default=ServerArgs.enable_http2,
|
||||
help="Use Granian instead of Uvicorn as the ASGI server, enabling HTTP/1.1 and "
|
||||
"HTTP/2 auto-negotiation. Clients may use h2c (cleartext HTTP/2) or plain HTTP/1.1. "
|
||||
"Requires 'pip install sglang[http2]'.",
|
||||
)
|
||||
|
||||
# Quantization and data type
|
||||
parser.add_argument(
|
||||
|
||||
Reference in New Issue
Block a user