config: template-detected parsers go to the engine's control-plane overlay
`init_tokenizer_manager` wrote the chat-template-detected `reasoning_parser` / `tool_call_parser` onto the published `ServerArgs`, after `TokenizerManager.__init__` had already projected the config bags — so the namespace readers and the resolved-config readback disagreed with the instance, and a second `Engine` in the same process would inherit the first one's detection through the shared bags. Detection is per-engine control-plane state, which the manager already models: `record_config_updates` records it, the readback endpoints overlay it, and `config_value` reports what is in effect. `OpenAIServingChat` — the only reader of these two fields in the tokenizer process — follows the overlay. The architecture pass (`resolve_auto_parsers`, before the schedulers fork) is unchanged: the scheduler resolves its own bags from the instance it receives.
This commit is contained in:
@@ -175,10 +175,12 @@ def init_tokenizer_manager(
|
||||
"tool-call parser",
|
||||
),
|
||||
):
|
||||
if getattr(server_args, attr) != "auto":
|
||||
if tokenizer_manager.config_value(attr) != "auto":
|
||||
continue
|
||||
if suggested is not None:
|
||||
server_args.override(source="template-detection", **{attr: suggested})
|
||||
tokenizer_manager.record_config_updates(
|
||||
"template-detection", **{attr: suggested}
|
||||
)
|
||||
logger.info(
|
||||
f"Auto-detected --{attr.replace('_', '-')} as '{suggested}' from chat template"
|
||||
)
|
||||
@@ -187,7 +189,9 @@ def init_tokenizer_manager(
|
||||
f"--{attr.replace('_', '-')}=auto specified but could not detect "
|
||||
f"{label} from chat template. Disabling {label}."
|
||||
)
|
||||
server_args.override(source="template-detection", **{attr: None})
|
||||
tokenizer_manager.record_config_updates(
|
||||
"template-detection", **{attr: None}
|
||||
)
|
||||
|
||||
return tokenizer_manager, template_manager
|
||||
|
||||
|
||||
@@ -203,8 +203,8 @@ class OpenAIServingChat(OpenAIServingBase):
|
||||
):
|
||||
super().__init__(tokenizer_manager)
|
||||
self.template_manager = template_manager
|
||||
self.tool_call_parser = self.tokenizer_manager.server_args.tool_call_parser
|
||||
self.reasoning_parser = self.tokenizer_manager.server_args.reasoning_parser
|
||||
self.tool_call_parser = self.tokenizer_manager.config_value("tool_call_parser")
|
||||
self.reasoning_parser = self.tokenizer_manager.config_value("reasoning_parser")
|
||||
self.default_chat_template_kwargs = (
|
||||
self.tokenizer_manager.server_args.default_chat_template_kwargs or {}
|
||||
)
|
||||
@@ -1049,9 +1049,7 @@ class OpenAIServingChat(OpenAIServingBase):
|
||||
# SGLang's ReasonerGrammarBackend owns the reasoning prefix
|
||||
# when --reasoning-parser is configured, so builtin xgrammar
|
||||
# tags must describe only the post-reasoning tool-call suffix.
|
||||
xgrammar_reasoning = thinking_mode and (
|
||||
self.tokenizer_manager.server_args.reasoning_parser is None
|
||||
)
|
||||
xgrammar_reasoning = thinking_mode and (self.reasoning_parser is None)
|
||||
tool_call_constraint = None
|
||||
|
||||
# Apply chat template and its stop strings
|
||||
|
||||
@@ -97,8 +97,8 @@ class OpenAIServingResponses(OpenAIServingChat):
|
||||
) -> None:
|
||||
super().__init__(tokenizer_manager, template_manager)
|
||||
|
||||
# template_manager is already set by parent class
|
||||
self.reasoning_parser = self.tokenizer_manager.server_args.reasoning_parser
|
||||
# template_manager is already set by parent class; reasoning_parser comes
|
||||
# from the parent, which reads the manager's control-plane overlay.
|
||||
self.enable_prompt_tokens_details = enable_prompt_tokens_details
|
||||
|
||||
# Parent OpenAIServingChat.__init__ already populated default_sampling_params.
|
||||
|
||||
Reference in New Issue
Block a user