Skip to content
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

[V1][VLM] Proper memory profiling for image language models #11210

Merged
merged 9 commits into from
Dec 17, 2024

Conversation

ywang96
Copy link
Member

@ywang96 ywang96 commented Dec 15, 2024

This PR adds memory profiling for image language models in V1 so that peak memory usage is correctly measured to avoid potential CUDA OOM.

A few things to note:

  1. We still use the dummy multi_modal_data for memory profiling. This not only allows us to reuse the existing code, but is also developer-friendly since defining a dummy PIL image is much more intuitive than defining dummy pixel values. In order to do so, mm_input_mapper is added to model runner only for profiling purpose.

  2. This current version only works for image (because of limitation on mm_input_mapper). The memory profiling section has supported profiling for other single non-text modality models, but may require some additional design to be extended to mixed non-text modality profiling.

  3. Encoder compute budget and cache size are added to scheduler config, but they remain hardcoded and should be optimized in a later PR.

Verified with VLLM_USE_V1=1 VLLM_ENABLE_V1_MULTIPROCESSING=1 python3 mmmu_bench.py --model OpenGVLab/InternVL2_5-8B --trust-remote-code --gpu-memory-utilization 0.99 from #11196

Main branch:

...
INFO 12-15 10:18:11 uniproc_executor.py:64] # GPU blocks: 31207
...
torch.OutOfMemoryError: CUDA out of memory. Tried to allocate 322.00 MiB. GPU 0 has a total capacity of 79.10 GiB of which 249.88 MiB is free. 

This PR:

...
INFO 12-15 10:16:26 uniproc_executor.py:64] # GPU blocks: 30973
...
Request throughput: 8.13 req/s
Total generated tokens: 39100
Token generation rate: 317.89 tok/s

Signed-off-by: Roger Wang <[email protected]>
Signed-off-by: Roger Wang <[email protected]>
Copy link

👋 Hi! Thank you for contributing to the vLLM project.
Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of those by going to your fastcheck build on Buildkite UI (linked in the PR checks section) and unblock them. If you do not have permission to unblock, ping simon-mo or khluu to add you in our Buildkite org.

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:

  • Add ready label to the PR
  • Enable auto-merge.

🚀

Signed-off-by: Roger Wang <[email protected]>
Signed-off-by: Roger Wang <[email protected]>
vllm/v1/worker/gpu_model_runner.py Outdated Show resolved Hide resolved
vllm/v1/worker/gpu_model_runner.py Outdated Show resolved Hide resolved
Signed-off-by: Roger Wang <[email protected]>
Copy link
Member

@DarkLight1337 DarkLight1337 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM now!

@DarkLight1337 DarkLight1337 added the ready ONLY add when PR is ready to merge/full CI is needed label Dec 16, 2024
Copy link
Collaborator

@WoosukKwon WoosukKwon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! Left some minor comments.

vllm/v1/worker/gpu_model_runner.py Outdated Show resolved Hide resolved
vllm/v1/worker/gpu_model_runner.py Show resolved Hide resolved
vllm/v1/worker/gpu_model_runner.py Outdated Show resolved Hide resolved
vllm/v1/worker/gpu_model_runner.py Outdated Show resolved Hide resolved
@ywang96
Copy link
Member Author

ywang96 commented Dec 16, 2024

@WoosukKwon I've addressed your comments via 1720f68 - Let me know if there's any other concern!

Copy link
Member

@mgoin mgoin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks!

@ywang96 ywang96 merged commit 59c9b6e into vllm-project:main Dec 17, 2024
53 checks passed
BKitor pushed a commit to BKitor/vllm that referenced this pull request Dec 30, 2024
joennlae pushed a commit to 44ai-labs/vllm that referenced this pull request Jan 19, 2025
joennlae pushed a commit to 44ai-labs/vllm that referenced this pull request Jan 19, 2025
abmfy pushed a commit to abmfy/vllm-flashinfer that referenced this pull request Jan 24, 2025
abmfy pushed a commit to abmfy/vllm-flashinfer that referenced this pull request Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready ONLY add when PR is ready to merge/full CI is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants