Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:LMCache LMCache LMCacheControllerManager Init

From Leeroopedia


Knowledge Sources
Domains Distributed_Systems, Cluster_Management
Last Updated 2026-02-09 00:00 GMT

Overview

Concrete tool for initializing the centralized cache controller that coordinates P2P KV cache sharing across vLLM instances, provided by the lmcache library.

Description

The LMCacheControllerManager.__init__ sets up ZMQ sockets (PULL for worker heartbeats, REP for worker requests), creates a RegistrationController, KVController, and LMCacheClusterExecutor. The main() CLI entry point in __main__.py parses arguments, loads controller config, creates the FastAPI app via create_app(), and runs it with uvicorn.

Usage

Launch via the lmcache_controller CLI command or directly via python -m lmcache.v1.api_server.

Code Reference

Source Location

  • Repository: LMCache
  • File: lmcache/v1/cache_controller/controller_manager.py (init), lmcache/v1/api_server/__main__.py (CLI)
  • Lines: controller_manager.py:L66-L160, __main__.py:L85-L537

Signature

class LMCacheControllerManager:
    def __init__(
        self,
        controller_urls: dict[str, str],
        health_check_interval: int,
        lmcache_worker_timeout: int,
        full_sync_completion_threshold: float = 0.8,
        full_sync_timeout_s: float = 300.0,
    ):
        """
        Args:
            controller_urls: Dict with "pull", "reply", "heartbeat" ZMQ URLs
            health_check_interval: Seconds between worker health checks
            lmcache_worker_timeout: Seconds before a worker is considered dead
            full_sync_completion_threshold: Fraction of workers needed for full sync
            full_sync_timeout_s: Timeout for full sync operations
        """

Import

# Via CLI
lmcache_controller --host 0.0.0.0 --port 9000 --monitor-ports '{"pull": 8300, "reply": 8400}'

# Via Python
from lmcache.v1.cache_controller.controller_manager import LMCacheControllerManager

I/O Contract

Inputs

Name Type Required Description
controller_urls dict[str, str] Yes ZMQ endpoint URLs for pull, reply, heartbeat
health_check_interval int Yes Health check interval in seconds
lmcache_worker_timeout int Yes Worker timeout in seconds

Outputs

Name Type Description
self LMCacheControllerManager Initialized controller with KVController, RegistrationController, ClusterExecutor

Usage Examples

CLI Launch

lmcache_controller \
    --host 0.0.0.0 \
    --port 9000 \
    --monitor-ports '{"pull": 8300, "reply": 8400, "heartbeat": 8500}' \
    --health-check-interval 30 \
    --lmcache-worker-timeout 300

Related Pages

Implements Principle

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment