Skip to content

Align with huggingface beam search - #646

Closed
hashming wants to merge 1 commit into
vllm-project:mainfrom
hashming:better_beam_search
Closed

hashming wants to merge 1 commit into
vllm-project:mainfrom
hashming:better_beam_search

Conversation

@hashming

@hashming hashming commented Aug 2, 2023

Copy link
Copy Markdown

main modifications

  1. sampler
    • always sample 2 * num_beams tokens, even if beam_width < num_beams
  2. scheduler
    • update: keep at-most num_beams finished seqs (beam_hyps) and at-most num_beams running seqs in seq_group.
    • move _decode and _stop function to scheduler (from llm_engine).
  3. sequence
    • move "data" attributes from Sequence to SequenceData

example

  • prompt: "What is deep learning?"
  • sampling_params: SamplingParams(temperature = 0, use_beam_search = True, n = 5, max_tokens = 100)
  • model & tokenizer: A finetuned Llama
  • original beam search returns:
 * Learning is deep type of machine learning that involves using building and neural networks to model and solve complex problems.
 * Deep learning is a subset of artificial intelligence that involves the use of artificial neural networks to model and solve complex problems.
 * It's a type of Artificial allows training artificial neural networks to recognize patterns in data. problems that require
 * the not a word machine learning that involves building and training neural networks to model and generalize knowledge problems that Deep learning is inspired by the structure and function of the human brain and is used for a variety of applications including natural language processing, image and speech recognition, and decision making.
 * A is a the subfield of artificial intelligence that involves the use of artificial neural networks to model and solve complex problems. Deep learning is inspired by the structure and function of the human brain and is used for a variety of applications including natural language processing, image and speech recognition, and decision making.
  • modified beam search:
 * Deep learning is a subfield of artificial intelligence that involves the use of artificial neural networks to model and solve problems that require high-level processing, such as natural language processing, image and speech recognition, and decision making.
 * Deep learning is a subset of artificial intelligence that involves the use of artificial neural networks to model and solve complex problems. It is inspired by the structure and function of the human brain and is used for a variety of applications such as natural language processing, image and speech recognition, and decision making.
 * Deep learning is a subfield of artificial intelligence that involves the use of artificial neural networks to model and solve complex problems. Deep learning is inspired by the structure and function of the human brain and is used for a variety of applications including natural language processing, image and speech recognition, and decision making.
 * Deep learning is a subset of artificial intelligence that involves the use of artificial neural networks to model and solve complex problems. It is inspired by the structure and function of the human brain and is used for a variety of applications such as natural language processing, image and speech recognition, and autonomous decision making.
 * Deep learning is a subfield of artificial intelligence that involves the use of artificial neural networks to model and solve problems that require high-level processing, such as natural language processing, image and speech recognition, and decision making. Deep learning is inspired by the structure and function of the human brain and is used to model and solve complex problems.

@hashming hashming changed the title align with huggingface beam search. align with huggingface beam search Aug 2, 2023
@hashming

hashming commented Aug 2, 2023

Copy link
Copy Markdown
Author

related issue: #344 #644

@hashming
hashming force-pushed the better_beam_search branch from 1558da0 to 086b848 Compare August 3, 2023 04:20
@hashming hashming closed this Aug 3, 2023
@hashming
hashming force-pushed the better_beam_search branch 2 times, most recently from 086b848 to aa84c92 Compare August 3, 2023 04:22
@hashming hashming reopened this Aug 3, 2023
@thisissum thisissum mentioned this pull request Aug 3, 2023
@hashming
hashming force-pushed the better_beam_search branch 2 times, most recently from 5eb3ab4 to 2374db0 Compare August 7, 2023 09:15
@hashming
hashming force-pushed the better_beam_search branch from 2374db0 to f1e5c4a Compare August 9, 2023 08:06
@hashming hashming changed the title align with huggingface beam search Align with huggingface beam search Aug 9, 2023
@zhuohan123

Copy link
Copy Markdown
Member

@hsm1997 Thank you for your great contribution! The changes you make are a bit complicated. Can we schedule a chat to discuss about this PR? I cannot find your email address. Can you send me an email at zhuohan[at]berkeley.edu? Thanks again!

@zhuohan123
zhuohan123 self-requested a review August 12, 2023 02:51
@leiwen83

leiwen83 commented Aug 12, 2023

Copy link
Copy Markdown
Contributor

A minor fix with this PR:

diff --git a/vllm/core/scheduler.py b/vllm/core/scheduler.py
index e2ca127..11eea5e 100644
--- a/vllm/core/scheduler.py
+++ b/vllm/core/scheduler.py
@@ -342,7 +342,7 @@ class Scheduler:
                     continue

                 # schedule next-beam tasks
-                pending = pending[:sampling_params.n]
+                pending = pending[:sampling_params.best_of]
                 running_ids = [
                     seq.seq_id for seq in seq_group.get_seqs(
                         status=SequenceStatus.RUNNING)

We need to keep the history with best_of setting, or we may lose the highest score, since n in sampling_params only means for the output token, not in the searching stage.

@zhuohan123

Copy link
Copy Markdown
Member

Close this PR since #857 is merged. Thanks @hsm1997 again for finding the issue and the draft PR!

@zhuohan123 zhuohan123 closed this Sep 5, 2023
tobymao added a commit to tobymao/vllm that referenced this pull request Sep 11, 2026
…points (vllm-project#669)

* Preserve aligned cache reuse alongside request boundary checkpoints

Port the qualified hybrid retention, fine-hit, event, exact external-state,
and aligned-budget changes onto dev/jovian-judgement. Keep endpoint bundles
private and preserve their allocation, reader, and invalidation lifecycle.

Retain the behavioral contributions from PRs vllm-project#557, vllm-project#643, vllm-project#645, vllm-project#646,
vllm-project#655, vllm-project#656, vllm-project#657, and vllm-project#663. Resolve shared helpers once so fine and coarse
replay boundaries are not expanded twice.

Validation: 910 cache, scheduler, parser, event, connector, and endpoint
regressions pass. The three literal LP26 cache regressions also pass.

Co-authored-by: Jason Cook <jasonc@maxlyn.com>
Co-authored-by: Martin Vit <martin@voipmonitor.org>
Co-authored-by: Yifan Qiao <yifanqiao@inferact.ai>
Co-authored-by: haic0 <149741444+haic0@users.noreply.github.com>
Co-authored-by: tobymao <toby.mao@gmail.com>
Signed-off-by: logprobz <321553542+logprobz@users.noreply.github.com>

* Clean up cache regression fixtures for pre-commit checks

Signed-off-by: logprobz <321553542+logprobz@users.noreply.github.com>

---------

Signed-off-by: logprobz <321553542+logprobz@users.noreply.github.com>
Co-authored-by: logprobz <321553542+logprobz@users.noreply.github.com>
Co-authored-by: Jason Cook <jasonc@maxlyn.com>
Co-authored-by: Martin Vit <martin@voipmonitor.org>
Co-authored-by: Yifan Qiao <yifanqiao@inferact.ai>
Co-authored-by: haic0 <149741444+haic0@users.noreply.github.com>
Co-authored-by: tobymao <toby.mao@gmail.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.

3 participants