Skip to content

[P/D] Support NIXL connector to disconnect during a clean shutdown - #24423

Merged
NickLucche merged 7 commits into
vllm-project:mainfrom
chaunceyjiang:nixl_shutdown
Sep 23, 2025
Merged

[P/D] Support NIXL connector to disconnect during a clean shutdown#24423
NickLucche merged 7 commits into
vllm-project:mainfrom
chaunceyjiang:nixl_shutdown

Conversation

@chaunceyjiang

@chaunceyjiang chaunceyjiang commented Sep 8, 2025

Copy link
Copy Markdown
Collaborator

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 an explicit shutdown method for the NixlConnector to ensure proper resource cleanup, moving away from relying on __del__. The new method handles the shutdown of background threads and releases NIXL resources like dlist handles, remote agents, and registered memory. This is a significant improvement for ensuring a clean shutdown. My main feedback is regarding the shutdown of the _nixl_handshake_listener_t thread, which could be made more graceful.

Comment thread vllm/distributed/kv_transfer/kv_connector/v1/nixl_connector.py
@chaunceyjiang

Copy link
Copy Markdown
Collaborator Author

@njhill PTAL

@njhill

njhill commented Sep 8, 2025

Copy link
Copy Markdown
Member

cc @wseaton @markmc

@wseaton

wseaton commented Sep 8, 2025

Copy link
Copy Markdown
Contributor

Thanks @chaunceyjiang, this seems reasonable (saw it plugs into the shutdown API that you just added in another PR). Have you observed what happens with this change when a prefill node is killed or scaled after handshaking with many decode nodes? Do you see disconnect logs in the decode peers? Any ill effects?

@chaunceyjiang

chaunceyjiang commented Sep 10, 2025

Copy link
Copy Markdown
Collaborator Author

Hi @wseaton
The primary purpose of this PR is to trigger a call to nixl.backendEngines.disconnect().

Based on this PR, I tested two scenarios:

  1. When killing the prefill node, the decode node enters an error callback, such as: UCX error handling callback was invoked with status -25 (Connection reset by remote peer). When the prefill node restarts, it establishes a new connection.
  2. When killing the decode node, the prefill node shows no change.

I also noticed that all nixl test examples explicitly call disconnect(). Therefore, I believe it is reasonable to maintain consistent behavior.

@markmc markmc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not clear which cleanup call is doing more than just releasing memory that would be freed by when objects are finalized anyway ... is it remove_remote_agent() does a disconnect?

I guess it's fine to follow the recommended API usage ... but it looks like we're missing doing release_xfer_handle() on any in-progress _recving_transfers ?

Comment thread vllm/distributed/kv_transfer/kv_connector/v1/nixl_connector.py
Comment thread vllm/distributed/kv_transfer/kv_connector/v1/nixl_connector.py
@markmc

markmc commented Sep 11, 2025

Copy link
Copy Markdown
Member

Hi @wseaton The primary purpose of this PR is to trigger a call to nixl.backendEngines.disconnect().

Would you mind explaining how exactly the changes trigger this call? Thanks in advance

@chaunceyjiang

Copy link
Copy Markdown
Collaborator Author

is it remove_remote_agent() does a disconnect?

@markmc Yes . If I’m not mistaken, it should be like this.
remove_remote_agent() -> invalidateRemoteMD() -> backendEngines[it.first]->disconnect() -> ucx.disconnect()

@NickLucche NickLucche left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for adding this @chaunceyjiang !
I think this is a good practice change, in particular as we expand Nixl to support different backends other than UCX, which may require specific resource cleanup.

While we're at it though, as we're already releasing data structures memory nixl-side, I think we should also release on-going transfers prior to that, as @markmc pointed out.

Comment thread vllm/distributed/kv_transfer/kv_connector/v1/nixl_connector.py
@mergify

mergify Bot commented Sep 19, 2025

Copy link
Copy Markdown
Contributor

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

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

@chaunceyjiang

Copy link
Copy Markdown
Collaborator Author

/cc @NickLucche PTAL.

@markmc

markmc commented Sep 22, 2025

Copy link
Copy Markdown
Member

Thank you for explaining that remove_remote_agent() calling ucx->disconnect() is the main purpose of this PR

I think we should ensure that shutdown() is idempotent, and it's probably good to test this also. I've pushed a commit to do this here: chaunceyjiang/vllm@nixl_shutdown...markmc:vllm:nixl_shutdown

@mergify mergify Bot added the v1 label Sep 23, 2025
@chaunceyjiang chaunceyjiang added the ready ONLY add when PR is ready to merge/full CI is needed label Sep 23, 2025
@mergify

mergify Bot commented Sep 23, 2025

Copy link
Copy Markdown
Contributor

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

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 Sep 23, 2025
chaunceyjiang and others added 3 commits September 23, 2025 06:14
Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
Co-authored-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
Co-authored-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
Comment thread vllm/distributed/kv_transfer/kv_connector/v1/nixl_connector.py Outdated
Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>

@NickLucche NickLucche left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM , thanks for adding tests as well @chaunceyjiang !

@NickLucche
NickLucche merged commit f05a4f0 into vllm-project:main Sep 23, 2025
45 checks passed
ABC12345anouys pushed a commit to ABC12345anouys/vllm that referenced this pull request Sep 25, 2025
…llm-project#24423)

Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
Co-authored-by: Mark McLoughlin <markmc@redhat.com>
charlifu pushed a commit to ROCm/vllm that referenced this pull request Sep 25, 2025
…llm-project#24423)

Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
Co-authored-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: charlifu <charlifu@amd.com>
@chaunceyjiang
chaunceyjiang deleted the nixl_shutdown branch September 26, 2025 05:58
yewentao256 pushed a commit that referenced this pull request Oct 3, 2025
…24423)

Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
Co-authored-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: yewentao256 <zhyanwentao@126.com>
choprahetarth pushed a commit to Tandemn-Labs/vllm that referenced this pull request Oct 11, 2025
…llm-project#24423)

Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
Co-authored-by: Mark McLoughlin <markmc@redhat.com>
ptrdlr14 pushed a commit to ptrdlr14/vllm that referenced this pull request Oct 20, 2025
…llm-project#24423)

Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
Co-authored-by: Mark McLoughlin <markmc@redhat.com>
rtourgeman pushed a commit to rtourgeman/vllm that referenced this pull request Nov 10, 2025
…llm-project#24423)

Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
Co-authored-by: Mark McLoughlin <markmc@redhat.com>
mystous pushed a commit to mystous/vllm_hybrid that referenced this pull request May 10, 2026
…llm-project#24423)

Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
Co-authored-by: Mark McLoughlin <markmc@redhat.com>
my-other-github-account pushed a commit to my-other-github-account/vllm that referenced this pull request May 15, 2026
…llm-project#24423)

Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
Co-authored-by: Mark McLoughlin <markmc@redhat.com>
my-other-github-account pushed a commit to my-other-github-account/vllm that referenced this pull request May 15, 2026
…llm-project#24423)

Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
Co-authored-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: yewentao256 <zhyanwentao@126.com>
my-other-github-account pushed a commit to my-other-github-account/vllm that referenced this pull request May 15, 2026
…llm-project#24423)

Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
Co-authored-by: Mark McLoughlin <markmc@redhat.com>
my-other-github-account pushed a commit to my-other-github-account/vllm that referenced this pull request May 15, 2026
…llm-project#24423)

Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
Co-authored-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: yewentao256 <zhyanwentao@126.com>
0826joyce pushed a commit to 0826joyce/vllm-serving-optimization that referenced this pull request May 19, 2026
…llm-project#24423)

Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
Co-authored-by: Mark McLoughlin <markmc@redhat.com>
plasticchris pushed a commit to plasticchris/vllm that referenced this pull request Jul 20, 2026
…llm-project#24423)

Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
Co-authored-by: Mark McLoughlin <markmc@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kv-connector ready ONLY add when PR is ready to merge/full CI is needed v1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants