-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
[P/D][Bugfix]: Fix the metadata corruption issue in Nixl when TP > 1. #19341
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
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.
Hello @chaunceyjiang, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
Summary of Changes
Hello team, Gemini here to provide a quick summary of this pull request. Based on the title, this PR aims to fix an AssertionError
that occurs when self.num_blocks
is equal to nixl_agent_meta.num_blocks
. The core change involves modifying an assertion in the vllm/distributed/kv_transfer/kv_connector/v1/nixl_connector.py
file to use a strict greater-than comparison (>
) instead of greater-than-or-equal-to (>=
). This suggests that the logic requires the local number of blocks to be strictly larger than the remote agent's number of blocks for the assertion to pass correctly in all intended scenarios.
Highlights
- Bugfix: Addresses an
AssertionError
related to block count comparison in the KV transfer connector. - Assertion Logic Update: Modifies an assertion in
nixl_connector.py
from>=
to>
to correctly handle cases where block counts might be equal.
Changelog
- vllm/distributed/kv_transfer/kv_connector/v1/nixl_connector.py
- Fixed an
AssertionError
on line 706 by changing the comparison operator from>=
to>
in the assertionassert self.num_blocks >= nixl_agent_meta.num_blocks
.
- Fixed an
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
👋 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 aims to fix an AssertionError
related to self.num_blocks
and nixl_agent_meta.num_blocks
. However, the current change appears to make the assertion stricter in a way that would not fix the AssertionError
if it was occurring on the specified line as implied by the PR title.
A more detailed explanation of the original bug and the rationale for this specific change would be very helpful. Currently, the PR description is empty, which makes it difficult to fully understand the context and intent of this bugfix.
Summary of Findings
- Effectiveness of the Fix: The primary concern is that the proposed change to the assertion (
self.num_blocks > nixl_agent_meta.num_blocks
) does not appear to fix theAssertionError
if it was caused byself.num_blocks < nixl_agent_meta.num_blocks
(as implied by the failure of the originalassert self.num_blocks >= nixl_agent_meta.num_blocks
). The new assertion is stricter and would also fail under the same condition. - Clarity of Intent: The pull request lacks a description, making it difficult to understand the exact nature of the bug being fixed and the rationale behind making the assertion stricter. Clarification is needed to ensure the change is appropriate and correctly addresses the underlying issue.
Merge Readiness
This pull request should not be merged in its current state. The core change seems to not address the AssertionError
as described in the PR title. Further clarification and potentially a different approach are needed to resolve the underlying issue. I am unable to approve this pull request; it requires further review and changes by the author.
270b08c
to
74bb4fe
Compare
@@ -664,7 +664,13 @@ def add_remote_agent(self, | |||
# TODO re-evaluate refreshing for scaling/recovery | |||
if remote_tp_rank in self._remote_agents.get(engine_id, ()): | |||
return | |||
|
|||
if remote_tp_rank != self.tp_rank: |
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.
The root cause lies here:
vllm/vllm/distributed/kv_transfer/kv_connector/v1/nixl_connector.py
Lines 470 to 473 in 9ef9173
# Handshake with remote agent-rank0 first to get the tp_size of remote | |
path = make_zmq_path("tcp", host, port) | |
logger.debug("Querying master rank metadata on path: %s", path) | |
metadata = handshake(path, 0) |
when the process with rank 7 is retrieving the metadata, it incorrectly records the num_blocks
.
vllm/vllm/distributed/kv_transfer/kv_connector/v1/nixl_connector.py
Lines 708 to 712 in 9ef9173
# Create dst descs and xfer side handles. TP workers have same #blocks. | |
if engine_id in self.dst_num_blocks: | |
assert self.dst_num_blocks[engine_id] == nixl_agent_meta.num_blocks | |
else: | |
self.dst_num_blocks[engine_id] = nixl_agent_meta.num_blocks |
Specifically, rank 7 of D records the
num_blocks
from rank 0 of P.
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 won't work when local TP > remote TP
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.
indeed
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 won't work when local TP > remote TP
@NickLucche I have updated the calculation method. Please take a look again.
/cc @NickLucche @njhill PTAL. |
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 reporting the issue! I think there's two overlapping matters here, let me clarify.
While you're correct the num_blocks being recorded is that of rank 0, the main point though is that the assumption here is that all tp ranks in a vllm instance have the same number of blocks, hence the assert self.dst_num_blocks[engine_id] == nixl_agent_meta.num_blocks
.
When this assumption does not hold, the actual fix here is to record the minimum num_blocks in the tp group (similar to https://github.com/vllm-project/vllm/blob/87360308/vllm/v1/core/kv_cache_utils.py#L771), which can also be achieved by just sending the value recorded in the config.
Alternatively, one could extend self.dst_num_blocks
to a map [str, dict[int,int] ], where the value is the number of blocks per tp rank, but I feel like that would be overkill.
The second issue you reported assert self.num_blocks >= nixl_agent_meta.num_blocks
is a separate condition I was already discussing with @ptarasiewiczNV . The rationale is that the consumer should have enough space to fit all the blocks from the producer. We can easily relax that one with some other lower bound as long as the kv cache is not being transferred in its entirity with nixl.
@@ -664,7 +664,13 @@ def add_remote_agent(self, | |||
# TODO re-evaluate refreshing for scaling/recovery | |||
if remote_tp_rank in self._remote_agents.get(engine_id, ()): | |||
return | |||
|
|||
if remote_tp_rank != self.tp_rank: |
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 won't work when local TP > remote TP
In fact, they are not the same. I've provided some logs here.
|
106dc95
to
395b9cb
Compare
…a.num_blocks Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
395b9cb
to
12d9f6c
Compare
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.
As I commented earlier, I'd fix the num_blocks issue rather than skipping the checks.
Can you either send the num_blocks off of kv_cache config here https://github.com/vllm-project/vllm/blob/main/vllm/distributed/kv_transfer/kv_connector/v1/nixl_connector.py#L62 (which is already the min in the group) or simply store the min during add_remote_agent
?
|
||
if remote_tp_rank != self.tp_rank // tp_ratio: |
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.
rather than an early exit here, which is equivalent to skipping descs at L727, I'd prefer fixing the num_blocks issue for once and still execute the other asserts (those are extra correctness checks that won't hurt to have).
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.
Got it, I'll look into the solution you proposed.
Just to add/clarify:
Here, it only skips the first handshake
execution. During the second handshake
execution, it will not be skipped.
vllm/vllm/distributed/kv_transfer/kv_connector/v1/nixl_connector.py
Lines 470 to 473 in 9ef9173
# Handshake with remote agent-rank0 first to get the tp_size of remote | |
path = make_zmq_path("tcp", host, port) | |
logger.debug("Querying master rank metadata on path: %s", path) | |
metadata = handshake(path, 0) |
The first handshake
execution is solely for obtaining the remote tp_size
, so it can be safely skipped.
vllm/vllm/distributed/kv_transfer/kv_connector/v1/nixl_connector.py
Lines 480 to 483 in 9ef9173
path = make_zmq_path("tcp", host, port + p_remote_rank) | |
logger.debug("Querying metadata on path: %s at remote rank %s", | |
path, p_remote_rank) | |
_ = handshake(path, p_remote_rank) |
The second handshake execution, however, will not be skipped—all checks will be performed as expected
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.
yeah absolutely, this was also the original intent: handshake with rank0 is to get tp_size.
But skipping a bunch of extra asserts on top won't get us to solving the core issue.
@NickLucche I am hitting the same issue as well, I also think that this assertion is too restricted. The number of blocks allocated depends on the GPU usage at the time and can easily fail this assertion on the same TP configs.. In my case it is off by 8 blocks over 5800
|
FIX #19338
Introduced By #18833