-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
[core] overhaul memory profiling and fix backward compatibility #10511
Conversation
Signed-off-by: youkaichao <[email protected]>
👋 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:
🚀 |
Signed-off-by: youkaichao <[email protected]>
Signed-off-by: youkaichao <[email protected]>
Signed-off-by: youkaichao <[email protected]>
cc @joerunde |
This pull request has merge conflicts that must be resolved before it can be |
any progress? I do need to run multi-instance with one GPU. |
is this function available? |
let me finish it this week. |
Thanks for taking this on @youkaichao! I think the docs for the |
Signed-off-by: youkaichao <[email protected]>
Signed-off-by: youkaichao <[email protected]>
vllm/worker/worker.py
Outdated
"PyTorch activation peak memory\t" | ||
f"{(result.torch_peak_increase_in_bytes / GiB_bytes):.2f}GiB\n" | ||
"available_kv_cache_memory\t" | ||
f"{(available_kv_cache_memory / GiB_bytes):.2f}GiB\n") |
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.
Some suggestions on making this a bit nicer:
- The log would be much easier to parse if the numbers were aligned on the same column, right now they're all over the place
- The descriptions are a mix of plain words and variable names, for logs maybe we should just use words.
available_kv_cache_memory:
->KV Cache Size:
etc. - "Non torch memory" is the one item on this list that I think might not be easily understood by somebody reading the logs. Maybe calling it something a little more generic like "Memory overhead" would be less distracting
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 think all of the newlines take too much space in the logs. IMO it would be more simple to keep the same single-line comma-separated result as before
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.
addressed in #10511 (comment) , PTAL
@youkaichao Any chance you can add in a quick test for the profiling context manager itself? As an example the one I wrote up here was very simple to do: https://github.com/vllm-project/vllm/pull/11120/files#diff-33c13e0b177bacd2f02e29bcb8aea5b49e7ce34901fd8f41fefb65defba1bd33R277-R312 |
@youkaichao 🤔🤔🤔 Loading
Might not be super important to fix- I think the main use case to unblock here is multi-process vllm serving. But it is interesting, I can't immediately see why that would happen |
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.
Excellent work Kaichao, I appreciate the walkthrough example in memory_profiling
. This passed my local usage and I didn't see the issue Joe saw, or think it is a serious issue. My only nit is on adding all the newlines to the log, I think it was fine as comma-separated list
vllm/worker/worker.py
Outdated
"PyTorch activation peak memory\t" | ||
f"{(result.torch_peak_increase_in_bytes / GiB_bytes):.2f}GiB\n" | ||
"available_kv_cache_memory\t" | ||
f"{(available_kv_cache_memory / GiB_bytes):.2f}GiB\n") |
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 think all of the newlines take too much space in the logs. IMO it would be more simple to keep the same single-line comma-separated result as before
Signed-off-by: youkaichao <[email protected]>
Signed-off-by: youkaichao <[email protected]>
Signed-off-by: youkaichao <[email protected]>
Signed-off-by: youkaichao <[email protected]>
@mgoin changed the logging to be:
Let me know if you have further ideas on how to improve the readability. |
@joerunde this is because PyTorch's internal memory fragmentation. If PyTorch allocates 2MiB from cuda, and allocate 1MiB only, then this 1 MiB will be accounted as non-torch memory. And when you run it the next time, maybe you allocate another 1 MiB, and the internal memory fragmentation reduces. |
Signed-off-by: youkaichao <[email protected]>
Signed-off-by: youkaichao <[email protected]>
Signed-off-by: youkaichao <[email protected]>
@joerunde that's a great idea! I added it now, PTAL. |
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 pretty good to me! Thanks for looking at this so thoroughly
errors are unrelated, merging |
…-project#10511) Signed-off-by: youkaichao <[email protected]>
fixes #10451 , and clearly explain the memory classification and the procedure.
I also added the initial pytorch memory, to be aligned with the pytorch memory profiler.
the profiling procedure is extracted into
vllm/utils
, so that we can use it later in v1 too.