Convert IPC dataclasses to msgspec.Struct with opt-in msgpack transport (#28688)
Co-authored-by: Lianmin Zheng <lianminzheng@gmail.com>
This commit is contained in:
co-authored by
Lianmin Zheng
parent
714011a40f
commit
be1930133a
@@ -173,6 +173,7 @@ from sglang.srt.utils.json_response import (
|
||||
dumps_json,
|
||||
orjson_response,
|
||||
)
|
||||
from sglang.srt.utils.msgspec_utils import msgspec_to_builtins
|
||||
from sglang.srt.utils.watchdog import SubprocessWatchdog
|
||||
from sglang.utils import get_exception_traceback
|
||||
from sglang.version import __version__
|
||||
@@ -698,16 +699,18 @@ async def server_info():
|
||||
server_args = _global_state.tokenizer_manager.server_args
|
||||
|
||||
# server_args.model_config is not serializable but should be excluded by asdict.
|
||||
return {
|
||||
**dataclasses.asdict(server_args),
|
||||
**_global_state.scheduler_info,
|
||||
"internal_states": internal_states,
|
||||
"version": __version__,
|
||||
# Structured KV-event publisher descriptor for KV-aware routers.
|
||||
# `None` when publishing is disabled or misconfigured; see
|
||||
# `ServerArgs.describe_kv_events_publisher` for the precise contract.
|
||||
"kv_events": server_args.describe_kv_events_publisher(),
|
||||
}
|
||||
return msgspec_to_builtins(
|
||||
{
|
||||
**dataclasses.asdict(server_args),
|
||||
**_global_state.scheduler_info,
|
||||
"internal_states": internal_states,
|
||||
"version": __version__,
|
||||
# Structured KV-event publisher descriptor for KV-aware routers.
|
||||
# `None` when publishing is disabled or misconfigured; see
|
||||
# `ServerArgs.describe_kv_events_publisher` for the precise contract.
|
||||
"kv_events": server_args.describe_kv_events_publisher(),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@app.get("/get_load")
|
||||
@@ -1417,7 +1420,7 @@ async def load_lora_adapter(
|
||||
"""Load a new LoRA adapter without re-launching the server."""
|
||||
result = await _global_state.tokenizer_manager.load_lora_adapter(obj, request)
|
||||
status_code = HTTPStatus.OK if result.success else HTTPStatus.BAD_REQUEST
|
||||
return ORJSONResponse(result, status_code=status_code)
|
||||
return ORJSONResponse(msgspec_to_builtins(result), status_code=status_code)
|
||||
|
||||
|
||||
@app.api_route("/load_lora_adapter_from_tensors", methods=["POST"])
|
||||
@@ -1429,7 +1432,7 @@ async def load_lora_adapter_from_tensors(
|
||||
obj, request
|
||||
)
|
||||
status_code = HTTPStatus.OK if result.success else HTTPStatus.BAD_REQUEST
|
||||
return ORJSONResponse(result, status_code=status_code)
|
||||
return ORJSONResponse(msgspec_to_builtins(result), status_code=status_code)
|
||||
|
||||
|
||||
@app.api_route("/unload_lora_adapter", methods=["POST"])
|
||||
@@ -1440,7 +1443,7 @@ async def unload_lora_adapter(
|
||||
"""Load a new LoRA adapter without re-launching the server."""
|
||||
result = await _global_state.tokenizer_manager.unload_lora_adapter(obj, request)
|
||||
status_code = HTTPStatus.OK if result.success else HTTPStatus.BAD_REQUEST
|
||||
return ORJSONResponse(result, status_code=status_code)
|
||||
return ORJSONResponse(msgspec_to_builtins(result), status_code=status_code)
|
||||
|
||||
|
||||
@app.api_route("/open_session", methods=["GET", "POST"])
|
||||
|
||||
Reference in New Issue
Block a user