Repository navigation
feat(server): honour ignore_eos and min_tokens (#881) - #907
Merged
Merged
Conversation
…ma endpoints Mask the end-of-sequence ids in AutoModel::_sample() while ignore_eos is set or fewer than min_tokens tokens were generated (fixes #881). DFlash verifies through _sample() so it is covered; the MTP loop skips speculate() while the mask is needed, since its draft head samples inside the engine. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #881.
ignore_eosandmin_tokenswere accepted by/v1/chat/completions(and/generate, Ollama chat) but never read, so generation always stopped at the model's EOS.Change
rest_handler.cpp: readignore_eos(bool) andmin_tokens(int) intochat_meta_info_tin all four handlers.AutoModel::_sample(): whileignore_eosis set orgenerated_tokens < min_tokens, clear the EOS ids from the allowed-token mask (combined with any grammar mask; a grammar that allows only EOS keeps it).modeling_qwen3_8mtp.cpp: the MTP draft head samples inside the engine, past that mask, sospeculate()is skipped while EOS is suppressed (one token at a time, much slower on 27B; speculation resumes aftermin_tokens)._sample().request_parameters.md.Tested (local build on XDNA 2, host-only change, no libs)
min_tokens=64ignore_eosmax 150;ignore_eos+min_tokens=256max 300lengthmin_tokens=64max 96;ignore_eosmax 32lengthmin_tokens=64ignore_eosmax 150;ignore_eos+min_tokens=256max 300; streaming max 60min_tokensguarantees at least that many tokens; the reply can run 1-2 over (engines count the first sampled token differently), more with DFlash batches. The Qwen3.5-2B and 27B runs were on the earlier branch before the port onto this main; the code is identical.🤖 Generated with Claude Code