config: route runtime config adjustments through the namespace bags (#31812)

This commit is contained in:
Cheng Wan
2026-07-22 01:17:22 -07:00
committed by GitHub
parent 97e2c0c4ee
commit e1479cc966
31 changed files with 385 additions and 45 deletions
+14 -7
View File
@@ -241,7 +241,7 @@ from sglang.srt.observability.trace import process_tracing_init, trace_set_threa
from sglang.srt.parser.reasoning_parser import ReasoningParser
from sglang.srt.platforms import current_platform
from sglang.srt.plugins import load_plugins
from sglang.srt.runtime_context import get_parallel, get_server_args
from sglang.srt.runtime_context import get_context, get_parallel
from sglang.srt.sampling.sampling_batch_info import SamplingBatchInfo
from sglang.srt.sampling.sampling_params import TOP_K_ALL
from sglang.srt.server_args import PortArgs, ServerArgs
@@ -786,6 +786,11 @@ class Scheduler(
)
if self.server_args.speculative_draft_load_format is not None:
# Write the draft load_format onto server_args (not just the bag):
# the draft worker is built from a copy of self.server_args and
# build_load_config reads server_args.load_format, so a bag-only
# override would be ignored and the draft would load in the target's
# format.
self.server_args.override(
"scheduler.draft_load_format",
load_format=self.server_args.speculative_draft_load_format,
@@ -890,8 +895,8 @@ class Scheduler(
self.min_free_slots_delayer = MinFreeSlotsDelayer(
min_free_slots=min_free_slots
)
if not get_server_args().pp_max_micro_batch_size:
get_server_args().override(
if not get_parallel().pp_max_micro_batch_size:
get_context().override(
"scheduler.pp_max_micro_batch_size_default",
pp_max_micro_batch_size=max(
self.max_running_requests // self.ps.pp_size, 1
@@ -2837,7 +2842,7 @@ class Scheduler(
return NextBatchPlan(batch_to_run=ret, running_batch=running_batch)
def get_num_allocatable_reqs(self, running_bs):
res = get_server_args().pp_max_micro_batch_size - running_bs
res = get_parallel().pp_max_micro_batch_size - running_bs
res = min(res, self.req_to_token_pool.available_size())
return res
@@ -3893,7 +3898,9 @@ class Scheduler(
return success
def get_internal_state(self, recv_req: GetInternalStateReq):
ret = dict(vars(get_server_args())) # vars returns a ref to obj.__dict__
# Resolved config (pristine server_args + post-publish overrides) so a
# readback reflects values changed via /set_internal_state, not startup.
ret = get_context().resolved_server_args_dict()
ret["last_gen_throughput"] = self.metrics_reporter.last_gen_throughput
ret["memory_usage"] = {
"weight": round(self.tp_worker.model_runner.weight_load_mem_usage, 2),
@@ -4013,8 +4020,8 @@ class Scheduler(
if remaining.pop("dspark_clear_info_records", None):
self.draft_worker.clear_info_records()
if remaining:
get_server_args().override(source="update_server_args", **remaining)
logger.info(f"Global server args updated! {get_server_args()=}")
get_context().override(source="update_server_args", **remaining)
logger.info(f"Config updated via context override: {remaining}")
return SetInternalStateReqOutput(updated=if_success)