config: retire ServerArgs.override in favour of derive()
`ServerArgs.override(source, **fields)` was the last way to change a resolved
`ServerArgs` in place. Every remaining call-site was one of two things, and
neither wanted an in-place write:
- **A config for someone else.** A draft worker's context length, an encode
worker's device, the compile script's watchdog, the client's port pick, a test
fixture's backends. These already deepcopied first — the write was on the copy.
- **A launcher-stage resolution.** `resolve_auto_parsers` detected the chat
template's parsers and wrote them back, to be inherited by the schedulers it
spawns.
Both are "one config becomes another", so `derive(source, **fields)` returns the
variant and leaves the receiver — and any bags projected from it — untouched. It
deliberately is not `dataclasses.replace`: resolution does not re-run, because
the values being set are decided after it, from inputs it never had. Provenance
and the resolvable-field stash work as before, on the copy.
`resolve_auto_parsers` now computes the parsers and returns the config to launch
with; the detection helpers stop taking a config to mutate. `HiMambaRadixCache`
re-applied a HiCache layout normalization `__post_init__` already performs (the
same duplicate removed from `UnifiedRadixCache` in ebb1c88d23) and just goes.
With no in-place mutation left, `ServerArgs.__setattr__` raising after
resolution *is* the guarantee, so the textual writer ratchet retires and
`test_server_args_derive.py` pins the contract instead: the receiver survives
deriving, the published instance still refuses assignment, and deriving does not
publish. `SGLANG_STRICT_CONFIG_MUTATION` was already unused — the guard has been
unconditional since the mutation sweep — and goes with it.
The detection tests drop their `SimpleNamespace` stand-in for a real
`ServerArgs`; the test kit and the MLA chunk-metadata fixture publish a derived
variant instead of writing the runner's published config.
This commit is contained in:
@@ -1011,8 +1011,7 @@ class _ServerArgsOverride:
|
||||
|
||||
def install(self) -> ServerArgs:
|
||||
"""Publish a fresh dummy-boundary ``ServerArgs`` carrying the
|
||||
overrides (written through ``ServerArgs.override`` for provenance);
|
||||
returns the published instance."""
|
||||
overrides; returns the published instance."""
|
||||
from sglang.srt.server_args import ServerArgs
|
||||
|
||||
assert not self._installed, "override_server_args already installed"
|
||||
@@ -1025,7 +1024,7 @@ class _ServerArgsOverride:
|
||||
self._prev_capture = ctx.flags.capture.enable_torch_compile
|
||||
server_args = ServerArgs(model_path="dummy")
|
||||
if self._fields:
|
||||
server_args.override(source="test-override", **self._fields)
|
||||
server_args = server_args.derive("test-override", **self._fields)
|
||||
# The dummy boundary skips materialization, which would leave the
|
||||
# strict mutation guard unarmed on the published object — mark it
|
||||
# materialized so bare post-publish writes raise like they do on a
|
||||
|
||||
Reference in New Issue
Block a user