-
Notifications
You must be signed in to change notification settings - Fork 532
[Store] Add alloc_in_same_node as a configurable parameter #3952
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?
Conversation
Signed-off-by: LCAIZJ <leichao139636@163.com>
|
👋 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 introduces a new configurable parameter alloc_in_same_node to control the local-preference allocation policy in the Mooncake store. The changes in config_data.py correctly add and load this parameter. However, I've found a critical issue in mooncake_store.py where using this new feature could lead to an AttributeError under certain configurations. My review includes a comment with a suggested fix that not only resolves the bug but also improves the code's robustness and maintainability.
| if self.config.alloc_in_same_node: | ||
| config = ReplicateConfig() | ||
| config.preferred_segment = self.local_seg | ||
| config.prefer_alloc_in_same_node = True | ||
| res = self.store.batch_put_from_multi_buffers( | ||
| keys, addrs, sizes, config) | ||
| else: | ||
| res = self.store.batch_put_from_multi_buffers( | ||
| keys, addrs, sizes) |
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.
There's a potential AttributeError here because self.local_seg is used but it's not guaranteed to be initialized in Mooncakestore.__init__. Specifically, if self.config.protocol == "ascend" and self.config.use_ascend_direct is False, self.local_seg is not set, which would cause a crash if alloc_in_same_node is True.
The suggested change fixes this by explicitly checking for self.local_seg and raising an AttributeError with a helpful message if it's missing. This makes configuration errors easier to debug. It also refactors the logic to be more concise and avoid duplicating the call to batch_put_from_multi_buffers.
| if self.config.alloc_in_same_node: | |
| config = ReplicateConfig() | |
| config.preferred_segment = self.local_seg | |
| config.prefer_alloc_in_same_node = True | |
| res = self.store.batch_put_from_multi_buffers( | |
| keys, addrs, sizes, config) | |
| else: | |
| res = self.store.batch_put_from_multi_buffers( | |
| keys, addrs, sizes) | |
| put_args = [keys, addrs, sizes] | |
| if self.config.alloc_in_same_node: | |
| if not hasattr(self, "local_seg"): | |
| raise AttributeError("alloc_in_same_node is True, but local_seg is not initialized.") | |
| config = ReplicateConfig() | |
| config.preferred_segment = self.local_seg | |
| config.prefer_alloc_in_same_node = True | |
| put_args.append(config) | |
| res = self.store.batch_put_from_multi_buffers(*put_args) |
What this PR does / why we need it?
Add alloc_in_same_node as a configurable parameter,
alloc_in_same_node=Trueenables the local-preference allocation policy.Does this PR introduce any user-facing change?
How was this patch tested?