Fault Tolerance Check#2692
Conversation
Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com>
Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com>
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 enhances the fault tolerance of the LMCache vLLM multi-process adapter by integrating a robust health-checking system. It introduces a dedicated heartbeat thread to continuously monitor the LMCache server's health. When the server becomes unresponsive, the adapter transitions into a degraded mode, preventing new operations and managing existing ones to ensure system stability. This change improves the overall resilience and reliability of the LMCache integration by proactively addressing potential server failures. 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 fault tolerance to the vLLM multi-process adapter by adding a heartbeat thread for server health checks. When the server is unhealthy, the adapters enter a degraded mode, failing fast on operations. Timeouts have also been added to several message queue operations to prevent indefinite blocking. The changes are well-implemented and significantly improve robustness. I have a couple of suggestions to improve documentation and code maintainability.
| """Periodically checks server health via HEALTH_CHECK. | ||
|
|
||
| Manages a threading.Event that adapters use to gate operations. | ||
| Once unhealthy, the adapter degrades permanently (no recovery). |
There was a problem hiding this comment.
The docstring states that the adapter degrades permanently, but the implementation allows for recovery. The _execute method will call self._health_event.set() if the health check passes again, allowing the adapter to resume normal operation. Please update the docstring to reflect this recovery capability.
| Once unhealthy, the adapter degrades permanently (no recovery). | |
| Once unhealthy, the adapter enters a degraded mode, and can recover once the server is healthy again. |
| try: | ||
| self.chunk_size = get_lmcache_chunk_size(self.mq_client) | ||
| except TimeoutError: | ||
| self.mq_client.close() | ||
| raise ConnectionError( | ||
| f"LMCache server did not respond within {LMCACHE_MQ_TIMEOUT}s. " | ||
| "Is the server running?" | ||
| ) from None | ||
| assert self.chunk_size % vllm_block_size == 0, ( | ||
| "LMCache chunk size should be a multiple of vLLM block size" | ||
| ) | ||
| self.blocks_in_chunk = self.chunk_size // vllm_block_size | ||
|
|
||
| # Health state (shared with heartbeat thread) | ||
| self._health_event = threading.Event() | ||
| self._health_event.set() | ||
|
|
||
| # Start heartbeat thread | ||
| self._heartbeat = HeartbeatThread( | ||
| mq_client=self.mq_client, | ||
| health_event=self._health_event, | ||
| ) | ||
| self._heartbeat.start() |
There was a problem hiding this comment.
The initialization logic for fault tolerance, including the try...except block for get_lmcache_chunk_size and the setup of the HeartbeatThread, is duplicated in LMCacheMPSchedulerAdapter.__init__ (here) and LMCacheMPWorkerAdapter.__init__ (lines 419-441). To improve maintainability and reduce redundancy, consider refactoring this common logic into a shared base class or a helper function.
Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com>
ApostaC
left a comment
There was a problem hiding this comment.
Some changes are needed. See the details below
| ) | ||
|
|
||
| for request_id, r_future in self.retrieve_futures.items(): | ||
| for request_id, (r_future, r_block_ids) in self.retrieve_futures.items(): |
There was a problem hiding this comment.
nit:
| for request_id, (r_future, r_block_ids) in self.retrieve_futures.items(): | |
| for request_id, (r_future, _) in self.retrieve_futures.items(): |
|
cc @maobaolong for visibility. |
| "HEALTH_CHECK": ProtocolDefinition( | ||
| payload_classes=[], | ||
| response_class=bool, | ||
| handler_type=HandlerType.SYNC, |
There was a problem hiding this comment.
We can use BLOCKING as the handler type
…branch) Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com>
Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com>
Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com>
|
|
||
| # Timeout (seconds) for blocking MQ requests: initial chunk-size query, | ||
| # KV cache registration/unregistration, and other synchronous operations. | ||
| DEFAULT_MQ_TIMEOUT: float = 30.0 |
| """ | ||
| future = send_lmcache_request(mq_client, RequestType.GET_CHUNK_SIZE, []) | ||
| chunk_size = future.result() | ||
| chunk_size = future.result(timeout=DEFAULT_MQ_TIMEOUT) |
There was a problem hiding this comment.
We are hard-coding the timeout here. Does this mean that people cannot overwrite this from vLLM's config?
Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com>
Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com>
* health check Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com> * lint Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com> * fix ut Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com> * fix Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com> * dev Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com> * timeout Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com> * fix ut Signed-off-by: yuweia <ayw.sirius19@gmail.com> * add comment Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com> * add test Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com> * Remove fault tolerance CI step (will be added in separate fault-t-ci branch) Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com> * Rename HEALTH_CHECK to PING, add timeout params, extract helper Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com> * fix Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com> * fix ut Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com> * fix timeout Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com> --------- Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com> Signed-off-by: yuweia <ayw.sirius19@gmail.com> Signed-off-by: Aaron Wu <aaron.wu@dell.com>
* health check Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com> * lint Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com> * fix ut Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com> * fix Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com> * dev Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com> * timeout Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com> * fix ut Signed-off-by: yuweia <ayw.sirius19@gmail.com> * add comment Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com> * add test Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com> * Remove fault tolerance CI step (will be added in separate fault-t-ci branch) Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com> * Rename HEALTH_CHECK to PING, add timeout params, extract helper Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com> * fix Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com> * fix ut Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com> * fix timeout Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com> --------- Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com> Signed-off-by: yuweia <ayw.sirius19@gmail.com>
* health check Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com> * lint Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com> * fix ut Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com> * fix Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com> * dev Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com> * timeout Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com> * fix ut Signed-off-by: yuweia <ayw.sirius19@gmail.com> * add comment Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com> * add test Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com> * Remove fault tolerance CI step (will be added in separate fault-t-ci branch) Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com> * Rename HEALTH_CHECK to PING, add timeout params, extract helper Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com> * fix Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com> * fix ut Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com> * fix timeout Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com> --------- Signed-off-by: Oasis-Git <ayw.sirius19@gmail.com> Signed-off-by: yuweia <ayw.sirius19@gmail.com>
What this PR does / why we need it:
Special notes for your reviewers:
If applicable: