Skip to content

[BugFix][v0.24.0][KV Pool] Guard batch_get_key_info before memcache backend init - #13309

Merged
LCAIZJ merged 1 commit into
vllm-project:releases/v0.24.0rcfrom
tyy0829:fix/memcache-batch-get-key-info-v0.24.0rc
Aug 3, 2026
Merged

LCAIZJ merged 1 commit into
vllm-project:releases/v0.24.0rcfrom
tyy0829:fix/memcache-batch-get-key-info-v0.24.0rc

Conversation

@tyy0829

@tyy0829 tyy0829 commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

fix(kv_pool): guard batch_get_key_info before memcache backend init

When the MemcacheBackend store is not yet initialized (lazy_init mode),
batch_get_key_info hit assert self.store is not None and crashed the
scheduler/worker. Return an empty list instead, matching the list[KeyInfo]
return contract; callers treat an empty result as zero cache hits.

Also call ensure_initialized() in batch_alloc so allocation triggers lazy
init, and annotate the return type as list[Any].

(cherry picked from commit 476b7fb)
Signed-off-by: tyy0829 1455207791@qq.com


Cherry-pick of #13307, rebased on releases/v0.24.0rc.

When the MemcacheBackend store is not yet initialized (lazy_init mode),
batch_get_key_info hit `assert self.store is not None` and crashed the
scheduler/worker. Return an empty list instead, matching the list[KeyInfo]
return contract; callers treat an empty result as zero cache hits.

Also call ensure_initialized() in batch_alloc so allocation triggers lazy
init, and annotate the return type as list[Any].

(cherry picked from commit 476b7fb)
Signed-off-by: tyy0829 <1455207791@qq.com>
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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!

This pull request addresses a runtime stability issue where the system would crash if key information was requested before the Memcache backend had completed its lazy initialization. By gracefully returning an empty list and ensuring the backend is initialized during allocation, the PR prevents unexpected failures and maintains consistent behavior for callers.

Highlights

  • Crash Prevention: Added a guard in batch_get_key_info to return an empty list instead of crashing when the MemcacheBackend is not yet initialized in lazy_init mode.
  • Initialization Logic: Ensured that batch_alloc triggers lazy initialization by calling ensure_initialized() before proceeding.
New Features

🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the 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 may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

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

@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 updates the MemcacheBackend to handle lazy initialization safely. It guards batch_get_key_info to return an empty list if called before the store is initialized, and ensures initialization is triggered during batch_alloc. The reviewer pointed out that the PR title and description do not conform to the repository's style guide and provided compliant templates.

return self.store.batch_is_exist(keys)

def batch_get_key_info(self, keys: list[str]):
def batch_get_key_info(self, keys: list[str]) -> list[Any]:

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.

high

The Pull Request title and description do not follow the repository's style guide.

Specifically:

  1. The PR title format should be [Branch][Module][Action] Pull Request Title. The current title has [Action] before [Module] and is missing the branch prefix [releases/v0.24.0rc].
  2. The PR description is missing the required section headers (### What this PR does / why we need it?, ### Does this PR introduce _any_ user-facing change?, and ### How was this patch tested?).

Please update them to match the repository style guide.

Suggested PR Title:

[releases/v0.24.0rc][KV Transfer][BugFix] Guard batch_get_key_info before memcache backend init

Suggested PR Summary:

### What this PR does / why we need it?

When the MemcacheBackend store is not yet initialized (lazy_init mode), `batch_get_key_info` hits `assert self.store is not None` and crashes the scheduler/worker. This PR guards `batch_get_key_info` by returning an empty list when the store is not initialized, matching the `list[KeyInfo]` return contract (callers treat an empty result as zero cache hits).

Additionally, it calls `ensure_initialized()` in `batch_alloc` so that allocation triggers lazy initialization, and annotates the return type of `batch_get_key_info` as `list[Any]`.

Cherry-picked from commit 476b7fb6be099265db821a9339afe30f99e8b941.

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

Tested with existing unit tests and verified that the scheduler/worker no longer crashes during lazy initialization.
References
  1. The Pull Request title and summary must follow the specific formats defined in the Repository Style Guide. (link)

@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

Suggested PR Title:

[Ops][BugFix] Handle lazy initialization in MemcacheBackend

Suggested PR Summary:

### What this PR does / why we need it?

This pull request updates `MemcacheBackend` to safely handle cases where methods are called before the store is fully initialized. Specifically, `batch_get_key_info` now returns an empty list if called before initialization when lazy init is enabled, and `batch_alloc` ensures the store is initialized before proceeding. Type hints were also added to `batch_get_key_info`.

I have no additional feedback to provide.

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

No tests were added in this PR.

@tyy0829 tyy0829 changed the title [BugFix][KV Transfer] Guard batch_get_key_info before memcache backend init [BugFix][v0.24.0][KV Pool] Guard batch_get_key_info before memcache backend init Jul 31, 2026
@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! Thank you for contributing to the vLLM Ascend project. The following points will speed up your PR merge:‌‌

  • A PR should do only one thing, smaller PRs enable faster reviews.
  • Every PR should include unit tests and end-to-end tests ‌to ensure it works and is not broken by other future PRs.
  • Write the commit message by fulfilling the PR description to help reviewer and future developers understand.

If CI fails, you can run linting and testing checks locally according Contributing and Testing.


Tip

💡 Consider Linking a Related Issue or RFC

Your PR title contains the [BugFix] tag, indicating a bug fix or new feature.

Linking a related issue or RFC in the PR description is strongly encouraged — it gives reviewers helpful context and speeds up the review. You can use any of these keywords:

  • Fixes #<issue_number>
  • Closes #<issue_number>
  • Resolves #<issue_number>
  • Refs #<rfc_or_issue_number> (for RFCs)

🙏 Thanks for helping us keep the project well-organized!

@zzzzwwjj zzzzwwjj added the ready label Aug 1, 2026
@LCAIZJ
LCAIZJ merged commit f90f15c into vllm-project:releases/v0.24.0rc Aug 3, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants