[Refactor]: add a centralized CreateGPUConnector()#2530
[Refactor]: add a centralized CreateGPUConnector()#2530sammshen merged 8 commits intoLMCache:devfrom
Conversation
Signed-off-by: Samuel Shen <slshen@uchciago.edu>
Summary of ChangesHello @sammshen, 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 refactors the GPU connector creation and management within the LMCache system. By introducing a centralized factory function and reorganizing related utility code into dedicated modules, it aims to improve the clarity, maintainability, and extensibility of how GPU connectors are initialized and utilized across different integration points like SGLang and vLLM. The changes streamline device handling and parallel configuration logic, making the system more robust and easier to understand. 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 a valuable refactoring by centralizing the GPU connector creation logic into a CreateGPUConnector factory function. This significantly improves code maintainability by removing duplicated logic from sglang_adapter.py and manager.py. The new gpu_connector package is well-structured, and the added utility for calculating local rank and world size enhances multi-node support for vLLM. I've identified one potential issue regarding XPU platform support for layerwise connectors and a minor opportunity for code simplification.
Signed-off-by: Samuel Shen <slshen@uchciago.edu>
Signed-off-by: Samuel Shen <slshen@uchciago.edu>
| return torch_dev, dev_name | ||
|
|
||
|
|
||
| def calculate_local_rank_and_world_size(vllm_config: "VllmConfig"): |
There was a problem hiding this comment.
logic to find local worker id
| dtype=kv_dtype, | ||
| device=device, | ||
| ) | ||
| gpu_connector = CreateGPUConnector(config, metadata, "sglang") |
There was a problem hiding this comment.
format can remove the passing of engine string like "sglang" in the future
|
|
||
|
|
||
| def calculate_local_rank_and_world_size(vllm_config: "VllmConfig"): | ||
| """ |
There was a problem hiding this comment.
Update doc string and return type hint
| from lmcache.v1.config import LMCacheEngineConfig | ||
| from lmcache.v1.config_base import parse_command_line_extra_params | ||
| from lmcache.v1.gpu_connector import VLLMPagedMemGPUConnectorV2 | ||
| from lmcache.v1.gpu_connector.gpu_connectors import VLLMPagedMemGPUConnectorV2 |
There was a problem hiding this comment.
See if we can use CreateGPUConnector() in this file
| from lmcache.v1.config import LMCacheEngineConfig | ||
| from lmcache.v1.event_manager import EventManager, EventStatus, EventType | ||
| from lmcache.v1.gpu_connector import ( | ||
| from lmcache.v1.gpu_connector.gpu_connectors import ( |
There was a problem hiding this comment.
See if we can use CreateGPUConnector and do not care about which specific type it is
There was a problem hiding this comment.
move to gpu_connector/ folder
Signed-off-by: Samuel Shen <slshen@uchciago.edu>
Signed-off-by: Samuel Shen <slshen@uchciago.edu>
DongDongJu
left a comment
There was a problem hiding this comment.
Hello @sammshen, thanks for the continuous hard working for refactoring.
I left one nit request and few comments but generally looks good!
| device=device, | ||
| ) | ||
| else: | ||
| return SGLangGPUConnector( |
There was a problem hiding this comment.
Not sure that this case is still working with actual integration case in sglang codes.
@Oasis-Git Do you think that remove this case and forcing to layerwise mode is too brutal?
There was a problem hiding this comment.
this logic has not changed at all
There was a problem hiding this comment.
Yes I saw that. I meant that SGLangGPUConnector integration is not valid anymore If I remember correctly.
So asked the opinion about removal after this PR.
Signed-off-by: Samuel Shen <slshen@uchciago.edu>
DongDongJu
left a comment
There was a problem hiding this comment.
LGTM. Thanks for hard working!
* CreateGPUConnector() Signed-off-by: Samuel Shen <slshen@uchciago.edu> * move the import outside of TYPE_CHECKING Signed-off-by: Samuel Shen <slshen@uchciago.edu> * fix need_gpu_interm_buffer UT Signed-off-by: Samuel Shen <slshen@uchciago.edu> * address AspostaC's comments Signed-off-by: Samuel Shen <slshen@uchciago.edu> * move xpu connector Signed-off-by: Samuel Shen <slshen@uchciago.edu> --------- Signed-off-by: Samuel Shen <slshen@uchciago.edu> Co-authored-by: Samuel Shen <slshen@uchciago.edu>
* CreateGPUConnector() Signed-off-by: Samuel Shen <slshen@uchciago.edu> * move the import outside of TYPE_CHECKING Signed-off-by: Samuel Shen <slshen@uchciago.edu> * fix need_gpu_interm_buffer UT Signed-off-by: Samuel Shen <slshen@uchciago.edu> * address AspostaC's comments Signed-off-by: Samuel Shen <slshen@uchciago.edu> * move xpu connector Signed-off-by: Samuel Shen <slshen@uchciago.edu> --------- Signed-off-by: Samuel Shen <slshen@uchciago.edu> Co-authored-by: Samuel Shen <slshen@uchciago.edu>
* CreateGPUConnector() Signed-off-by: Samuel Shen <slshen@uchciago.edu> * move the import outside of TYPE_CHECKING Signed-off-by: Samuel Shen <slshen@uchciago.edu> * fix need_gpu_interm_buffer UT Signed-off-by: Samuel Shen <slshen@uchciago.edu> * address AspostaC's comments Signed-off-by: Samuel Shen <slshen@uchciago.edu> * move xpu connector Signed-off-by: Samuel Shen <slshen@uchciago.edu> --------- Signed-off-by: Samuel Shen <slshen@uchciago.edu> Co-authored-by: Samuel Shen <slshen@uchciago.edu> Signed-off-by: shaoxiawjc <wjc2800@163.com>
lmcache/v1/gpu_connector/__init__.pyThis prepares: