config: resolution declares, and nothing writes a field (#36618)
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
d1f14431fd
commit
bd4bb1781a
@@ -190,10 +190,8 @@ def resolving_view(server_args: Any) -> ResolvingConfig:
|
||||
return ResolvingConfig(server_args)
|
||||
|
||||
|
||||
# Ordered post-process passes (the normalization stage). List order is the
|
||||
# end-state execution order and mirrors today's handler call sequence in
|
||||
# __post_init__; during the transition each pass is invoked from its legacy
|
||||
# slot via run_post_process_pass, so ordering is preserved byte-for-byte.
|
||||
# Registered post-process passes. This is a registry, not an execution order:
|
||||
# each pass is invoked from its own slot via run_post_process_pass.
|
||||
POST_PROCESS_PASSES: List[Callable[..., dict]] = []
|
||||
|
||||
|
||||
@@ -223,11 +221,29 @@ def run_post_process_pass(server_args: Any, fn: Callable[..., dict]) -> None:
|
||||
|
||||
Evaluates the pass on the resolving state (a read-only view with the
|
||||
accumulated declarations overlaid from the stash) and appends its
|
||||
declaration to the stash. During ``__post_init__`` the fields stay
|
||||
untouched: the stash is what the config bags are projected from. A pass
|
||||
invoked after resolution finished (a post-init slot) writes through
|
||||
immediately, because there is no later projection to pick it up.
|
||||
declaration to the stash, which is what the config bags are projected from.
|
||||
The fields stay untouched.
|
||||
|
||||
A slot that runs after resolution -- ``check_server_args`` hosts one -- lands
|
||||
in the same stash, which publish projects from later, so it needs no field
|
||||
write either. After *publish* there is no such later projection: the stash
|
||||
would grow an entry nothing reads. So, like ``declare_late_resolution``,
|
||||
this refuses the published record -- post-publish changes go to the bags
|
||||
through ``get_context().override(...)``.
|
||||
"""
|
||||
from sglang.srt.runtime_context import get_context
|
||||
|
||||
try:
|
||||
published = get_context().server_args
|
||||
except ValueError:
|
||||
published = None
|
||||
if published is server_args:
|
||||
raise ValueError(
|
||||
f"run_post_process_pass({fn.__qualname__!r}) called on the published "
|
||||
"config; the stash is projected at publish and never again, so a "
|
||||
"declaration made here would be a silent no-op -- post-publish "
|
||||
"changes go to the bags via get_context().override(...)"
|
||||
)
|
||||
declared = fn(ResolvedView(server_args, overlay=_declaration_overlay(server_args)))
|
||||
if not isinstance(declared, dict):
|
||||
raise TypeError(
|
||||
@@ -246,13 +262,15 @@ def run_post_process_pass(server_args: Any, fn: Callable[..., dict]) -> None:
|
||||
stash = server_args._resolved_overrides = []
|
||||
stash.append(entry)
|
||||
validate_declarations(server_args, [entry])
|
||||
if getattr(server_args, "_resolution_finished", False):
|
||||
_apply_fields(server_args, declared)
|
||||
|
||||
|
||||
def _apply_fields(server_args: Any, fields: Dict[str, Any]) -> None:
|
||||
"""Write fields on behalf of the pipeline (bypasses the strict bare-
|
||||
assignment guard that protects post-resolution mutation)."""
|
||||
"""Write record fields past the guard that forbids post-resolution writes.
|
||||
|
||||
Resolution declares, so nothing in the pipeline calls this. It exists for
|
||||
``RuntimeContext.override_server_args``, the launch stand-in tests use: there
|
||||
the caller's values are both the operator's input and resolution's answer.
|
||||
"""
|
||||
object.__setattr__(server_args, "_internal_write", True)
|
||||
try:
|
||||
for field, value in fields.items():
|
||||
@@ -1745,9 +1763,7 @@ def _step3p_overrides(server_args: Any, hf_config: Any) -> dict:
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Post-process passes (normalization stage), in end-state execution order.
|
||||
# Faithful ports of the legacy __post_init__ handlers; each is invoked from
|
||||
# its legacy slot via run_post_process_pass during the transition.
|
||||
# Post-process passes (normalization stage).
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -2803,6 +2819,7 @@ def _moe_runner_fusion_disable(view: Any) -> dict:
|
||||
return {}
|
||||
|
||||
|
||||
@register_post_process
|
||||
def _a2a_fusion_adjustments(view: Any) -> dict:
|
||||
"""A2A-backend-driven shared-experts fusion adjustments, declared at the
|
||||
legacy write slots in _handle_a2a_moe: Waterfill requires the
|
||||
@@ -2982,6 +2999,7 @@ def validate_declarations(
|
||||
)
|
||||
|
||||
|
||||
@register_post_process
|
||||
def _hrm_text_attention_force(view: Any) -> dict:
|
||||
"""HRM-Text's bidirectional prefix attention only works on the Triton
|
||||
backend. Invoked as the last attention declaration of the resolution
|
||||
|
||||
Reference in New Issue
Block a user