-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[USAGE] Improve error handling for weight initialization in Unquantized… #20321
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
Conversation
👋 Hi! Thank you for contributing to the vLLM project. 💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels. Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run 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 either: Add 🚀 |
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.
Summary of Changes
Hello @koiker, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request significantly improves the user experience when encountering torch.OutOfMemoryError
during vLLM model initialization. It introduces more specific and informative error messages, along with debug details about CUDA memory usage, to help users pinpoint the exact stage of model loading where the memory exhaustion occurs, thereby streamlining the troubleshooting process.
Highlights
- Improved OOM Error Messages: Enhanced error handling in the
UnquantizedLinearMethod
andAttention
classes to provide more specific and informative messages whentorch.OutOfMemoryError
occurs during weight or constant initialization. - Detailed CUDA Memory Debugging: Added logging of CUDA device ID, allocated memory, and reserved memory (in GB) to the error messages, which will significantly aid in troubleshooting memory-related issues during model loading.
- Specific Failure Point Identification: The new error messages clarify whether the Out-of-Memory error happened during the initialization of attention layer constants (
q_range
,k_range
,v_range
) or unquantized linear layer weights, making it easier to pinpoint the exact stage of failure.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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.
Code Review
The code changes improve error handling for out-of-memory situations during model weight initialization by logging CUDA memory statistics. The exception type caught in vllm/attention/layer.py
and vllm/model_executor/layers/linear.py
can be narrowed for better precision.
I think there may be a git issue as the diff is unusually large |
Hi @hmellor, I have two files changed.
But for some reason, there are other commits in the same PR. |
This pull request has merge conflicts that must be resolved before it can be |
The Lint and Deploy Charts / lint-and-deploy (pull_request) failed due to a docker build error. |
I have rerun it for you |
buildkite is failing to complete some tasks. |
Hi @DarkLight1337, I have re-run the checks, all appears to be good. |
vllm/attention/layer.py
Outdated
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.
Maybe we can use vllm.utils.MemorySnapshot
class to avoid code duplication
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.
Looks good overall, just some nits about GiB
and @DarkLight1337's comment about using a memory util
Please resolve the merge conflict and we can get this merged |
…LinearMethod and Attention class. When initializing vLLM the `torch.OutOfMemoryError: CUDA out of memory.` is opaque and does not indicate which step of the loading model it failed. Also it is not clear where the pre-allocated memory has been used. Errors like: ``` torch.OutOfMemoryError: CUDA out of memory. Tried to allocate 896.00 MiB. GPU 2 has a total capacity of 23.57 GiB of which 235.88 MiB is free. Including non-PyTorch memory, this process has 23.33 GiB memory in use. Of the allocated memory 23.03 GiB is allocated by PyTorch, and 13.48 MiB is reserved by PyTorch but unallocated. If reserved but unallocated memory is large try setting PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True to avoid fragmentation. See documentation for Memory Management (https://pytorch.org/docs/stable/notes/cuda.html#environment-variables) ``` This small change will include a more clear error message on which step of the model loading the error has occured and allow users to change the settings to use a model that will fit the memory or adjust other settings in the vllm. Signed-off-by: Rafael Marcelino Koike <[email protected]> Signed-off-by: Rafael Koike <[email protected]>
Signed-off-by: Rafael Marcelino Koike <[email protected]> Signed-off-by: Rafael Koike <[email protected]>
Signed-off-by: Rafael Marcelino Koike <[email protected]> Signed-off-by: Rafael Koike <[email protected]>
Signed-off-by: Rafael Marcelino Koike <[email protected]> Signed-off-by: Rafael Koike <[email protected]>
Signed-off-by: Rafael Koike <[email protected]>
Signed-off-by: Rafael Koike <[email protected]>
Signed-off-by: Rafael Koike <[email protected]>
…ed… (vllm-project#20321) Signed-off-by: Rafael Marcelino Koike <[email protected]> Signed-off-by: Rafael Koike <[email protected]>
…ed… (vllm-project#20321) Signed-off-by: Rafael Marcelino Koike <[email protected]> Signed-off-by: Rafael Koike <[email protected]>
…ed… (vllm-project#20321) Signed-off-by: Rafael Marcelino Koike <[email protected]> Signed-off-by: Rafael Koike <[email protected]> Signed-off-by: xuebwang-amd <[email protected]>
…ed… (vllm-project#20321) Signed-off-by: Rafael Marcelino Koike <[email protected]> Signed-off-by: Rafael Koike <[email protected]>
…LinearMethod and Attention class.
When initializing vLLM the
torch.OutOfMemoryError: CUDA out of memory.
is opaque and does not indicate which step of the loading model it failed. Also it is not clear where the pre-allocated memory has been used.Errors like:
This small change will include a more clear error message on which step of the model loading the error has occurred and allow users to change the settings to use a model that will fit the memory or adjust other settings in the vllm.
Essential Elements of an Effective PR Description Checklist
supported_models.md
andexamples
for a new model.Purpose
Improve the usage of vLLM when initializing a vLLM instance or starting a vLLM serve and loading the model throws an out-of-memory error, but it is not clear if there was a previous process using the memory or if the device set to load the model is the correct one. This change will include logging and debug information that will allow developers and engineers to better understand at which step in the model loading the error occurs. This will improve the troubleshooting process to resolve the issue of loading LLMs with vLLM
Test Plan
Load a model that is larger than the available memory and see the torch.OutOfMemoryError happens. Try to understand from the information displayed where is the issue.
Test Result
After the implementation of the code in this PR, this is an example of the output of an error loading a large LLM that does not fit into the GPU memory:
Note: In this example, the environment variable
VLLM_LOGGING_LEVEL
was set toDEBUG
to show extra information about the GPU ID and memory utilization.(Optional) Documentation Update