Skip to content

Fixes #2556: Assertion when remote backend is enabled without local CPU backend#2557

Merged
hickeyma merged 8 commits intoLMCache:devfrom
hlin99:remote_cpu
Mar 2, 2026
Merged

Fixes #2556: Assertion when remote backend is enabled without local CPU backend#2557
hickeyma merged 8 commits intoLMCache:devfrom
hlin99:remote_cpu

Conversation

@hlin99
Copy link
Copy Markdown
Contributor

@hlin99 hlin99 commented Feb 6, 2026

#2556 includes two underneath issues.

  1. SafeLocalCPUBackend config and metadata are missing, which throw exception when connector is initialized
    refer to code https://github.com/LMCache/LMCache/blob/dev/lmcache/v1/storage_backend/connector/lm_connector.py#L45

  2. Local CPU backend is must have for remote backend, otherwise remote backend won't work properly. so raise an assertion during creating backend is a decent handling way
    refer to code: https://github.com/LMCache/LMCache/blob/dev/lmcache/v1/storage_backend/storage_manager.py#L327

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @hlin99, 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 critical issues related to the setup and operation of storage backends, specifically when a remote backend is enabled without a local CPU backend. It introduces a necessary assertion to enforce the dependency of remote backends on a local CPU buffer, preventing runtime errors. Additionally, it corrects the initialization of the SafeLocalCPUBackend stub, ensuring that configuration and metadata are properly handled, which stabilizes the storage system's startup and operation.

Highlights

  • Remote Backend Dependency Enforcement: An assertion has been added to CreateStorageBackends to ensure that a local CPU backend is always present when a remote backend is configured. This prevents the remote backend from operating improperly without its required local buffer.
  • SafeLocalCPUBackend Initialization Fix: The SafeLocalCPUBackend constructor has been updated to correctly accept and store both config and metadata. This resolves previous exceptions that occurred during connector initialization when these essential attributes were missing.
  • Connector Instantiation Update: The Connector's initialization logic now correctly passes both config and metadata when instantiating SafeLocalCPUBackend as a fallback, ensuring consistent and complete object state.

🧠 New Feature in Public Preview: You can now enable Memory 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.

Changelog
  • lmcache/v1/storage_backend/init.py
    • Introduced an assertion check within the CreateStorageBackends function to verify that local_cpu_backend is not None if config.remote_url is set, providing a clear error message if this dependency is not met.
  • lmcache/v1/storage_backend/connector/init.py
    • Modified the __init__ method of SafeLocalCPUBackend to accept metadata: Optional[LMCacheMetadata] as an argument, storing both config and metadata as instance attributes.
    • Updated the instantiation of SafeLocalCPUBackend within the Connector's __init__ method to pass both config and metadata when the local_cpu_backend is initially None.
Activity
  • No human activity (comments, reviews, etc.) has been recorded for this pull request yet.
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 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 counter productive. 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.

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

  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.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a 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 addresses two issues when using a remote backend. First, it adds an assertion to ensure a local CPU backend is available when a remote backend is configured. Second, it fixes an issue with SafeLocalCPUBackend by initializing config and metadata attributes.

The changes are in the right direction, but I've identified a couple of issues. The new assertion is too strict and would break schedulers, which can validly use a remote backend without a local CPU backend. I've suggested making this assertion conditional on the worker role. Additionally, the initialization of SafeLocalCPUBackend is incomplete and will cause an AttributeError because it's missing the layerwise attribute. I've provided a suggestion to fix this.

Comment thread lmcache/v1/storage_backend/__init__.py
Comment thread lmcache/v1/storage_backend/connector/__init__.py Outdated
Copy link
Copy Markdown
Collaborator

@maobaolong maobaolong left a comment

Choose a reason for hiding this comment

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

@hlin99 LGTM. thanks for this fix.

@hlin99
Copy link
Copy Markdown
Contributor Author

hlin99 commented Feb 18, 2026

Hi @sammshen could u take 5mins to take a look? This is a small safety check. Thx!

Comment thread lmcache/v1/storage_backend/__init__.py Outdated
@hlin99 hlin99 requested a review from sammshen February 23, 2026 16:28
Copy link
Copy Markdown
Contributor

@sammshen sammshen left a comment

Choose a reason for hiding this comment

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

lgtm

The scheduler never reaches this code path, so the
`metadata.role != "scheduler"` condition is unnecessary.

Remove the redundant role check and always assert the
presence of a local CPU backend when remote_url is set.

Signed-off-by: Tony Lin <tony.lin@intel.com>
@hickeyma hickeyma enabled auto-merge (squash) February 24, 2026 13:57
@hlin99
Copy link
Copy Markdown
Contributor Author

hlin99 commented Feb 27, 2026

hi @maobaolong @sammshen @hickeyma just resolved the conflicts and rebased to the latest... could you help manually merge this PR if no more comment? auto-merge seems does not work...... thanks.

@sammshen sammshen added the full Run comprehensive tests on this PR label Mar 2, 2026
@hickeyma hickeyma merged commit 9dc3ab7 into LMCache:dev Mar 2, 2026
24 checks passed
@hlin99 hlin99 deleted the remote_cpu branch March 2, 2026 05:41
hlin99 added a commit to hlin99/LMCache that referenced this pull request Mar 2, 2026
…local CPU backend (LMCache#2557)

Remove redundant role check for remote backend CPU assertion

The scheduler never reaches this code path, so the
`metadata.role != "scheduler"` condition is unnecessary.

Remove the redundant role check and always assert the
presence of a local CPU backend when remote_url is set.

Signed-off-by: Tony Lin <tony.lin@intel.com>
oferki pushed a commit to oferki/LMCache that referenced this pull request Mar 3, 2026
…local CPU backend (LMCache#2557)

Remove redundant role check for remote backend CPU assertion

The scheduler never reaches this code path, so the
`metadata.role != "scheduler"` condition is unnecessary.

Remove the redundant role check and always assert the
presence of a local CPU backend when remote_url is set.

Signed-off-by: Tony Lin <tony.lin@intel.com>
Signed-off-by: Ofer Kiselov Nahman <ofer.kiselovnahman@weka.io>
oferki pushed a commit to oferki/LMCache that referenced this pull request Mar 3, 2026
…local CPU backend (LMCache#2557)

Remove redundant role check for remote backend CPU assertion

The scheduler never reaches this code path, so the
`metadata.role != "scheduler"` condition is unnecessary.

Remove the redundant role check and always assert the
presence of a local CPU backend when remote_url is set.

Signed-off-by: Tony Lin <tony.lin@intel.com>
mauryaavinash95 pushed a commit to mauryaavinash95/LMCache that referenced this pull request Mar 7, 2026
…local CPU backend (LMCache#2557)

Remove redundant role check for remote backend CPU assertion

The scheduler never reaches this code path, so the
`metadata.role != "scheduler"` condition is unnecessary.

Remove the redundant role check and always assert the
presence of a local CPU backend when remote_url is set.

Signed-off-by: Tony Lin <tony.lin@intel.com>
shaoxiawjc pushed a commit to shaoxiawjc/LMCache that referenced this pull request Mar 11, 2026
…local CPU backend (LMCache#2557)

Remove redundant role check for remote backend CPU assertion

The scheduler never reaches this code path, so the
`metadata.role != "scheduler"` condition is unnecessary.

Remove the redundant role check and always assert the
presence of a local CPU backend when remote_url is set.

Signed-off-by: Tony Lin <tony.lin@intel.com>
Signed-off-by: shaoxiawjc <wjc2800@163.com>
realAaronWu pushed a commit to realAaronWu/LMCache that referenced this pull request Mar 20, 2026
…local CPU backend (LMCache#2557)

Remove redundant role check for remote backend CPU assertion

The scheduler never reaches this code path, so the
`metadata.role != "scheduler"` condition is unnecessary.

Remove the redundant role check and always assert the
presence of a local CPU backend when remote_url is set.

Signed-off-by: Tony Lin <tony.lin@intel.com>
Signed-off-by: Aaron Wu <aaron.wu@dell.com>
jooho-XCENA pushed a commit to xcena-dev/LMCache that referenced this pull request Apr 2, 2026
…local CPU backend (LMCache#2557)

Remove redundant role check for remote backend CPU assertion

The scheduler never reaches this code path, so the
`metadata.role != "scheduler"` condition is unnecessary.

Remove the redundant role check and always assert the
presence of a local CPU backend when remote_url is set.

Signed-off-by: Tony Lin <tony.lin@intel.com>
jooho-XCENA pushed a commit to xcena-dev/LMCache that referenced this pull request Apr 2, 2026
…local CPU backend (LMCache#2557)

Remove redundant role check for remote backend CPU assertion

The scheduler never reaches this code path, so the
`metadata.role != "scheduler"` condition is unnecessary.

Remove the redundant role check and always assert the
presence of a local CPU backend when remote_url is set.

Signed-off-by: Tony Lin <tony.lin@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full Run comprehensive tests on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants