- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 10.9k
          [Bugfix][Frontend] Fix Issues Under High Load With zeromq Frontend
          #7394
        
          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
  
    [Bugfix][Frontend] Fix Issues Under High Load With zeromq Frontend
  
  #7394
              Conversation
| 👋 Hi! Thank you for contributing to the vLLM project. Once the PR is approved and ready to go, please make sure to run full CI as it is required to merge (or just use auto-merge). To run full CI, you can do one of these: 
 🚀 | 
zeromq Frontend At High QPSzeromq Frontend
      zeromq Frontendzeromq Frontend
      zeromq Frontendzeromq Frontend
      zeromq Frontendzeromq Frontend
      | After further investigation, I using zmq sockets will impose a hard limit on the number of active request. While it is possible to change the value of  We are unable to change the value: import zmq
ctx = zmq.Context()
ctx.get(zmq.SOCKET_LIMIT)
# >>> 65535
ctx.set(zmq.SOCKET_LIMIT, 10000000)
ctx.get(zmq.SOCKET_LIMIT)
# >>> 65535I believe this will put a hard limit on ZMQ at 65k concurrent connections. This is obviously a lot of requests, but I am worried about an offline batch use case where someone sends 1M requests to Other Options 
 WDYT? | 
Co-authored-by: Nick Hill <[email protected]>
| @robertgshaw2-neuralmagic thanks for the great work! I think limiting the total number of pending requests make sense to me. Many web servers should have similar constraints. As for offline batching inference, we don't need to surface this to users. We can accept arbitrary number of requests, but send part of them to the engine every time. BTW, offline batch inference does not use this api server. So it should not be a concern there. For the technical review, I would like to hand it over to @njhill who has better expertise here. | 
| Also note --- I tried running with  | 
| assert attributes.get(SpanAttributes.LLM_LATENCY_E2E) == e2e_time | ||
| assert attributes.get(SpanAttributes.LLM_LATENCY_TIME_IN_SCHEDULER | ||
| ) == metrics.scheduler_time | ||
| assert attributes.get( | 
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.
make ./format happy
| 
 @robertgshaw2-neuralmagic That would be great, the only issue I'd see is if the  | 
| while True: | ||
| # Wait for a request. | ||
| identity, message = await self.socket.recv_multipart() | ||
| identity, part2, message = await self.socket.recv_multipart() | 
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.
For future readers it'd be nice to add a link to some zmq docs here or give this a descriptive name to say what part2 is. From context here I'm guessing this is routing information for the client-side proxy?
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.
Its related to the use of ROUTER, will do
| 
 hmmmm - can you explain more? | 
| 
 It's probably not a huge deal since vllm itself is a library and doesn't ship k8s configs but, in general readiness probes are used to back off traffic from pods experiencing issues accepting new requests, while liveness probes are used to kill pods that have crashed or experienced some unrecoverable error. If we were to set  I think we'd want to suggest something different to use as a liveness probe in that case, maybe something as simple as checking that the frontend and backend processes are running. | 
| 
 Thanks - this is clear | 
| - vllm/ | ||
| commands: | ||
| - pip install -e ./plugins/vllm_add_dummy_model | ||
| - pip install git+https://github.com/EleutherAI/lm-evaluation-harness.git@a4987bba6e9e9b3f22bd3a6c1ecf0abd04fd5622#egg=lm_eval[api] | 
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.
need to install from source since local-completions api with support for concurrent requests is not yet in release of lm_eval
| self.from_api_server.bind(INPROC_PROXY_PATH) | ||
|  | ||
| # Asyncio background task for the proxy. | ||
| self.proxy_task = asyncio.create_task( | 
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.
@njhill does this need to be explicitly canceled somewhere?
(e.g. in close())
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.
@robertgshaw2-neuralmagic yes, we should cancel it there.
| @@ -0,0 +1,105 @@ | |||
| """ | |||
| This file tests significant load on the vLLM server. | |||
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.
cc @simon-mo --- this test takes ~3 minutes on H100
Will likely take >10 min on L4 ... are you okay with this?
| 
 | 
| Should be merged after: #7698 | 
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 @robertgshaw2-neuralmagic!
…llm-project#7394) Co-authored-by: Nick Hill <[email protected]> Signed-off-by: Alvant <[email protected]>
…llm-project#7394) Co-authored-by: Nick Hill <[email protected]> Signed-off-by: LeiWang1999 <[email protected]>
BUG REPO:
On
v0.5.4due to the mp frontend, we fail under heavy load:server script
The server dies when we get ~1000 active requests in the system
SUMMARY:
icpfor thezeromq-based RPC connection. Each new request connects to this socket on the RPC Server side, meaning for N active requests, we will have N connections.zmq.MAX_SOCKETSdefaults to 1023. If more than this number of sockets is opened we failToo many open fileserror. This puts a hard cap on the number of active requests in vLLM and causes the bugs lists below.zmq.MAX_SOCKETSto a high number resolves our issue. However,lsof -U | wc -lshows we are usingunixsockets under the hood, the number of active requests will be limited by systemulimit. This is a bad UX and again puts a hard cap on the number of active requests running in vLLM.proxyon theRPCClientside. The proxy creates a singleipcconnection from theRPCClientto theRPCServer. Each API server thread handing a request connects to the proxy viainprocprotocol and the message is forwarded over the sinceipcconnection with properidentitytags. This means we only ever create 1 unix socket.NOTES:
zmqhas a variable calledzmq.MAX_SOCKETSwhich applies at theContextlevel. This variable can be set up to a maximum ofzmq.SOCKET_LIMIT=65536. This imposes a hard limit on the number of concurrent connections (see comments below for more details on this topic).PERFORMANCE:
Serving benchmark
H100forLlama-3-8B-InstructatQPS=10:branchrun 1run 2run 3mainpr--disable-frontend-multiprocessingFIX
UPDATE 8/20 POST OFFLINE DISCUSSION
Per discussion offline with @njhill @simon-mo and @youkaichao
After much further investigation, we ran into a separate issue with the proxy design after enabling the proxy. Specifically, we encountered a situation where under high load, zeromq can DROP MESSAGES 😢 , due to a concept called high-water mark (https://zeromq.org/socket-api/#high-water-mark), which is designed to protect servers running zeromq from slow clients. Specifically:
This prevents issues where a server running ZMQ can run OOM due to a slow reciever which is not able to keep up with message passing. The HWM is defaulted to 1000. Its difficult to track down exactly the sequence of events that causes the message dropping under load, but the HWM seems to be the culprit
In our case, we disable the HWM 😨 . This is generally not advisable, however:
Anyways:
test_load.pyto simulate load on the client and try to detect errors like this.test_accuracy.pyto run an lm-eval-harness with concurrent requests via the openai API, which simulates real usage and makes sure we get the correct answer out of the serverBEFORE 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,LLMclass, 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.shto 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.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-requiredand 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-requiredlabel 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!