You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Honor model eos_token_id and bound local generation, bump to 0.3.20
Two fixes for runaway local generation with models whose ChatML end token
differs from their tokenizer EOS (e.g. dhara-250m: chat ends at <|im_end|>=49154
but tokenizer eos is <|end_of_text|>=1). optillm forced eos to the tokenizer's
id and defaulted max_new_tokens to 4096, so such a model never stopped and
generated 4096 tokens (~800s at ~5 tok/s) on every call that omitted max_tokens.
1. Resolve EOS from the model's generation_config.eos_token_id (merging the
tokenizer eos as a fallback) instead of hardcoding tokenizer.eos_token_id.
Applied to both PyTorch generate paths.
2. Make the default max_new_tokens env-configurable via OPTILLM_MAX_TOKENS
(default 4096), covering the config builders and the InferenceClient.create()
request paths. An explicit request max_tokens still wins. Set
OPTILLM_MAX_TOKENS=128 in the CI jobs that run the small test model.
Adds unit tests (no model load) for both helpers and documents OPTILLM_MAX_TOKENS.
Verified end to end: an unbounded request with OPTILLM_MAX_TOKENS=64 now stops
at 64 tokens instead of running to 4096.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: README.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -324,6 +324,8 @@ We support loading any HuggingFace model or LoRA directly in optillm. To use the
324
324
and then use the same in your OpenAI client. You can pass any HuggingFace model in model field. If it is a private model make sure you set the `HF_TOKEN` environment variable
325
325
with your HuggingFace key. We also support adding any number of LoRAs on top of the model by using the `+` separator.
326
326
327
+
By default a single local generation is capped at 4096 new tokens. Set `OPTILLM_MAX_TOKENS` to lower this default (e.g. `export OPTILLM_MAX_TOKENS=512`), which bounds any request that does not send `max_tokens` — useful for small models that do not reliably emit an EOS token. An explicit `max_tokens` in the request still takes precedence.
328
+
327
329
E.g. The following code loads the base model `meta-llama/Llama-3.2-1B-Instruct` and then adds two LoRAs on top - `patched-codes/Llama-3.2-1B-FixVulns` and `patched-codes/Llama-3.2-1B-FastApply`.
328
330
You can specify which LoRA to use using the `active_adapter` param in `extra_body` field of OpenAI SDK client. By default we will load the last specified adapter.
0 commit comments