A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 4, 20:00 UTC
[Bugfix] [Reasoning] Add reasoning_start_str/reasoning_end_str properties to reasoning parsers (#40566)
Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
Chauncey committed
Apr 22, 2026 at 15:27 UTC
a2bd09c960e584b5df1481de21cdc9a2b08c3e8b
5 files changed
+41
vllm/reasoning/deepseek_v3_reasoning_parser.py
+8
@@ -40,6 +40,14 @@ class DeepSeekV3ReasoningParser(ReasoningParser):
40
else:
41
self._parser = IdentityReasoningParser(tokenizer, *args, **kwargs)
42
43
+ @property
44
+ def reasoning_start_str(self) -> str | None:
45
+ return self._parser.reasoning_start_str
46
+
47
+ @property
48
+ def reasoning_end_str(self) -> str | None:
49
+ return self._parser.reasoning_end_str
50
+
51
def is_reasoning_end(self, input_ids: Sequence[int]) -> bool:
52
return self._parser.is_reasoning_end(input_ids)
53
vllm/reasoning/identity_reasoning_parser.py
+8
@@ -33,6 +33,14 @@ class IdentityReasoningParser(ReasoningParser):
33
"constructor during construction."
34
)
35
36
+ @property
37
+ def reasoning_start_str(self) -> str | None:
38
+ return None
39
+
40
+ @property
41
+ def reasoning_end_str(self) -> str | None:
42
+ return None
43
+
44
def is_reasoning_end(self, input_ids: Sequence[int]) -> bool:
45
# Always return True, since we never treat reasoning specially
46
return True
vllm/reasoning/kimi_k2_reasoning_parser.py
+8
@@ -65,6 +65,14 @@ class KimiK2ReasoningParser(ReasoningParser):
65
"tokens in the tokenizer!"
66
)
67
68
+ @property
69
+ def reasoning_start_str(self) -> str | None:
70
+ return self._start_token
71
+
72
+ @property
73
+ def reasoning_end_str(self) -> str | None:
74
+ return self._end_token
75
+
76
def is_reasoning_end(self, input_ids: Sequence[int]) -> bool:
77
"""
78
Check if the reasoning content ends in the input_ids.
vllm/reasoning/olmo3_reasoning_parser.py
+8
@@ -237,6 +237,14 @@ class Olmo3ReasoningParser(ReasoningParser):
237
think_start=self.think_start, think_end=self.think_end
238
)
239
240
+ @property
241
+ def reasoning_start_str(self) -> str:
242
+ return self.think_start
243
+
244
+ @property
245
+ def reasoning_end_str(self) -> str:
246
+ return self.think_end
247
+
248
def is_reasoning_end(self, input_ids: Sequence[int]) -> bool:
249
text = self.model_tokenizer.decode(input_ids)
250
return self.think_end in text
vllm/reasoning/step3_reasoning_parser.py
+9
@@ -29,6 +29,7 @@ class Step3ReasoningParser(ReasoningParser):
29
30
def __init__(self, tokenizer: PreTrainedTokenizerBase, *args, **kwargs):
31
super().__init__(tokenizer, *args, **kwargs)
32
+ self.think_start_token = "<think>"
33
self.think_end_token = "</think>"
34
35
self.reasoning_regex = re.compile(rf"(.*?){self.think_end_token}", re.DOTALL)
@@ -47,6 +48,14 @@ class Step3ReasoningParser(ReasoningParser):
48
)
49
self.think_end_token_id: int = think_end_token_id
50
51
+ @property
52
+ def reasoning_start_str(self) -> str:
53
+ return self.think_start_token
54
+
55
+ @property
56
+ def reasoning_end_str(self) -> str:
57
+ return self.think_end_token
58
+
59
def extract_reasoning_streaming(
60
self,
61
previous_text: str,