Skip to content

Conversation

njhill
Copy link
Member

@njhill njhill commented Aug 12, 2025

Follow-on from #22663.

cc @NickLucche

Copy link

👋 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 fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of those by going to your fastcheck build on Buildkite UI (linked in the PR checks section) and unblock them. If you do not have permission to unblock, ping simon-mo or khluu to add you in our Buildkite org.

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 ready label to the PR or enable auto-merge.

🚀

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 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.

Comment on lines 227 to 233
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)
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

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)

Copy link
Collaborator

@NickLucche NickLucche left a 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!

@NickLucche
Copy link
Collaborator

btw to expand on this PR, this will also fix heteroTP in a multiconnector scenario, among other cases.

@njhill njhill added ready ONLY add when PR is ready to merge/full CI is needed bug Something isn't working labels Aug 12, 2025
@DarkLight1337 DarkLight1337 enabled auto-merge (squash) August 12, 2025 14:49
@DarkLight1337 DarkLight1337 merged commit 0933f9d into vllm-project:main Aug 15, 2025
45 checks passed
@njhill njhill deleted the kv-layout-fix branch August 15, 2025 02:50
yiliu30 pushed a commit to yiliu30/vllm-fork that referenced this pull request Aug 19, 2025
divakar-amd pushed a commit to divakar-amd/vllm_upstream that referenced this pull request Aug 20, 2025
djmmoss pushed a commit to djmmoss/vllm that referenced this pull request Aug 21, 2025
epwalsh pushed a commit to epwalsh/vllm that referenced this pull request Aug 28, 2025
xiao-llm pushed a commit to xiao-llm/vllm that referenced this pull request Aug 28, 2025
zhewenl pushed a commit to zhewenl/vllm that referenced this pull request Aug 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ready ONLY add when PR is ready to merge/full CI is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants