[refactor] Update reasoning parameter to require_reasoning (#14922)
Signed-off-by: Xinyuan Tong <xinyuantong.cs@gmail.com>
This commit is contained in:
@@ -364,7 +364,7 @@
|
|||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"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",
|
" f\"http://localhost:{port}/generate\",\n",
|
||||||
" json={\n",
|
" json={\n",
|
||||||
" \"text\": text,\n",
|
" \"text\": text,\n",
|
||||||
" \"reasoning\": True,\n",
|
" \"require_reasoning\": True,\n",
|
||||||
" \"sampling_params\": {\n",
|
" \"sampling_params\": {\n",
|
||||||
" \"temperature\": 0,\n",
|
" \"temperature\": 0,\n",
|
||||||
" \"max_new_tokens\": 2048,\n",
|
" \"max_new_tokens\": 2048,\n",
|
||||||
@@ -462,7 +462,7 @@
|
|||||||
" f\"http://localhost:{port}/generate\",\n",
|
" f\"http://localhost:{port}/generate\",\n",
|
||||||
" json={\n",
|
" json={\n",
|
||||||
" \"text\": text,\n",
|
" \"text\": text,\n",
|
||||||
" \"reasoning\": True,\n",
|
" \"require_reasoning\": True,\n",
|
||||||
" \"sampling_params\": {\n",
|
" \"sampling_params\": {\n",
|
||||||
" \"temperature\": 0,\n",
|
" \"temperature\": 0,\n",
|
||||||
" \"max_new_tokens\": 2048,\n",
|
" \"max_new_tokens\": 2048,\n",
|
||||||
@@ -491,7 +491,7 @@
|
|||||||
" f\"http://localhost:{port}/generate\",\n",
|
" f\"http://localhost:{port}/generate\",\n",
|
||||||
" json={\n",
|
" json={\n",
|
||||||
" \"text\": \"Give me the information of the capital of France.\",\n",
|
" \"text\": \"Give me the information of the capital of France.\",\n",
|
||||||
" \"reasoning\": True,\n",
|
" \"require_reasoning\": True,\n",
|
||||||
" \"sampling_params\": {\n",
|
" \"sampling_params\": {\n",
|
||||||
" \"max_new_tokens\": 2048,\n",
|
" \"max_new_tokens\": 2048,\n",
|
||||||
" \"temperature\": 0,\n",
|
" \"temperature\": 0,\n",
|
||||||
@@ -529,7 +529,7 @@
|
|||||||
" f\"http://localhost:{port}/generate\",\n",
|
" f\"http://localhost:{port}/generate\",\n",
|
||||||
" json={\n",
|
" json={\n",
|
||||||
" \"text\": \"Paris is the capital of\",\n",
|
" \"text\": \"Paris is the capital of\",\n",
|
||||||
" \"reasoning\": True,\n",
|
" \"require_reasoning\": True,\n",
|
||||||
" \"sampling_params\": {\n",
|
" \"sampling_params\": {\n",
|
||||||
" \"temperature\": 0,\n",
|
" \"temperature\": 0,\n",
|
||||||
" \"max_new_tokens\": 2048,\n",
|
" \"max_new_tokens\": 2048,\n",
|
||||||
@@ -558,7 +558,7 @@
|
|||||||
")\n",
|
")\n",
|
||||||
"payload = {\n",
|
"payload = {\n",
|
||||||
" \"text\": text,\n",
|
" \"text\": text,\n",
|
||||||
" \"reasoning\": True,\n",
|
" \"require_reasoning\": True,\n",
|
||||||
" \"sampling_params\": {\n",
|
" \"sampling_params\": {\n",
|
||||||
" \"max_new_tokens\": 2048,\n",
|
" \"max_new_tokens\": 2048,\n",
|
||||||
" \"structural_tag\": json.dumps(\n",
|
" \"structural_tag\": json.dumps(\n",
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ class BaseGrammarBackend:
|
|||||||
return self._not_supported("structural_tag", key_string)
|
return self._not_supported("structural_tag", key_string)
|
||||||
|
|
||||||
def _init_value_dispatch(
|
def _init_value_dispatch(
|
||||||
self, key: Tuple[str, str], reasoning: bool
|
self, key: Tuple[str, str], require_reasoning: bool
|
||||||
) -> Optional[BaseGrammarObject]:
|
) -> Optional[BaseGrammarObject]:
|
||||||
s = time.perf_counter()
|
s = time.perf_counter()
|
||||||
key_type, key_string = key
|
key_type, key_string = key
|
||||||
@@ -179,14 +179,14 @@ class BaseGrammarBackend:
|
|||||||
return grammar
|
return grammar
|
||||||
|
|
||||||
def get_cached_or_future_value(
|
def get_cached_or_future_value(
|
||||||
self, key: Tuple[str, str], reasoning: bool
|
self, key: Tuple[str, str], require_reasoning: bool
|
||||||
) -> Optional[BaseGrammarObject]:
|
) -> Optional[BaseGrammarObject]:
|
||||||
value = self.cache.get(key)
|
value = self.cache.get(key)
|
||||||
if value:
|
if value:
|
||||||
copied_value = value.copy()
|
copied_value = value.copy()
|
||||||
copied_value.maybe_init_reasoning(reasoning)
|
copied_value.maybe_init_reasoning(require_reasoning)
|
||||||
return copied_value, True
|
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
|
return value, False
|
||||||
|
|
||||||
def set_cache(self, key: Tuple[str, str], value: BaseGrammarObject):
|
def set_cache(self, key: Tuple[str, str], value: BaseGrammarObject):
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ class OpenAIServingChat(OpenAIServingBase):
|
|||||||
return_hidden_states=request.return_hidden_states,
|
return_hidden_states=request.return_hidden_states,
|
||||||
rid=request.rid,
|
rid=request.rid,
|
||||||
extra_key=self._compute_extra_key(request),
|
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,
|
priority=request.priority,
|
||||||
custom_labels=custom_labels,
|
custom_labels=custom_labels,
|
||||||
custom_logit_processor=request.custom_logit_processor,
|
custom_logit_processor=request.custom_logit_processor,
|
||||||
|
|||||||
@@ -215,8 +215,8 @@ class GenerateReqInput(BaseReq, APIServingTimingMixin):
|
|||||||
bootstrap_pair_key: Optional[Union[List[str], str]] = None
|
bootstrap_pair_key: Optional[Union[List[str], str]] = None
|
||||||
decode_tp_size: Optional[Union[List[Optional[int]], int]] = None
|
decode_tp_size: Optional[Union[List[Optional[int]], int]] = None
|
||||||
|
|
||||||
# For reasoning
|
# Require reasoning for the request (hybrid reasoning model only)
|
||||||
reasoning: bool = False
|
require_reasoning: bool = False
|
||||||
|
|
||||||
# For data parallel rank routing
|
# For data parallel rank routing
|
||||||
data_parallel_rank: Optional[int] = None
|
data_parallel_rank: Optional[int] = None
|
||||||
@@ -700,8 +700,8 @@ class TokenizedGenerateReqInput(BaseReq):
|
|||||||
bootstrap_pair_key: Optional[str] = None
|
bootstrap_pair_key: Optional[str] = None
|
||||||
decode_tp_size: Optional[int] = None
|
decode_tp_size: Optional[int] = None
|
||||||
|
|
||||||
# For reasoning
|
# Require reasoning for the request (hybrid reasoning model only)
|
||||||
reasoning: bool = False
|
require_reasoning: bool = False
|
||||||
|
|
||||||
# For data parallel rank routing
|
# For data parallel rank routing
|
||||||
data_parallel_rank: Optional[int] = None
|
data_parallel_rank: Optional[int] = None
|
||||||
|
|||||||
@@ -472,7 +472,7 @@ class Req:
|
|||||||
token_type_ids: List[int] = None,
|
token_type_ids: List[int] = None,
|
||||||
session_id: Optional[str] = None,
|
session_id: Optional[str] = None,
|
||||||
custom_logit_processor: Optional[str] = None,
|
custom_logit_processor: Optional[str] = None,
|
||||||
reasoning: bool = False,
|
require_reasoning: bool = False,
|
||||||
return_hidden_states: bool = False,
|
return_hidden_states: bool = False,
|
||||||
eos_token_ids: Optional[Set[int]] = None,
|
eos_token_ids: Optional[Set[int]] = None,
|
||||||
bootstrap_host: Optional[str] = None,
|
bootstrap_host: Optional[str] = None,
|
||||||
@@ -518,8 +518,8 @@ class Req:
|
|||||||
# For multi-http worker
|
# For multi-http worker
|
||||||
self.http_worker_ipc = http_worker_ipc
|
self.http_worker_ipc = http_worker_ipc
|
||||||
|
|
||||||
# For reasoning
|
# Require reasoning for the request (hybrid reasoning model only)
|
||||||
self.reasoning = reasoning
|
self.require_reasoning = require_reasoning
|
||||||
|
|
||||||
# Sampling info
|
# Sampling info
|
||||||
if isinstance(sampling_params.custom_params, dict):
|
if isinstance(sampling_params.custom_params, dict):
|
||||||
|
|||||||
@@ -1314,7 +1314,7 @@ class Scheduler(
|
|||||||
lora_id=recv_req.lora_id,
|
lora_id=recv_req.lora_id,
|
||||||
input_embeds=recv_req.input_embeds,
|
input_embeds=recv_req.input_embeds,
|
||||||
custom_logit_processor=recv_req.custom_logit_processor,
|
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,
|
return_hidden_states=recv_req.return_hidden_states,
|
||||||
eos_token_ids=self.model_config.hf_eos_token_id,
|
eos_token_ids=self.model_config.hf_eos_token_id,
|
||||||
bootstrap_host=recv_req.bootstrap_host,
|
bootstrap_host=recv_req.bootstrap_host,
|
||||||
@@ -1443,7 +1443,7 @@ class Scheduler(
|
|||||||
key = ("structural_tag", req.sampling_params.structural_tag)
|
key = ("structural_tag", req.sampling_params.structural_tag)
|
||||||
|
|
||||||
value, cache_hit = self.grammar_backend.get_cached_or_future_value(
|
value, cache_hit = self.grammar_backend.get_cached_or_future_value(
|
||||||
key, req.reasoning
|
key, req.require_reasoning
|
||||||
)
|
)
|
||||||
req.grammar = value
|
req.grammar = value
|
||||||
|
|
||||||
|
|||||||
@@ -796,7 +796,7 @@ class TokenizerManager(TokenizerCommunicatorMixin, TokenizerManagerMultiItemMixi
|
|||||||
input_embeds=input_embeds,
|
input_embeds=input_embeds,
|
||||||
session_params=session_params,
|
session_params=session_params,
|
||||||
custom_logit_processor=obj.custom_logit_processor,
|
custom_logit_processor=obj.custom_logit_processor,
|
||||||
reasoning=obj.reasoning,
|
require_reasoning=obj.require_reasoning,
|
||||||
return_hidden_states=obj.return_hidden_states,
|
return_hidden_states=obj.return_hidden_states,
|
||||||
data_parallel_rank=obj.data_parallel_rank,
|
data_parallel_rank=obj.data_parallel_rank,
|
||||||
priority=obj.priority,
|
priority=obj.priority,
|
||||||
|
|||||||
Reference in New Issue
Block a user