-
Notifications
You must be signed in to change notification settings - Fork 624
[P/D][main] Clean connector history information #4650
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
base: main
Are you sure you want to change the base?
[P/D][main] Clean connector history information #4650
Conversation
Signed-off-by: wangxiaoteng <[email protected]>
|
👋 Hi! Thank you for contributing to the vLLM Ascend project. The following points will speed up your PR merge:
If CI fails, you can run linting and testing checks locally according Contributing and Testing. |
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.
Code Review
This pull request addresses the issue of stale connector history by appending a UUID to the engine_id, ensuring a unique identity for each node restart. This is a solid approach. Additionally, it introduces a SizedDict to replace defaultdict for caching remote engine metadata, which prevents unbounded memory growth.
My review includes two main points for improvement:
- The implementation of
SizedDictcan be simplified by removing an unnecessary@dataclassdecorator. - The default size limit in
SizedDictis very small and could cause performance issues in larger deployments. I've suggested increasing it and making it configurable.
These changes will improve the maintainability and performance robustness of the new caching mechanism.
| @dataclass | ||
| class SizedDict(OrderedDict): |
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 use of @dataclass on the SizedDict class is unnecessary and potentially misleading. This class defines a custom __init__ method and inherits from OrderedDict, which is not a dataclass. The @dataclass decorator is designed for classes that primarily store data and can auto-generate methods like __init__ and __repr__. In this case, it provides no benefit and could cause confusion or unexpected behavior during future maintenance. It's better to define it as a regular class for clarity and correctness.
| @dataclass | |
| class SizedDict(OrderedDict): | |
| class SizedDict(OrderedDict): |
| self.remote_kv_caches_base_addr: dict[str, dict[int, list[int]]] = \ | ||
| defaultdict(dict) | ||
| SizedDict() | ||
| self.remote_te_port: dict[str, dict[int, int]] = \ | ||
| defaultdict(dict) | ||
| SizedDict() |
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 new SizedDict is initialized with its default max_size of 2. This means it will only cache metadata for the two most recently used remote engines. In a deployment with more than two peer engines, this could lead to cache thrashing, where metadata is frequently evicted and then re-fetched over the network, potentially impacting performance.
It would be more robust to make this cache size configurable. For example, you could add a configuration option and pass it to the SizedDict constructor:
# In MooncakeLayerwiseConnectorWorker.__init__
max_cached_engines = self.vllm_config.kv_transfer_config.get_from_extra_config(
'max_cached_engines', 128) # A more reasonable default
# ...
self.remote_kv_caches_base_addr: dict[str, dict[int, list[int]]] = \
SizedDict(max_size=max_cached_engines)
self.remote_te_port: dict[str, dict[int, int]] = \
SizedDict(max_size=max_cached_engines)This would allow operators to tune the cache size based on their specific deployment topology. For now, I'm suggesting a larger default.
| self.remote_kv_caches_base_addr: dict[str, dict[int, list[int]]] = \ | |
| defaultdict(dict) | |
| SizedDict() | |
| self.remote_te_port: dict[str, dict[int, int]] = \ | |
| defaultdict(dict) | |
| SizedDict() | |
| self.remote_kv_caches_base_addr: dict[str, dict[int, list[int]]] = \ | |
| SizedDict(max_size=128) | |
| self.remote_te_port: dict[str, dict[int, int]] = \ | |
| SizedDict(max_size=128) |
Signed-off-by: wangxiaoteng <[email protected]>
Signed-off-by: wangxiaoteng <[email protected]>
Signed-off-by: wangxiaoteng <[email protected]>
Signed-off-by: wangxiaoteng <[email protected]>
What this PR does / why we need it?
Clean connector history information when the node restarts.
Does this PR introduce any user-facing change?
No
How was this patch tested?
By ci