-
Notifications
You must be signed in to change notification settings - Fork 433
[BugFix] Adapt mooncake_connector_v1 to latest vllm #1080
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
Open
ZeldaHuang
wants to merge
2
commits into
kvcache-ai:main
Choose a base branch
from
ZeldaHuang:fix/vllm_pd_connector
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,16 +22,15 @@ | |
| import torch | ||
| import zmq | ||
|
|
||
| from vllm.attention.selector import backend_name_to_enum, get_attn_backend | ||
| from vllm.attention.selector import AttentionBackendEnum, get_attn_backend | ||
| from vllm.config import VllmConfig | ||
| from vllm.distributed.kv_transfer.kv_connector.v1.base import ( | ||
| KVConnectorBase_V1, KVConnectorMetadata, KVConnectorRole) | ||
| from vllm.distributed.parallel_state import (get_tensor_model_parallel_rank, | ||
| get_tp_group) | ||
| from vllm.forward_context import ForwardContext | ||
| from vllm.logger import init_logger | ||
| from vllm.platforms import _Backend | ||
| from vllm.utils import get_ip, make_zmq_path, make_zmq_socket | ||
| from vllm.utils.network_utils import get_ip, make_zmq_path, make_zmq_socket | ||
| from vllm.v1.attention.backends.utils import get_kv_cache_layout | ||
| from vllm.v1.core.sched.output import SchedulerOutput | ||
| from vllm.v1.request import RequestStatus | ||
|
|
@@ -114,6 +113,7 @@ class MooncakeConnector(KVConnectorBase_V1): | |
| def __init__(self, vllm_config: VllmConfig, role: KVConnectorRole): | ||
| assert vllm_config.kv_transfer_config is not None | ||
| assert vllm_config.kv_transfer_config.engine_id is not None | ||
| super().__init__(vllm_config, role) | ||
| self.engine_id: EngineId = vllm_config.kv_transfer_config.engine_id | ||
|
|
||
| if role == KVConnectorRole.SCHEDULER: | ||
|
|
@@ -425,12 +425,11 @@ def __init__(self, vllm_config: VllmConfig, engine_id: str): | |
| self.model_config.dtype, | ||
| self.cache_config.cache_dtype, | ||
| self.block_size, | ||
| self.model_config.is_attention_free, | ||
| use_mla=self.use_mla) | ||
| self.backend_name = backend.get_name() | ||
| attn_backend = backend_name_to_enum(self.backend_name) | ||
| self._use_flashinfer = attn_backend == _Backend.FLASHINFER_VLLM_V1 | ||
| self._use_pallas_v1 = attn_backend == _Backend.PALLAS_VLLM_V1 | ||
| attn_backend = AttentionBackendEnum[self.backend_name] | ||
| self._use_flashinfer = attn_backend in [AttentionBackendEnum.FLASHINFER, AttentionBackendEnum.FLASHINFER_MLA] | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| self._use_pallas_v1 = attn_backend == AttentionBackendEnum.PALLAS | ||
| self.kv_cache_layout = get_kv_cache_layout() | ||
| logger.debug("Detected attention backend %s", self.backend_name) | ||
| logger.debug("Detected kv cache layout %s", self.kv_cache_layout) | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The current implementation
AttentionBackendEnum[self.backend_name]attempts to access an enum member by its name. However,self.backend_name(e.g., 'flashinfer') is the value of the enum member, not its name (e.g., 'FLASHINFER'). This will cause aKeyErrorat runtime, preventing the worker from initializing.To correctly get the enum member from its value, you should call the enum as a function:
AttentionBackendEnum(self.backend_name).