vllm-project/vllm · error · ValueError
ReasoningConfig: failed to tokenize reasoning strings: reaso
Error message
ReasoningConfig: failed to tokenize reasoning strings: reasoning_start_str='{self.reasoning_start_str}', reasoning_end_str='{self.reasoning_end_str}'. Ensure the strings are valid tokens in the model's vocabulary. What it means
ReasoningConfig encodes reasoning_start_str / reasoning_end_str with the model tokenizer; if any of the start, end, or natural-end strings tokenizes to an empty token-id list, the config is invalid and reasoning parsing stays disabled. The tokenizer simply does not recognize the string as one or more standalone tokens, so the parser could never match it reliably.
Source
Thrown at vllm/config/reasoning.py:119
# If we don't have valid strings to tokenize,
# we can't initialize the token IDs.
return
self._reasoning_start_token_ids = tokenizer.encode(
reasoning_start_str, add_special_tokens=False
)
self._reasoning_end_token_ids = tokenizer.encode(
reasoning_end_str, add_special_tokens=False
)
self._natural_reasoning_end_token_ids = tokenizer.encode(
natural_reasoning_end_str, add_special_tokens=False
)
if (
not self._reasoning_start_token_ids
or not self._reasoning_end_token_ids
or not self._natural_reasoning_end_token_ids
):
raise ValueError(
f"ReasoningConfig: failed to tokenize reasoning strings: "
f"reasoning_start_str='{self.reasoning_start_str}', "
f"reasoning_end_str='{self.reasoning_end_str}'. "
"Ensure the strings are valid tokens in the model's vocabulary."
)
self._enabled = True
View on GitHub (pinned to c794754062)
Solutions
- Verify the marker with tokenizer.encode(marker, add_special_tokens=False) and confirm a non-empty id list before starting vLLM
- Use the exact token spelling from the model's tokenizer_config.json (e.g. '</think>' including of angle brackets)
- Align --tokenizer with the checkpoint that defines the reasoning special tokens
- If markers genuinely aren't in the vocab, disable ReasoningConfig and parse reasoning another way
Example fix
# before
ReasoningConfig(model='deepseek-ai/DeepSeek-R1', tokenizer=wrong_tok, reasoning_start_str='<think>', reasoning_end_str='</think>')
# after
ReasoningConfig(model='deepseek-ai/DeepSeek-R1', tokenizer=r1_tok, reasoning_start_str='<think>', reasoning_end_str='</think>') # r1_tok.encode('</think>') -> [151649] Defensive patterns
Strategy: validation
Validate before calling
def reasoning_markers_tokenize(tokenizer, start: str, end: str, natural_end: str) -> bool:
enc = lambda s: bool(tokenizer.encode(s, add_special_tokens=False))
return enc(start) and enc(end) and enc(natural_end)
assert reasoning_markers_tokenize(tok, '<think>', '</think>', '</think>') Type guard
null
Try / catch
null
Prevention
- Pre-encode markers with the model's own tokenizer before launch
- Ship marker strings via the same config as --tokenizer
- Unit-test marker tokenization in CI for each served model
When it happens
Trigger: Setting reasoning_start_str='[think]' when the tokenizer splits it into nothing matching (rare) or returns no ids; using special-token strings without the tokenizer that defines them; wrong tokenizer for the model; empty/whitespace strings after config templating.
Common situations: Using DeepSeek-R1 style '</think>' markers with a base tokenizer that lacks them; pointing --tokenizer at a different vocab than --model; YAML stripping or HTML-escaping the marker string; version change in default natural_reasoning_end_str handling.
Related errors
- use_heterogeneous_vocab only works with method='draft_model'
- Target and draft model should have the same vocabulary size.
- this model's maximum context length is {max_model_len} token
- token_id(s) {token_ids:?} in {parameter} are out of vocabula
- Unknown dtype: {dtype!r}
AI-assisted analysis of vllm-project/vllm@c794754062 (2026-08-14).
Data as JSON: /api/errors/0101cb68381907f3.
Report an issue: GitHub.