[refactor] Update reasoning parameter to require_reasoning (#14922)

Signed-off-by: Xinyuan Tong <xinyuantong.cs@gmail.com>
This commit is contained in:
Xinyuan Tong
2025-12-11 16:55:59 -08:00
committed by GitHub
parent 70758d457e
commit 9975acf50f
7 changed files with 21 additions and 21 deletions
@@ -364,7 +364,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"> Note: For native API, as a work-around, you need to set `reasoning` argument to `True` to ensure the model will think before generating the structured output. It's not required for chat-completion API."
"> Note: For native API, as a work-around, you need to set `require_reasoning` argument to `True` to ensure the model will think before generating the structured output. It's not required for chat-completion API."
]
},
{
@@ -414,7 +414,7 @@
" f\"http://localhost:{port}/generate\",\n",
" json={\n",
" \"text\": text,\n",
" \"reasoning\": True,\n",
" \"require_reasoning\": True,\n",
" \"sampling_params\": {\n",
" \"temperature\": 0,\n",
" \"max_new_tokens\": 2048,\n",
@@ -462,7 +462,7 @@
" f\"http://localhost:{port}/generate\",\n",
" json={\n",
" \"text\": text,\n",
" \"reasoning\": True,\n",
" \"require_reasoning\": True,\n",
" \"sampling_params\": {\n",
" \"temperature\": 0,\n",
" \"max_new_tokens\": 2048,\n",
@@ -491,7 +491,7 @@
" f\"http://localhost:{port}/generate\",\n",
" json={\n",
" \"text\": \"Give me the information of the capital of France.\",\n",
" \"reasoning\": True,\n",
" \"require_reasoning\": True,\n",
" \"sampling_params\": {\n",
" \"max_new_tokens\": 2048,\n",
" \"temperature\": 0,\n",
@@ -529,7 +529,7 @@
" f\"http://localhost:{port}/generate\",\n",
" json={\n",
" \"text\": \"Paris is the capital of\",\n",
" \"reasoning\": True,\n",
" \"require_reasoning\": True,\n",
" \"sampling_params\": {\n",
" \"temperature\": 0,\n",
" \"max_new_tokens\": 2048,\n",
@@ -558,7 +558,7 @@
")\n",
"payload = {\n",
" \"text\": text,\n",
" \"reasoning\": True,\n",
" \"require_reasoning\": True,\n",
" \"sampling_params\": {\n",
" \"max_new_tokens\": 2048,\n",
" \"structural_tag\": json.dumps(\n",
@@ -155,7 +155,7 @@ class BaseGrammarBackend:
return self._not_supported("structural_tag", key_string)
def _init_value_dispatch(
self, key: Tuple[str, str], reasoning: bool
self, key: Tuple[str, str], require_reasoning: bool
) -> Optional[BaseGrammarObject]:
s = time.perf_counter()
key_type, key_string = key
@@ -179,14 +179,14 @@ class BaseGrammarBackend:
return grammar
def get_cached_or_future_value(
self, key: Tuple[str, str], reasoning: bool
self, key: Tuple[str, str], require_reasoning: bool
) -> Optional[BaseGrammarObject]:
value = self.cache.get(key)
if value:
copied_value = value.copy()
copied_value.maybe_init_reasoning(reasoning)
copied_value.maybe_init_reasoning(require_reasoning)
return copied_value, True
value = self.executor.submit(self._init_value_dispatch, key, reasoning)
value = self.executor.submit(self._init_value_dispatch, key, require_reasoning)
return value, False
def set_cache(self, key: Tuple[str, str], value: BaseGrammarObject):
@@ -214,7 +214,7 @@ class OpenAIServingChat(OpenAIServingBase):
return_hidden_states=request.return_hidden_states,
rid=request.rid,
extra_key=self._compute_extra_key(request),
reasoning=self._get_reasoning_from_request(request),
require_reasoning=self._get_reasoning_from_request(request),
priority=request.priority,
custom_labels=custom_labels,
custom_logit_processor=request.custom_logit_processor,
+4 -4
View File
@@ -215,8 +215,8 @@ class GenerateReqInput(BaseReq, APIServingTimingMixin):
bootstrap_pair_key: Optional[Union[List[str], str]] = None
decode_tp_size: Optional[Union[List[Optional[int]], int]] = None
# For reasoning
reasoning: bool = False
# Require reasoning for the request (hybrid reasoning model only)
require_reasoning: bool = False
# For data parallel rank routing
data_parallel_rank: Optional[int] = None
@@ -700,8 +700,8 @@ class TokenizedGenerateReqInput(BaseReq):
bootstrap_pair_key: Optional[str] = None
decode_tp_size: Optional[int] = None
# For reasoning
reasoning: bool = False
# Require reasoning for the request (hybrid reasoning model only)
require_reasoning: bool = False
# For data parallel rank routing
data_parallel_rank: Optional[int] = None
+3 -3
View File
@@ -472,7 +472,7 @@ class Req:
token_type_ids: List[int] = None,
session_id: Optional[str] = None,
custom_logit_processor: Optional[str] = None,
reasoning: bool = False,
require_reasoning: bool = False,
return_hidden_states: bool = False,
eos_token_ids: Optional[Set[int]] = None,
bootstrap_host: Optional[str] = None,
@@ -518,8 +518,8 @@ class Req:
# For multi-http worker
self.http_worker_ipc = http_worker_ipc
# For reasoning
self.reasoning = reasoning
# Require reasoning for the request (hybrid reasoning model only)
self.require_reasoning = require_reasoning
# Sampling info
if isinstance(sampling_params.custom_params, dict):
+2 -2
View File
@@ -1314,7 +1314,7 @@ class Scheduler(
lora_id=recv_req.lora_id,
input_embeds=recv_req.input_embeds,
custom_logit_processor=recv_req.custom_logit_processor,
reasoning=recv_req.reasoning,
require_reasoning=recv_req.require_reasoning,
return_hidden_states=recv_req.return_hidden_states,
eos_token_ids=self.model_config.hf_eos_token_id,
bootstrap_host=recv_req.bootstrap_host,
@@ -1443,7 +1443,7 @@ class Scheduler(
key = ("structural_tag", req.sampling_params.structural_tag)
value, cache_hit = self.grammar_backend.get_cached_or_future_value(
key, req.reasoning
key, req.require_reasoning
)
req.grammar = value
@@ -796,7 +796,7 @@ class TokenizerManager(TokenizerCommunicatorMixin, TokenizerManagerMultiItemMixi
input_embeds=input_embeds,
session_params=session_params,
custom_logit_processor=obj.custom_logit_processor,
reasoning=obj.reasoning,
require_reasoning=obj.require_reasoning,
return_hidden_states=obj.return_hidden_states,
data_parallel_rank=obj.data_parallel_rank,
priority=obj.priority,