Skip to content

Fix bitwise NOT (~) on boolean in tokenizer fallback#3845

Open
Chessing234 wants to merge 1 commit intolm-sys:mainfrom
Chessing234:fix/bitwise-not-use-fast
Open

Fix bitwise NOT (~) on boolean in tokenizer fallback#3845
Chessing234 wants to merge 1 commit intolm-sys:mainfrom
Chessing234:fix/bitwise-not-use-fast

Conversation

@Chessing234
Copy link
Copy Markdown

Bug

In load_compress_model(), when AutoTokenizer.from_pretrained raises a TypeError, the fallback retries with use_fast=~use_fast. The ~ operator is Python's bitwise NOT, not logical NOT:

  • ~True-2 (truthy)
  • ~False-1 (truthy)

So the fallback never actually flips use_fast — it always passes a truthy value, defeating the purpose of the retry.

Fix

Replace ~use_fast with not use_fast for correct boolean negation.

Note: the analogous code in model_adapter.py (line 116) correctly hardcodes use_fast=False in its fallback, confirming the intended behavior.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

…er fallback

In `load_compress_model`, the TypeError fallback path uses `~use_fast` to
flip the boolean. The `~` operator is bitwise NOT, so `~True` evaluates
to `-2` and `~False` to `-1`—both truthy. This means the fallback never
actually toggles `use_fast`, defeating the purpose of the retry.

Use `not use_fast` for correct boolean negation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant