Skip to content

Conversation

@LCAIZJ
Copy link
Contributor

@LCAIZJ LCAIZJ commented Nov 3, 2025

What this PR does / why we need it?

Add alloc_in_same_node as a configurable parameter, alloc_in_same_node=True enables the local-preference allocation policy.

Does this PR introduce any user-facing change?

How was this patch tested?

Signed-off-by: LCAIZJ <leichao139636@163.com>
@github-actions
Copy link

github-actions bot commented Nov 3, 2025

👋 Hi! Thank you for contributing to the vLLM Ascend project. The following points will speed up your PR merge:‌‌

  • A PR should do only one thing, smaller PRs enable faster reviews.
  • Every PR should include unit tests and end-to-end tests ‌to ensure it works and is not broken by other future PRs.
  • Write the commit message by fulfilling the PR description to help reviewer and future developers understand.

If CI fails, you can run linting and testing checks locally according Contributing and Testing.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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.

Comment on lines +91 to +99
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

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.

Suggested change
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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant