-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
[BugFix][KVConn] Fix use of get_required_kvcache_layout
#22734
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
Conversation
Follow-on from vllm-project#22663. Signed-off-by: Nick Hill <[email protected]>
👋 Hi! Thank you for contributing to the vLLM project. 💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels. Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging. To run CI, PR reviewers can either: Add 🚀 |
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 fixes an issue in get_required_kvcache_layout
where it was being called on the base class instead of the specific connector class. The change in base.py
correctly adds a safeguard to prevent this in the future. However, the fix in multi_connector.py
introduces a new issue by not providing the correct vllm_config
to the sub-connectors' get_required_kvcache_layout
method. I've provided a critical comment with a suggested fix for this.
for ktc in ktcs: | ||
kv_transfer_config = KVTransferConfig(**ktc) | ||
temp_vllm_config.kv_transfer_config = kv_transfer_config | ||
connector_cls = KVConnectorFactory.get_connector_class( | ||
KVTransferConfig(**ktc)) | ||
required_kvcache_layout = ( | ||
KVConnectorBase_V1.get_required_kvcache_layout( | ||
temp_vllm_config)) | ||
connector_cls.get_required_kvcache_layout(vllm_config)) | ||
if required_kvcache_layout is not None: | ||
layouts.add(required_kvcache_layout) |
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.
This change correctly calls get_required_kvcache_layout
on the specific connector_cls
. However, it passes the original vllm_config
from the MultiConnector
, not a config tailored for the sub-connector. If a sub-connector's get_required_kvcache_layout
implementation relies on its specific kv_transfer_config
(e.g., from kv_connector_extra_config
), it will receive the wrong configuration.
This is inconsistent with the pattern used in MultiConnector.__init__
, which creates a temporary config for each sub-connector. To ensure correctness and consistency, a temporary vllm_config
should be created for each sub-connector within the loop, similar to the __init__
method.
temp_vllm_config = copy.copy(vllm_config)
for ktc in ktcs:
kv_transfer_config = KVTransferConfig(**ktc)
temp_vllm_config.kv_transfer_config = kv_transfer_config
connector_cls = KVConnectorFactory.get_connector_class(
kv_transfer_config)
required_kvcache_layout = (
connector_cls.get_required_kvcache_layout(temp_vllm_config))
if required_kvcache_layout is not None:
layouts.add(required_kvcache_layout)
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.
Thanks for spotting this Nick!
btw to expand on this PR, this will also fix heteroTP in a multiconnector scenario, among other cases. |
Signed-off-by: Nick Hill <[email protected]>
…ct#22734) Signed-off-by: Nick Hill <[email protected]>
…ct#22734) Signed-off-by: Nick Hill <[email protected]>
…ct#22734) Signed-off-by: Nick Hill <[email protected]> Signed-off-by: Duncan Moss <[email protected]>
…ct#22734) Signed-off-by: Nick Hill <[email protected]>
…ct#22734) Signed-off-by: Nick Hill <[email protected]> Signed-off-by: Xiao Yu <[email protected]>
…ct#22734) Signed-off-by: Nick Hill <[email protected]>
Follow-on from #22663.
cc @NickLucche