Implementation:LMCache LMCache LMCacheEngineConfig P2P Fields
| Knowledge Sources | |
|---|---|
| Domains | Configuration, Distributed_Systems |
| Last Updated | 2026-02-09 00:00 GMT |
Overview
Concrete tool for configuring P2P KV cache sharing parameters provided by the LMCacheEngineConfig class.
Description
The LMCacheEngineConfig includes P2P-specific fields defined in _CONFIG_DEFINITIONS (lines 124-185): enable_p2p, p2p_host, p2p_init_ports, p2p_lookup_ports, enable_controller, lmcache_instance_id, controller_pull_url, controller_reply_url, lmcache_worker_ports, lmcache_worker_ids, and transfer_channel. Validation at lines 509-517 ensures all required fields are set when enable_p2p=True.
Usage
Create YAML config files per instance with unique ports and instance IDs.
Code Reference
Source Location
- Repository: LMCache
- File: lmcache/v1/config.py
- Lines: L124-L185 (P2P fields), L509-L517 (validation)
Signature
# P2P-specific fields in _CONFIG_DEFINITIONS:
"enable_p2p": {"type": bool, "default": False}
"p2p_host": {"type": Optional[str], "default": None}
"p2p_init_ports": {"type": Optional[list[int]], "default": None}
"p2p_lookup_ports": {"type": Optional[list[int]], "default": None}
"enable_controller": {"type": bool, "default": False}
"lmcache_instance_id": {"type": Optional[str], "default": None}
"controller_pull_url": {"type": Optional[str], "default": None}
"controller_reply_url": {"type": Optional[str], "default": None}
"lmcache_worker_ports": {"type": Optional[list[int]], "default": None}
"transfer_channel": {"type": Optional[str], "default": None}
Import
from lmcache.v1.config import load_engine_config_with_overrides
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| enable_p2p | bool | Yes | Enable P2P sharing mode |
| p2p_host | str | Yes | NIXL bind host for this instance |
| p2p_init_ports | list[int] | Yes | NIXL init ports (one per TP rank) |
| p2p_lookup_ports | list[int] | Yes | NIXL lookup ports (one per TP rank) |
| enable_controller | bool | Yes | Enable controller registration |
| lmcache_instance_id | str | Yes | Unique instance identifier |
| controller_pull_url | str | Yes | Controller ZMQ PULL address |
| controller_reply_url | str | Yes | Controller ZMQ REP address |
| lmcache_worker_ports | list[int] | Yes | Worker ZMQ ports |
| transfer_channel | str | Yes | Transfer channel type ("nixl") |
Outputs
| Name | Type | Description |
|---|---|---|
| config | LMCacheEngineConfig | Validated P2P configuration instance |
Usage Examples
Instance 1 YAML Config
# example1.yaml
chunk_size: 256
local_cpu: True
max_local_cpu_size: 5
enable_p2p: True
p2p_host: "localhost"
p2p_init_ports: [8200]
p2p_lookup_ports: [8201]
transfer_channel: "nixl"
enable_controller: True
lmcache_instance_id: "lmcache_instance_1"
controller_pull_url: "localhost:8300"
controller_reply_url: "localhost:8400"
lmcache_worker_ports: [8500]