Repository navigation
[Bugfix][KV Offload] Roll back failed P2P NIXL registration #63628
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
Merged
orozery
merged 3 commits into
vllm-project:main
from
Levius-Fubuki:submit/p2p-nixl-registration-rollback
Oct 26, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -228,11 +228,9 @@ def add_remote_peer( | |
| num_blocks: int, | ||
| block_len: int, | ||
| ) -> None: | ||
| gen = self._begin_registration(peer_id) | ||
| nixl_name, remote_dlist = self._build_peer_handles( | ||
| agent_metadata, base_addr, num_blocks, block_len | ||
| ) | ||
| self._publish_peer(peer_id, gen, nixl_name, remote_dlist) | ||
| self.add_remote_peer_async( | ||
| peer_id, agent_metadata, base_addr, num_blocks, block_len | ||
| ).result() | ||
|
|
||
| def add_remote_peer_async( | ||
| self, | ||
|
|
@@ -246,7 +244,7 @@ def add_remote_peer_async( | |
|
|
||
| def register() -> None: | ||
| nixl_name, remote_dlist = self._build_peer_handles( | ||
| agent_metadata, base_addr, num_blocks, block_len | ||
| peer_id, agent_metadata, base_addr, num_blocks, block_len | ||
| ) | ||
| if not self._publish_peer(peer_id, gen, nixl_name, remote_dlist): | ||
| raise RuntimeError( | ||
|
|
@@ -277,23 +275,33 @@ def _begin_registration(self, peer_id: str) -> int: | |
|
|
||
| def _build_peer_handles( | ||
| self, | ||
| peer_id: str, | ||
| agent_metadata: bytes, | ||
| base_addr: int, | ||
| num_blocks: int, | ||
| block_len: int, | ||
| ) -> tuple[str, Any]: | ||
| """The expensive half: agent wireup plus one descriptor per block. | ||
|
|
||
| Touches no shared state, so it runs unlocked — holding the peer | ||
| lock across it would stall the scheduler thread for exactly as | ||
| long as the registration it is meant to move off that thread. | ||
| Holding the peer lock across native registration would stall the | ||
| scheduler thread for exactly as long as the registration it is | ||
| meant to move off that thread. | ||
| """ | ||
| nixl_name = self._agent.add_remote_agent(agent_metadata) | ||
| block_descs = [ | ||
| (base_addr + i * block_len, block_len, 0) for i in range(num_blocks) | ||
| ] | ||
| xfer_dlist = self._agent.get_xfer_descs(block_descs, mem_type="DRAM") | ||
| remote_dlist = self._agent.prep_xfer_dlist(nixl_name, xfer_dlist) | ||
| try: | ||
| block_descs = [ | ||
| (base_addr + i * block_len, block_len, 0) for i in range(num_blocks) | ||
| ] | ||
| xfer_dlist = self._agent.get_xfer_descs(block_descs, mem_type="DRAM") | ||
| remote_dlist = self._agent.prep_xfer_dlist(nixl_name, xfer_dlist) | ||
| except Exception: | ||
| # All builds run on the single-worker _reg_executor, so another | ||
| # registration cannot acquire this name between check and release. | ||
| with self._peer_lock: | ||
| published = nixl_name in self._peer_nixl_names.values() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: could you add a short comment here noting that this check relies on builds being serialized on |
||
| if not published: | ||
| self._release_remote_handles(peer_id, None, nixl_name) | ||
| raise | ||
| return nixl_name, remote_dlist | ||
|
|
||
| def _publish_peer( | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Agree with nilig's race. I think it's worth fixing here. The rollback's ownership check is only sound because builds run one at a time on
_reg_executor. This sync path builds on the caller's thread, so it can overlap an async build. An older failed registration can then remove an agent that this call is about to publish. Routing it through the executor removes the gap:Nothing calls this from the registration worker, so it can't deadlock. One behaviour change: a superseded sync registration now raises instead of returning silently. Today it ignores
_publish_peer'sFalse, which already looks like a bug to me.Could you add a regression test as well? An older registration fails while a newer one for the same peer has added the agent but not yet published it, and the newer one should stay registered and usable for
write_blocks.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.
@liranschour Fixed the sync race, added regression coverage and the serialization comment in 6ed41cc. Full P2P suite: 321 passed; pre-commit passed. Could you please re-review?