-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
[CI/Build] VLM Test Consolidation #9372
[CI/Build] VLM Test Consolidation #9372
Conversation
👋 Hi! Thank you for contributing to the vLLM project. Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging. To run CI, PR reviewers can do one of these:
🚀 |
num_logprobs=num_logprobs, | ||
tensor_parallel_size=1, | ||
) | ||
models = ["llava-hf/llava-1.5-7b-hf"] | ||
|
||
|
||
@pytest.mark.parametrize("model", models) |
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.
We can make this a more general test, perhaps under engine tests (since it's actually testing the error handling inside LLMEngine
)
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.
Thanks for spending so much effort on this! Some initial comments.
@@ -0,0 +1,999 @@ | |||
"""Common utility functions relating to different models that are useful |
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.
This file is pretty long. Can we split out each part into a separate file?
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.
Agreed! I'll split it up 😄
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.
I broke its contents up into a vlm_utils
package. For now, it's still under the VLM tests, but I think we can also pull it up and bring other things into it in follow-ups if we want to (e.g., audio
tests which be similar to the same changes I made for video
, or the encoder/decoder vision tests for mllama)
####### Entrypoints for running different test types | ||
# Wrappers for all the above, where the only difference | ||
# is that each test runs in a separate process | ||
def run_single_image_test( |
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.
Is there an easy way to just run the tests for a single model or a custom subset of models, like the case for PP?
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.
Good point - I don't think there is at the moment, but I think it can probably be done by setting IDs in the parametrize call using the model key as a prefix. I'll give try it this evening!
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.
I looked into a bit - I think the best way to do this is actually just using pytest's -k
to substring match, since the model's key in the settings dict is already added as the first param to make it more clear which test failed.
Here is an example of how an expanded test case looks after parametrizing:
test_single_image_models[intern_vl-OpenGVLab/InternVL2-1B-128-5-half-None-size_wrapper19]
The key in the settings is always the first parameter in every test, so we can leverage [<key_name>
as a matchable substring for running all of the tests for a specific architecture. Some examples:
- Runs all of the types of tests for only llava - I added some notes to use
_
in the model architectures for the keys. This way, the hyphen afterllava
prevents it from matching against thellava_next
's tests
pytest test_models.py -k "[llava-"
- Run the tests for one of the two models used in InternVL's tests
pytest test_models.py -k "OpenGVLab/InternVL2-1B"
You can also use and/or
inside of -k
filters, so we can also do stuff like this to run just the single image llava tests, to run tests for multiple model types, etc. This also matches test_single_image_models_heavy
, so we don't need to worry about which tests are using forked processes when testing like this
pytest test_models.py -k "test_single_image and [llava-"
I added a long comment with similar examples, and recommended using --collect-only
to quickly check which tests pytests will run with a command before actually executing it here:
# NOTE: The convention of the test settings below is to lead each test key |
4ced439
to
f9f9fc9
Compare
Hey @DarkLight1337! Thanks for your patience - I addressed the initial feedback and rebased the branch. It's ready for another look when you have a moment! 🙂 |
tests/models/decoder_only/vision_language/vlm_utils/case_filtering.py
Outdated
Show resolved
Hide resolved
tests/models/decoder_only/vision_language/vlm_utils/core_utils.py
Outdated
Show resolved
Hide resolved
2e74e23
to
7b4c97f
Compare
tests/models/decoder_only/vision_language/vlm_utils/case_filtering.py
Outdated
Show resolved
Hide resolved
7b4c97f
to
d410164
Compare
PTAL at the test failure. |
Thanks @DarkLight1337 - I actually have been hitting the same error when I run the phi3v model tests in my environment for awhile (on In my environment, the phi3v tests seem to deterministically pass locally (here and on main) if the runner order in |
I'm pretty sure the core of the issue is that this is okay: model_name = "microsoft/Phi-3.5-vision-instruct"
from transformers import AutoImageProcessor
from transformers import AutoProcessor
AutoImageProcessor.from_pretrained(model_name, trust_remote_code=True)
AutoProcessor.from_pretrained(model_name, trust_remote_code=True) but this throws the attribute error breaking the test. model_name = "microsoft/Phi-3.5-vision-instruct"
from transformers import AutoImageProcessor
AutoImageProcessor.from_pretrained(model_name, trust_remote_code=True)
from transformers import AutoProcessor
AutoProcessor.from_pretrained(model_name, trust_remote_code=True) I'm not exactly sure why the current tests are passing on I am still trying to find a good workaround here that hopefully won't cause cuda initialization issues, but also went ahead and opened an issue in Transformers as well huggingface/transformers#34307 |
Let's see how HF side responds first. |
Seems that it will take them some time to fix it. Let's |
Sounds good, thanks @DarkLight1337 - I've pulled in the most recent changes from For the Qwen2 stuff - I can definitely add model tests for that model, and also help look into why the output results seem garbled, but would it be possible to do it in a separate PR? Pulling all the updates coming in is a bit painful 🙂 |
ea7aead
to
9bfc244
Compare
This pull request has merge conflicts that must be resolved before it can be |
Signed-off-by: Alex-Brooks <[email protected]>
Signed-off-by: Alex-Brooks <[email protected]>
Signed-off-by: Alex-Brooks <[email protected]>
9bfc244
to
2e55b2e
Compare
Just rebased again to update the skips in chameleon tests, but the multimodal decoder tests did pass in the last run! |
We also need to skip llava-next-video tests, and llava-next embedding tests. The distributed tests should be updated to use the new test file. |
Head branch was pushed to by a user without write access
Sounds good - disabled the llava next video tests, and fixed the build kite path for distributed tests. For the llava next embeddings test, I only skipped |
a815cc4
to
5f6c4b7
Compare
Signed-off-by: Alex-Brooks <[email protected]> Disable failing llava next tests Signed-off-by: Alex-Brooks <[email protected]>
5f6c4b7
to
c81bed0
Compare
Signed-off-by: Alex-Brooks <[email protected]> Signed-off-by: Randall Smith <[email protected]>
Signed-off-by: Alex-Brooks <[email protected]> Signed-off-by: NickLucche <[email protected]>
Signed-off-by: Alex-Brooks <[email protected]> Signed-off-by: NickLucche <[email protected]>
Signed-off-by: Alex-Brooks <[email protected]>
Signed-off-by: Alex-Brooks <[email protected]> Signed-off-by: Linkun Chen <[email protected]>
Signed-off-by: Alex-Brooks <[email protected]>
Signed-off-by: Alex-Brooks <[email protected]> Signed-off-by: Loc Huynh <[email protected]>
Signed-off-by: Alex-Brooks <[email protected]> Signed-off-by: Sumit Dubey <[email protected]>
*This PR is large because it's touching pretty much all of the VLM tests - the place where they are consolidated into, i.e., where new model tests would be added is here. The place that each of these eventually land to run the vLLM/HF runners (for all of the tests types) is here!
Overview
Most of the multi-modal image/video tests in vLLM do the same thing, but have small tweaks to things like
@large_gpu_test
, which may control spawning the tests in a new process)and so on.
However, the structure of the tests themselves is very similar, and pretty much always consists of some boilerplate to configure instances of
HfRunner
/VllmRunner
and compare greedy logprobs in some common_run_test
function, which will then be wrapped in atest_
function with different options, e.g.,size_factors
, being parametrized.This PR aims to consolidate a lot of the redundancy in vLLM's multimodal tests, starting with the visual tests, but in a way that can also (hopefully) be easily extended to other types, e.g.,
audio
.The way this is accomplished is by defining five types of test, which can cover most of our visual model tests:
and defining test wrappers for each of them, each of which leverage common utilities and invoke a common
run_test
, which is written to be model-agnostic. As such, to add a test for a new type of model, you should be able to (mostly) add a new object configuring a model for theVLM_TEST_SETTINGS
& only need to worry about things that are model-specific, e.g., post-processing on the VLLM runner output.Example 1: GLM-4
Here is an example of an object describing the GLM-4 tests.
Which indicates that we should run a test single image test, using the default single image prompt / image token, without additional prompt formatting. This will actually result in four tests, because it runs the default size factors as separate pytest cases. Additionally, each test case will run in a separate process, similar to if we wrote a test with
@large_gpu_test(min_gb=48)
to ensure resources are still cleaned up correctly.Example 2: Phi3v
Phi3v is a model that supports multiple images, so it has single & mutli image tests. This is a pretty good example of what our multi-image tests look like most of the time, but there are a few quirks specific to the model, e.g., needing to use eager attention when running the HF model. The option below configures both the single & multi-image tests for the default size factors.
So as a result of the default size factors, when this gets picked up, it will run 4 single image tests (one per size factor) and 4 multi image tests (one per size factor). Settings like
max_model_len
andmax_num_seqs
etc which are common are used in all the test types.Other Implementation details
Each
VLMTestInfo
has the flexibility to set the things we would normallyparametrize
, e.g.,size_factors
. This is accomplished by consuming all of theVLM_TEST_SETTINGS
, dropping things that are marked as skipped / tests that don't have the correspondingtest_type
, and then taking an itertools product over specific fields (e.g.,models
,num_tokens
,size_factors/fixed_sizes
,dtype
etc) for each test that matched so that each combination will run as its own test.Each test type has two implementations; the normal one, and a
heavy
version which is identical, but runs each test in a new process. If a test setsfork_new_process_for_each_test=True
, it will run in the heavy version, which is wrapped in the@fork_new_process_for_each_test
decorator.skip
field to achieve the same effect of some of our existing decorators for cleaning up resources. For example, settingVLMTestInfo(..., fork_new_process_for_each_test=True, skip=(get_memory_gb() < 48))
will behave like@large_gpu_test(min_gb=48)
.A lot of the current tests use very slight variations of the same prompts. This PR is aligning most of them on a common prompts, so the scores will change slightly. The settings for most models should (hopefully) be the same though; for each model, I ensured that if the prompts matched, the vLLM runner/hf runner produced the same output as I was porting them.
In some cases, e.g., paligemma, the prompt is quite different, and using the default one fails the logprobs check. This is why in some cases the prompt is set directly for some models.
There are a couple of other tests here that didn't really fit (e.g., the quantized InternVL test and error case for Llava). For now, I left these where they were, since I thought it might be a good idea to figure out if we prefer this to somewhere In between (e.g., keeping in model's tests in its own file, but using common test runner here) first
To handle stuff like
audio
, I think it should be pretty similar to handlingimages
vs.video
; if we choose to make this sort of change, hopefully we can just add a newtest_type
to pass audio through the common wrapper for the vllm/hf runnersFor stuff like quantized tests - some thoughts for what would feel nice might be a good idea, but I imagine we probably could just pass the model / quantized model, and if its set, create two vLLM runners instead of a HF/vLLM runner
BEFORE SUBMITTING, PLEASE READ THE CHECKLIST BELOW AND FILL IN THE DESCRIPTION ABOVE
PR Checklist (Click to Expand)
Thank you for your contribution to vLLM! Before submitting the pull request, please ensure the PR meets the following criteria. This helps vLLM maintain the code quality and improve the efficiency of the review process.
PR Title and Classification
Only specific types of PRs will be reviewed. The PR title is prefixed appropriately to indicate the type of change. Please use one of the following:
[Bugfix]
for bug fixes.[CI/Build]
for build or continuous integration improvements.[Doc]
for documentation fixes and improvements.[Model]
for adding a new model or improving an existing model. Model name should appear in the title.[Frontend]
For changes on the vLLM frontend (e.g., OpenAI API server,LLM
class, etc.)[Kernel]
for changes affecting CUDA kernels or other compute kernels.[Core]
for changes in the core vLLM logic (e.g.,LLMEngine
,AsyncLLMEngine
,Scheduler
, etc.)[Hardware][Vendor]
for hardware-specific changes. Vendor name should appear in the prefix (e.g.,[Hardware][AMD]
).[Misc]
for PRs that do not fit the above categories. Please use this sparingly.Note: If the PR spans more than one category, please include all relevant prefixes.
Code Quality
The PR need to meet the following code quality standards:
format.sh
to format your code.docs/source/
if the PR modifies the user-facing behaviors of vLLM. It helps vLLM user understand and utilize the new features or changes.Adding or changing kernels
Each custom kernel needs a schema and one or more implementations to be registered with PyTorch.
Tensors
require meta-functions. Meta-functions should be implemented and registered in python so that dynamic dims can be handled automatically. See above documents for a description of meta-functions.torch.libary.opcheck()
to test the function registration and meta-function for any registered ops. Seetests/kernels
for examples.Notes for Large Changes
Please keep the changes as concise as possible. For major architectural changes (>500 LOC excluding kernel/data/config/test), we would expect a GitHub issue (RFC) discussing the technical design and justification. Otherwise, we will tag it with
rfc-required
and might not go through the PR.What to Expect for the Reviews
The goal of the vLLM team is to be a transparent reviewing machine. We would like to make the review process transparent and efficient and make sure no contributor feel confused or frustrated. However, the vLLM team is small, so we need to prioritize some PRs over others. Here is what you can expect from the review process:
action-required
label on the PR if there are changes required. The contributor should address the comments and ping the reviewer to re-review the PR.Thank You
Finally, thank you for taking the time to read these guidelines and for your interest in contributing to vLLM. Your contributions make vLLM a great tool for everyone!