Skip to content

Conversation

@KingsleyZhang123
Copy link
Contributor

@KingsleyZhang123 KingsleyZhang123 commented May 12, 2025

KVConnectorBase_V1 API is introduced in (#15960), however, due to the multi-process nature, it's hard to register a customized kv connector implementations from outside context.

This change will make the kv connector registration more flexible as it allows for external dependency injection.
Example Usage:

kv_connector_registry_args={
  "name": "CustomConnector",
  "module_path": "external.module.path",
  "class_name": "CustomConnector",
},

This will allow external developers to register customized kv connectors without keep adding a boilerplate & updating the factory.py.

The third commit moves the kv connector init after model loading, allowing vllm_config to be populated with all attention layers info.

@github-actions
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.

🚀

@liuzijing2014
Copy link
Collaborator

cc @njhill for review

connector_name = config.kv_transfer_config.kv_connector
if (config.kv_transfer_config.kv_connector_external_registration_args
is not None and connector_name not in cls._registry):
cls.register_connector(**config.kv_transfer_config.

Choose a reason for hiding this comment

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

could this be called multiple times

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, based on current v1 design each process will only call it once

Copy link
Contributor Author

@KingsleyZhang123 KingsleyZhang123 May 13, 2025

Choose a reason for hiding this comment

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

Double checked, when running world_size = 1, UniProcExecutor will be used, scheduler & worker will run on the same process and this will be called twice.

vllm/vllm/config.py

Lines 1828 to 1829 in d67085c

if self.distributed_executor_backend is None and self.world_size == 1:
self.distributed_executor_backend = "uni"

@maobaolong
Copy link
Contributor

Interesting feature, it will help private kv connector implementation works without change or hack vllm, this feature is very useful.

@sdavidbd
Copy link
Contributor

@liuzijing2014 thanks for the PR—this is definitely a step in the right direction (from the GenericKVConnector #17840) toward supporting external connector integration. I'd like to offer an alternative approach that I believe simplifies things further: #18142.

Rather than dynamically registering the external KV connector through an opaque config field (encapsulating multiple fields: connector name, module path, class name), the factory can directly load the external implementation using a single, semantically clear config field: the external module path. This eliminates the need for explicit registration or wrapper classes.

More importantly, with this approach:

  • No connector registration is needed in V1
  • No vendor-specific connector implementation needs to be upstreamed to vLLM
  • Integration is declarative and self-contained, keeping the vLLM codebase clean
  • Vendors can ship their own connector logic independently, and users can consume it by setting config only

This minimizes boilerplate and improves usability while preserving full flexibility. The supported external connectors can simply be documented or included in examples, rather than embedded in the core repo.

I’d be glad to hear your thoughts.

@mergify
Copy link

mergify bot commented May 17, 2025

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @KingsleyZhang123.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify bot added the needs-rebase label May 17, 2025
@github-actions
Copy link

This pull request has been automatically marked as stale because it has not had any activity within 90 days. It will be automatically closed if no further activity occurs within 30 days. Leave a comment if you feel this pull request should remain open. Thank you!

@github-actions github-actions bot added the stale Over 90 days of inactivity label Aug 16, 2025
@github-actions
Copy link

This pull request has been automatically closed due to inactivity. Please feel free to reopen if you intend to continue working on it. Thank you!

@github-actions github-actions bot closed this Sep 16, 2025
@KingsleyZhang123 KingsleyZhang123 deleted the external_kv_connector branch November 5, 2025 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-rebase stale Over 90 days of inactivity v1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants