[MP] Support MP Server restart#2713
Conversation
Summary of ChangesHello, 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 robustness of the LMCache system by addressing the scenario where the multi-process server restarts. It introduces an automatic re-registration capability for KV caches on the client side and enhances error handling on the server side, ensuring that operations can resume seamlessly after a server interruption. These changes make the system more resilient and reliable in dynamic environments. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe 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 by creating a comment using either
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 Limitations & Feedback Gemini Code Assist 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. 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
|
There was a problem hiding this comment.
Code Review
This pull request introduces support for LMCache server restarts by making the client-side adapter more resilient. The changes include modifying the server to gracefully handle requests for unregistered instances, updating the client-side futures to handle failure responses, implementing auto-re-registration logic in the vLLM adapter, and adding a comprehensive integration test. The overall approach is solid. I have a couple of suggestions to further improve the robustness of the re-registration logic by adding timeouts and better exception handling to prevent the worker from hanging or crashing if the server is temporarily unavailable. I also have a minor suggestion to improve the clarity of one of the new tests.
DongDongJu
left a comment
There was a problem hiding this comment.
Hello @maobaolong, thanks for the work.
Generally, LGTM.
But I have one concern that need_reregister decide logic is too simple now since retrieve return other failure too. (currently only two return True/False).
But we can handle it next pr.
Signed-off-by: baoloongmao <baoloongmao@tencent.com>
Signed-off-by: baoloongmao <baoloongmao@tencent.com>
Signed-off-by: baoloongmao <baoloongmao@tencent.com>
07e318c to
f8b97d6
Compare
Signed-off-by: baoloongmao <baoloongmao@tencent.com>
|
@DongDongJu Thanks for your review and good suggestion, i addressed it. |
ApostaC
left a comment
There was a problem hiding this comment.
@maobaolong this one actually incurs a few problems... The default value of LMCACHE_REGISTER_TIMEOUT is too small. And right now, this may have some design conflict with #2692
Can we revert this PR temporarily? To support server restart, a better solution is to make the mq_client be able to reconnect.
| if self.is_done_.is_set(): | ||
| # Completed without a CUDA event (e.g. server | ||
| # returned failure with empty handle). | ||
| return True | ||
|
|
There was a problem hiding this comment.
There is a race condition here.
Thread A (_on_raw_future_complete): run self.is_done_.set()
Thread B (wait): run if self.event_: and found self.event_ is None
Thread B (wait): run if self.is_done_.set(): return True
Thread A (_on_raw_future_complete): run self.event_ = torch.cuda.Event.from_ipc_handle(self.device_, event_bytes) that initializes the real cuda event
This race condition will cause correctness issues or un-needed re-registration which have undefined behavior.
| ], | ||
| ) | ||
| future.result() | ||
| timeout = float(os.getenv("LMCACHE_REGISTER_TIMEOUT", "5.0")) |
There was a problem hiding this comment.
This default timeout is too short. The LMCache side need to initialize the cuda stream and cupy, which may take ~2 seconds for a single TP worker.
This reverts commit 55622e8. Signed-off-by: ApostaC <yihua98@uchicago.edu>
* [MP] Support MP Server restart Signed-off-by: baoloongmao <baoloongmao@tencent.com> * Address comment Signed-off-by: baoloongmao <baoloongmao@tencent.com> * Address comment from dongdongju Signed-off-by: baoloongmao <baoloongmao@tencent.com> * Fix related failed UT. Signed-off-by: baoloongmao <baoloongmao@tencent.com> --------- Signed-off-by: baoloongmao <baoloongmao@tencent.com> Signed-off-by: shaoxiawjc <wjc2800@163.com>
This reverts commit 55622e8. Signed-off-by: ApostaC <yihua98@uchicago.edu> Signed-off-by: shaoxiawjc <wjc2800@163.com>
* [MP] Support MP Server restart Signed-off-by: baoloongmao <baoloongmao@tencent.com> * Address comment Signed-off-by: baoloongmao <baoloongmao@tencent.com> * Address comment from dongdongju Signed-off-by: baoloongmao <baoloongmao@tencent.com> * Fix related failed UT. Signed-off-by: baoloongmao <baoloongmao@tencent.com> --------- Signed-off-by: baoloongmao <baoloongmao@tencent.com> Signed-off-by: Aaron Wu <aaron.wu@dell.com>
This reverts commit 55622e8. Signed-off-by: ApostaC <yihua98@uchicago.edu> Signed-off-by: Aaron Wu <aaron.wu@dell.com>
* [MP] Support MP Server restart Signed-off-by: baoloongmao <baoloongmao@tencent.com> * Address comment Signed-off-by: baoloongmao <baoloongmao@tencent.com> * Address comment from dongdongju Signed-off-by: baoloongmao <baoloongmao@tencent.com> * Fix related failed UT. Signed-off-by: baoloongmao <baoloongmao@tencent.com> --------- Signed-off-by: baoloongmao <baoloongmao@tencent.com>
This reverts commit 55622e8. Signed-off-by: ApostaC <yihua98@uchicago.edu>
* [MP] Support MP Server restart Signed-off-by: baoloongmao <baoloongmao@tencent.com> * Address comment Signed-off-by: baoloongmao <baoloongmao@tencent.com> * Address comment from dongdongju Signed-off-by: baoloongmao <baoloongmao@tencent.com> * Fix related failed UT. Signed-off-by: baoloongmao <baoloongmao@tencent.com> --------- Signed-off-by: baoloongmao <baoloongmao@tencent.com>
This reverts commit 55622e8. Signed-off-by: ApostaC <yihua98@uchicago.edu>
What this PR does / why we need it:
introduces an automatic re-registration capability for KV caches on the client side and enhances error handling on the server side, ensuring that operations can resume seamlessly after a server interruption. These changes make the system more resilient and reliable in dynamic environments.
Special notes for your reviewers:
If applicable: