[Frontend] [Parser] Migrate Nemotron V3 to streaming parser engine (#45755)

Signed-off-by: Ben Browning <bbrownin@redhat.com>
This commit is contained in:
Ben Browning
2026-06-16 05:31:21 +00:00
committed by GitHub
parent 259ff891be
commit f3858d5422
12 changed files with 771 additions and 172 deletions
+2 -2
View File
@@ -101,8 +101,8 @@ _REASONING_PARSERS_TO_REGISTER = {
"MistralReasoningParser",
),
"nemotron_v3": (
"nemotron_v3_reasoning_parser",
"NemotronV3ReasoningParser",
"nemotron_v3_engine_reasoning_parser",
"NemotronV3ParserReasoningAdapter",
),
"olmo3": (
"olmo3_reasoning_parser",
@@ -0,0 +1,8 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
from vllm.parser.engine.registered_adapters import (
NemotronV3ParserReasoningAdapter,
)
__all__ = ["NemotronV3ParserReasoningAdapter"]
@@ -1,48 +0,0 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
from vllm.entrypoints.openai.chat_completion.protocol import (
ChatCompletionRequest,
)
from vllm.entrypoints.openai.responses.protocol import (
ResponsesRequest,
)
from vllm.reasoning.deepseek_r1_reasoning_parser import DeepSeekR1ReasoningParser
class NemotronV3ReasoningParser(DeepSeekR1ReasoningParser):
"""
Reasoning parser for Nemotron V3 models.
"""
def _should_force_content(
self, request: ChatCompletionRequest | ResponsesRequest
) -> bool:
chat_template_kwargs = getattr(request, "chat_template_kwargs", None)
return bool(
chat_template_kwargs
and (
chat_template_kwargs.get("enable_thinking") is False
or chat_template_kwargs.get("force_nonempty_content") is True
)
)
def extract_reasoning(
self, model_output: str, request: ChatCompletionRequest | ResponsesRequest
) -> tuple[str | None, str | None]:
reasoning, final_content = super().extract_reasoning(model_output, request)
if self._should_force_content(request) and (
final_content is None or not final_content.strip()
):
reasoning, final_content = final_content, reasoning
return reasoning, final_content
def get_streaming_fallback_content(
self, text: str, request: ChatCompletionRequest | ResponsesRequest
) -> str | None:
"""Reasoning to duplicate into content on the terminal streaming delta."""
if not self._should_force_content(request):
return None
reasoning, _ = super().extract_reasoning(text, request)
return reasoning