-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
[Core][Bugfix] Fix Online MM Beam Search #19688
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
DarkLight1337
merged 4 commits into
vllm-project:main
from
alex-jw-brooks:async_beam_search
Jun 19, 2025
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
4bd5b1e
Use common beam search scoring
alex-jw-brooks 7f6066f
Pull prompt token ids and mm data off of raw prompt
alex-jw-brooks b886374
Check responsese in vision async beam search test
alex-jw-brooks 2cf7fd8
Fix beam search test output in ci
alex-jw-brooks File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,7 +15,8 @@ | |
| from typing_extensions import TypeVar, deprecated | ||
|
|
||
| from vllm.beam_search import (BeamSearchInstance, BeamSearchOutput, | ||
| BeamSearchSequence, get_beam_search_score) | ||
| BeamSearchSequence, | ||
| create_sort_beams_key_function) | ||
| from vllm.config import (CompilationConfig, ModelDType, TokenizerMode, | ||
| is_init_field) | ||
| from vllm.engine.arg_utils import (EngineArgs, HfOverrides, PoolerConfig, | ||
|
|
@@ -573,10 +574,11 @@ def beam_search( | |
| lora_requests = self._get_beam_search_lora_requests( | ||
| lora_request, prompts) | ||
|
|
||
| def sort_beams_key(x: BeamSearchSequence) -> float: | ||
| return get_beam_search_score(x.tokens, x.cum_logprob, | ||
| tokenizer.eos_token_id, | ||
| length_penalty) | ||
| tokenizer = self.get_tokenizer() | ||
| sort_beams_key = create_sort_beams_key_function( | ||
|
||
| tokenizer.eos_token_id, | ||
| length_penalty, | ||
| ) | ||
|
|
||
| def create_tokens_prompt_from_beam( | ||
| beam: BeamSearchSequence) -> TokensPrompt: | ||
|
|
@@ -591,7 +593,6 @@ def create_tokens_prompt_from_beam( | |
| "mm_processor_kwargs"] = beam.mm_processor_kwargs | ||
| return TokensPrompt(**token_prompt_kwargs) | ||
|
|
||
| tokenizer = self.get_tokenizer() | ||
| # generate 2 * beam_width candidates at each step | ||
| # following the huggingface transformers implementation | ||
| # at https://github.com/huggingface/transformers/blob/e15687fffe5c9d20598a19aeab721ae0a7580f8a/src/transformers/generation/beam_search.py#L534 # noqa | ||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.