-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
[Meta] Official Eagle mm support, first enablement on llama4 #20788
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
Open
morgendave
wants to merge
1
commit into
vllm-project:main
Choose a base branch
from
morgendave:eagle-mm-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+199
−36
Open
Changes from all commits
Commits
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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -9,23 +9,28 @@ | |||||
import torch | ||||||
|
||||||
from vllm import LLM, SamplingParams | ||||||
from vllm.assets.base import VLLM_S3_BUCKET_URL | ||||||
from vllm.assets.image import VLM_IMAGES_DIR | ||||||
from vllm.distributed import cleanup_dist_env_and_memory | ||||||
|
||||||
|
||||||
@pytest.fixture | ||||||
def test_prompts(): | ||||||
def get_test_prompts(mm_enabled: bool): | ||||||
prompt_types = ["repeat", "sentence"] | ||||||
num_prompts = 100 | ||||||
if mm_enabled: | ||||||
prompt_types.append("mm") | ||||||
num_prompts = 10 | ||||||
prompts = [] | ||||||
|
||||||
random.seed(0) | ||||||
random_prompt_type_choices = random.choices(prompt_types, k=num_prompts) | ||||||
print(f"Prompt types: {random_prompt_type_choices}") | ||||||
|
||||||
# Generate a mixed batch of prompts, some of which can be easily | ||||||
# predicted by n-gram matching and some which likely cannot. | ||||||
for kind in random_prompt_type_choices: | ||||||
word_choices = ["test", "temp", "hello", "where"] | ||||||
word = random.choice(word_choices) | ||||||
prompt: str | list[dict[str, Any]] = "" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Don't break Python 3.9 users |
||||||
if kind == "repeat": | ||||||
prompt = f""" | ||||||
please repeat the word '{word}' 10 times. | ||||||
|
@@ -38,6 +43,21 @@ def test_prompts(): | |||||
uses the word {word} at least once. | ||||||
give no other output than that simple sentence without quotes. | ||||||
""" | ||||||
elif kind == "mm": | ||||||
placeholders = [{ | ||||||
"type": "image_url", | ||||||
"image_url": { | ||||||
"url": | ||||||
f"{VLLM_S3_BUCKET_URL}/{VLM_IMAGES_DIR}/stop_sign.jpg" | ||||||
}, | ||||||
}] | ||||||
prompt = [ | ||||||
*placeholders, | ||||||
{ | ||||||
"type": "text", | ||||||
"text": "The meaning of the image is" | ||||||
}, | ||||||
] | ||||||
else: | ||||||
raise ValueError(f"Unknown prompt type: {kind}") | ||||||
prompts.append([{"role": "user", "content": prompt}]) | ||||||
|
@@ -103,23 +123,30 @@ def test_ngram_correctness( | |||||
cleanup_dist_env_and_memory() | ||||||
|
||||||
|
||||||
@pytest.mark.parametrize("model_setup", [ | ||||||
("eagle", "meta-llama/Llama-3.1-8B-Instruct", | ||||||
"yuhuili/EAGLE-LLaMA3.1-Instruct-8B", 1), | ||||||
("eagle3", "meta-llama/Llama-3.1-8B-Instruct", | ||||||
"yuhuili/EAGLE3-LLaMA3.1-Instruct-8B", 1), | ||||||
pytest.param( | ||||||
("eagle", "meta-llama/Llama-4-Scout-17B-16E-Instruct", | ||||||
"morgendave/EAGLE-Llama-4-Scout-17B-16E-Instruct", 4), | ||||||
marks=pytest.mark.skip(reason="Skipping due to CI OOM issues")), | ||||||
], | ||||||
ids=["llama3_eagle", "llama3_eagle3", "llama4_eagle"]) | ||||||
@pytest.mark.parametrize( | ||||||
"model_setup,mm_enabled", [ | ||||||
(("eagle", "meta-llama/Llama-3.1-8B-Instruct", | ||||||
"yuhuili/EAGLE-LLaMA3.1-Instruct-8B", 1), False), | ||||||
(("eagle3", "meta-llama/Llama-3.1-8B-Instruct", | ||||||
"yuhuili/EAGLE3-LLaMA3.1-Instruct-8B", 1), False), | ||||||
pytest.param( | ||||||
(("eagle", "meta-llama/Llama-4-Scout-17B-16E-Instruct", | ||||||
"morgendave/EAGLE-Llama-4-Scout-17B-16E-Instruct", 4), False), | ||||||
marks=pytest.mark.skip(reason="Skipping due to CI OOM issues")), | ||||||
pytest.param( | ||||||
(("eagle", "meta-llama/Llama-4-Scout-17B-16E-Instruct", | ||||||
"morgendave/EAGLE-Llama-4-Scout-17B-16E-Instruct", 4), True), | ||||||
marks=pytest.mark.skip(reason="Skipping due to CI OOM issues")), | ||||||
], | ||||||
ids=["llama3_eagle", "llama3_eagle3", "llama4_eagle", "llama4_eagle_mm"]) | ||||||
def test_eagle_correctness( | ||||||
monkeypatch: pytest.MonkeyPatch, | ||||||
test_prompts: list[list[dict[str, Any]]], | ||||||
sampling_config: SamplingParams, | ||||||
model_setup: tuple[str, str, str, int], | ||||||
mm_enabled: bool, | ||||||
): | ||||||
# Generate test prompts inside the function instead of using fixture | ||||||
test_prompts = get_test_prompts(mm_enabled) | ||||||
''' | ||||||
Compare the outputs of a original LLM and a speculative LLM | ||||||
should be the same when using eagle speculative decoding. | ||||||
|
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The model should be Llama4 for multimodal mode