@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / 2990cee95b
Fork 0

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 15, 12:15 UTC

[Feature] The Qwen3 reasoning parser supports guided decoding (#17466)

Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>

Chauncey committed Apr 30, 2025 at 22:48 UTC 2990cee95bb74394fb56c6fb6cc994fa80acbc86
1 file changed +12 -1
vllm/reasoning/qwen3_reasoning_parser.py
+12 -1
@@ -47,6 +47,18 @@ class Qwen3ReasoningParser(ReasoningParser):
47 "Qwen3 reasoning parser could not locate think start/end "
48 "tokens in the tokenizer!")
49
50 + def is_reasoning_end(self, input_ids: list[int]) -> bool:
51 + return self.think_end_token_id in input_ids
52 +
53 + def extract_content_ids(self, input_ids: list[int]) -> list[int]:
54 + """
55 + Extract the content after the end tokens
56 + """
57 + if self.think_end_token_id not in input_ids[:-1]:
58 + return []
59 + else:
60 + return input_ids[input_ids.index(self.think_end_token_id) + 1:]
61 +
62 def extract_reasoning_content_streaming(
63 self,
64 previous_text: str,
@@ -88,7 +100,6 @@ class Qwen3ReasoningParser(ReasoningParser):
100 # reasoning content continues
101 return DeltaMessage(reasoning_content=delta_text)
102 elif self.think_start_token_id in delta_token_ids:
91 - logger.info(delta_text)
103 if self.think_end_token_id in delta_token_ids:
104 # <think> in delta, </think> in delta, extract reasoning content
105 start_index = delta_text.find(self.think_start_token)