Skip to content

Commit c8cbdde

Browse files
jacqueriecodelionclaude
authored
Fix autothink and thinkdeeper for transformers>=5 (#320)
* Fix autothink and thinkdeeper for transformers>=5 * Keep device transfer when unwrapping BatchEncoding, cover deepconf, bump 0.3.22 Builds on the transformers>=5 fix: apply_chat_template now returns a BatchEncoding, so the tensor must be unwrapped via .input_ids. Two corrections to the original change: 1. Preserve the device transfer. `tokens.to(device)` was called without assigning the result, but Tensor.to() is not in-place -- it returns a new tensor. As written the tokens stayed on CPU, so on CUDA/MPS the subsequent model(input_ids=tokens, ...) would fail with a device mismatch. A CPU-only repro hides this. Chain it instead: .input_ids.to(self.model.device). 2. Apply the same fix to optillm/deepconf/processor.py, which has the identical apply_chat_template(return_tensors="pt") -> model(input_ids=tokens) pattern and was still passing a BatchEncoding. Also updates the README badges (drop the GitHub stars badge, use the pepy.tech downloads badge which reports actual counts) and bumps the version to 0.3.22. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Asankhaya Sharma <codelion@users.noreply.github.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent c258858 commit c8cbdde

6 files changed

Lines changed: 6 additions & 8 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@
99
</p>
1010

1111
<p align="center">
12-
<a href="https://github.com/algorithmicsuperintelligence/optillm/stargazers"><img src="https://img.shields.io/github/stars/algorithmicsuperintelligence/optillm?style=social" alt="GitHub stars"></a>
1312
<a href="https://pypi.org/project/optillm/"><img src="https://img.shields.io/pypi/v/optillm" alt="PyPI version"></a>
14-
<a href="https://pypi.org/project/optillm/"><img src="https://img.shields.io/pypi/dm/optillm" alt="PyPI downloads"></a>
13+
<a href="https://pepy.tech/projects/optillm"><img src="https://static.pepy.tech/personalized-badge/optillm?period=monthly&units=INTERNATIONAL_SYSTEM&left_color=BLACK&right_color=GREEN&left_text=downloads/month" alt="PyPI Downloads"></a>
1514
<a href="https://github.com/algorithmicsuperintelligence/optillm/blob/main/LICENSE"><img src="https://img.shields.io/github/license/algorithmicsuperintelligence/optillm" alt="License"></a>
1615
</p>
1716

‎optillm/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Version information
2-
__version__ = "0.3.21"
2+
__version__ = "0.3.22"
33

44
import os as _os
55

‎optillm/autothink/processor.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ def process(self, messages: List[Dict[str, str]]) -> str:
243243
thinking_messages,
244244
continue_final_message=True,
245245
return_tensors="pt"
246-
).to(self.model.device)
246+
).input_ids.to(self.model.device)
247247

248248
# Reset and update token history in steering hooks
249249
if self.steering_hooks:

‎optillm/deepconf/processor.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def generate_single_trace(self, messages: List[Dict[str, str]],
108108
messages,
109109
return_tensors="pt",
110110
add_generation_prompt=True
111-
).to(self.model.device)
111+
).input_ids.to(self.model.device)
112112

113113
# Initialize generation state
114114
kv_cache = DynamicCache()

‎optillm/thinkdeeper.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ def reasoning_effort(self, messages) -> str:
7777
messages,
7878
continue_final_message=True,
7979
return_tensors="pt"
80-
)
81-
tokens = tokens.to(self.model.device)
80+
).input_ids.to(self.model.device)
8281

8382
kv = DynamicCache()
8483
n_thinking_tokens = 0

‎pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "optillm"
7-
version = "0.3.21"
7+
version = "0.3.22"
88
description = "An optimizing inference proxy for LLMs."
99
readme = "README.md"
1010
license = "Apache-2.0"

0 commit comments

Comments
 (0)