Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This project provides an external logging backend implementation for LMCache.

## Features
- Implements the `StorageBackendInterface` from LMCache
- Implements the `StoragePluginInterface` from LMCache
- Logs all backend operations (put, get, prefetch, pin, etc.)
- Easy to integrate with existing LMCache systems

Expand All @@ -22,10 +22,10 @@ Add the following to your LMCache Configuration:
chunk_size: 64
local_cpu: False
max_local_cpu_size: 5
external_backends: "log_external_backend"
storage_plugins: "log_external_backend"
extra_config:
external_backend.log_external_backend.module_path: lmc_external_log_backend.lmc_external_log_backend
external_backend.log_external_backend.class_name: ExternalLogBackend
storage_plugin.log_external_backend.module_path: lmc_external_log_backend.lmc_external_log_backend
storage_plugin.log_external_backend.class_name: ExternalLogBackend

```

Expand Down
28 changes: 13 additions & 15 deletions lmc_external_log_backend/lmc_external_log_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,30 @@
from typing import List, Optional
from concurrent.futures import Future

# Third Party
import torch

# First Party
from lmcache.logging import init_logger
from lmcache.v1.storage_backend.abstract_backend import StorageBackendInterface
from lmcache.v1.storage_backend.local_cpu_backend import LocalCPUBackend
from lmcache.v1.storage_backend.abstract_backend import StoragePluginInterface
from lmcache.utils import CacheEngineKey
from lmcache.v1.memory_management import MemoryObj

logger = init_logger(__name__)


class ExternalLogBackend(StorageBackendInterface):
class ExternalLogBackend(StoragePluginInterface):
def __init__(
self,
config,
metadata,
loop,
memory_allocator,
local_cpu_backend: LocalCPUBackend,
local_cpu_backend,
dst_device,
lookup_server=None,
):
super().__init__(dst_device=dst_device)
self.config = config
self.metadata = metadata
self.loop = loop
self.memory_allocator = memory_allocator
self.lookup_server = lookup_server
super().__init__(dst_device=dst_device,
config=config,
metadata = metadata,
local_cpu_backend = local_cpu_backend,
loop = loop,
)
logger.info(f"ExternalLogBackend initialized for device {dst_device}")

def contains(self, key: CacheEngineKey, pin: bool = False) -> bool:
Expand Down Expand Up @@ -78,3 +72,7 @@ def remove(self, key: CacheEngineKey, force: bool = True) -> bool:

def close(self) -> None:
logger.info("ExternalLogBackend Closing ExternalLogBackend")

def get_allocator_backend(self):
logger.info(f"ExternalLogBackend get allocator backend: {self.local_cpu_backend}")
return self.local_cpu_backend