Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions omlx/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1707,7 +1707,10 @@ def _build_sampler_and_processors(
if think_end_ids:
from .api.thinking import ThinkingBudgetProcessor

think_start_id = self._get_think_token_id("think_start_id")
try:
think_start_id = getattr(self.tokenizer, 'think_start_id', None)
except (ValueError, TypeError):
think_start_id = None
leading_ids, trailing_ids = self._resolve_think_close_pattern()
processor = ThinkingBudgetProcessor(
think_end_token_ids=think_end_ids,
Expand Down Expand Up @@ -1770,7 +1773,11 @@ def _resolve_think_end_token_ids(self) -> list[int] | None:
</think> and </longcat_think> automatically.
"""
# Tier 1: mlx-lm tokenizer attribute (covers all known think variants)
think_end_id = self._get_think_token_id("think_end_id")
try:
think_end_id = getattr(self.tokenizer, 'think_end_id', None)
except (ValueError, TypeError):
# Multi-token think end (e.g. Gemma 4) - fall through to Tier 2
think_end_id = None
if think_end_id is not None:
return [think_end_id]

Expand Down Expand Up @@ -1888,7 +1895,12 @@ def _detect_needs_think_prefix(self, request: "Request") -> bool:
Returns False for disabled-thinking patterns like <think></think>
where </think> immediately follows <think> in the prompt tail.
"""
think_start_id = self._get_think_token_id("think_start_id")
try:
think_start_id = getattr(self.tokenizer, 'think_start_id', None)
except (ValueError, TypeError):
# Multi-token think start (e.g. Gemma 4 <|channel>thought) -
# single-token detection not applicable, handled by output parser
return False
if think_start_id is None:
try:
think_start_id = self.tokenizer.convert_tokens_to_ids("<think>")
Expand Down