配置参考#
本页面记录了 LMCache 多进程服务器接受的每个 CLI 参数。参数按定义它们的配置模块进行分组。
Per-request LMCache configuration#
vLLM clients can attach request-scoped LMCache metadata through the top-level
kv_transfer_params field. When vLLM uses LMCacheMPConnector, entries
whose keys start with lmcache. are forwarded with the request across the
MP scheduler and worker IPC paths. Other kv_transfer_params entries are
reserved for the transfer layer and are not forwarded to LMCache.
For example:
curl -X POST http://localhost:8000/v1/completions \
-H "Content-Type: application/json" \
-d '{
"model": "Qwen/Qwen3-14B",
"prompt": "Explain KV cache reuse.",
"max_tokens": 32,
"kv_transfer_params": {
"lmcache.tag.tenant": "example-tenant",
"lmcache.ttl": 60
}
}'
The connector carries these values on lookup, prefetch, store, retrieve, and lookup-lock cleanup operations so server-side features can inspect the same request metadata throughout the request lifecycle.
重要
Forwarding a value does not by itself make the MP server act on it or make
it part of cache identity. The current MP server treats request configs as
metadata. Do not rely on lmcache.tag.*, lmcache.ttl,
lmcache.skip_save, or another request config for isolation, expiration,
or cache-control behavior in MP mode unless the selected server-side
feature explicitly documents support for it. The in-process
LMCacheConnectorV1 may interpret these values differently.
MP 服务器#
源: lmcache/v1/multiprocess/config.py
参数 |
默认 |
描述 |
|---|---|---|
|
(未设置,默认 UUID v4) |
此 MP 服务器的稳定标识。用作协调器成员身份键,并投影到每条指标和每个 Span 的 OTel |
|
|
绑定 ZMQ 服务器的主机地址。 |
|
|
绑定 ZMQ 服务器的端口。 |
|
|
KV Cache 操作的块大小(以 token 为单位)。 |
|
|
工作线程的基本数量。为 GPU(亲和性)池和 CPU(正常)池设置默认值。可以通过 |
|
(继承 |
GPU 亲和性池(STORE/RETRIEVE)的工作线程。来自同一 vLLM 实例的请求始终分发到同一线程,从而消除 GPU 传输锁竞争。 |
|
(继承 |
普通 CPU 池(LOOKUP 等)的工作线程。 |
|
|
基于 token 的操作所使用的哈希算法。可选项: |
|
|
Cache engine backend type. |
|
|
Which worker → server transfer paths the server loads.
|
|
|
Assume engine workers and this server run in containers that share
no host IPC namespace ( |
|
|
零个或多个路径,用于运行时插件脚本或目录,以便与服务器一起启动。插件由 |
|
|
通过 |
|
|
允许在 HTTP |
|
|
SHM segment name for non-GPU KV transfer (only used when the
non-GPU path is loaded, i.e. |
|
|
工作线程发送至少一个心跳 PING 后进入静默状态的最长容忍时间(秒),超时后将回收其 KV Cache 注册,并释放泄漏的 GPU 上下文和 CUDA IPC 句柄。 |
|
|
针对已注册但从未发送 PING 的工作线程(仍在预热或在首次请求前已崩溃)的静默容忍时间(秒)。必须大于或等于 |
|
|
CacheBlend ( |
|
|
|
|
|
Split a hybrid model's kernel groups into one object group per
cross-chunk attention window (full attention, each sliding-window
size, mamba/GDN) at KV-cache registration. Off by default; pass
|
查找哈希日志记录#
源: lmcache/v1/mp_observability/subscribers/logging/lookup_hash.py
启用时,服务器将在 EventBus 上以 MP_LOOKUP 事件的形式发布 lookup() 期间计算的块哈希。LookupHashLoggingSubscriber 会将这些事件写入滚动 JSONL 文件以供离线分析。默认禁用。这些参数属于可观察性配置组。
参数 |
默认 |
描述 |
|---|---|---|
|
|
写入查找哈希 JSONL 文件的目录。空字符串将禁用日志记录。 |
|
|
滚动到新日志文件前的时间间隔(秒)。 |
|
|
即使时间间隔未到,触发滚动的最大文件大小(字节)。 |
|
|
保留的最大日志文件数量。当超过此限制时,最旧的文件将被删除。 |
HTTP 前端#
源: lmcache/v1/multiprocess/config.py
HTTP 前端在运行 lmcache server 时包含在内。
参数 |
默认 |
描述 |
|---|---|---|
|
|
绑定 HTTP (FastAPI/uvicorn) 服务器的主机。 |
|
|
绑定 HTTP 服务器的端口。 |
P2P#
源: lmcache/v1/multiprocess/config.py
这些标志配置 MP 服务器之间的点对点 KV Cache 共享(请参见 P2P KV 缓存共享)。它们通过 add_p2p_args() 在 lmcache server 解析器中注册。当设置了 --p2p-advertise-url 时,P2P 被启用,这还需要通过 --coordinator-url``(或 ``LMCACHE_COORDINATOR_URL)提供协调器 URL。
参数 |
默认 |
描述 |
|---|---|---|
|
|
传输通道服务器 |
|
|
传输通道服务器 |
|
|
在查找结果被视为未命中之前的秒数。 |
|
|
在对等加载被视为失败之前的秒数。 |
|
|
使用的传输通道实现。 |
L1 内存管理器#
来源: lmcache/v1/distributed/config.py
参数 |
默认 |
描述 |
|---|---|---|
|
必需 |
L1 层的大小(以 GB 为单位)。默认情况下,设置固定 DRAM 的 L1 大小,或者在设置了 |
|
|
启用或禁用 L1 内存的延迟分配。传递 |
|
|
使用延迟分配时的初始分配大小(GB)。 |
|
|
对齐大小(以字节为单位,默认 4 KB)。 |
|
(未设置) |
Optional |
GDS L1 层#
来源: lmcache/v1/distributed/config.py
选择加入。设置 --gds-l1-path 将 L1 媒介从固定 DRAM 切换到通过 GPUDirect Storage DMA 访问的 NVMe 块文件。然后禁用 CPU 固定 DRAM 层,并且 --l1-size-gb 设置块的大小。当此选项开启时,禁用字节数组 L2 适配器(GDS 层不提供 L1 内存缓冲区供它们注册)。
DMA 路径由平台自动选择:NVIDIA 上使用 cuFile (libcufile.so),而 AMD ROCm 上使用 hipFile (libhipfile.so,ROCm/hipFile)。这两个平台适用相同的标志;切换供应商无需更改配置。
uGDS (libugds.so) is a third, opt-in backend selected with
--gds-l1-backend ugds. It is a user-space GPUDirect Storage library that
builds NVMe commands and rings doorbells from user space, so its IO path issues
no syscall. LMCache can use uGDS on either NVIDIA CUDA or AMD ROCm. Each
deployment must use a libugds.so built for its active platform. Unlike
cuFile and hipFile, uGDS does not use a filesystem: the slab is mapped directly
onto a raw character device, and --gds-l1-path must name that device (for
example /dev/ugds_drv0) rather than a directory. The first
--l1-size-gb bytes of the device are the slab, so the device must be at
least that large and must not hold anything else.
Phoenix (libphoenix.so) is a fourth opt-in backend selected with
--gds-l1-backend phx. Phoenix (phxfs) provides a kernel-mediated
user-space NVMe-to-GPU DMA path with a very low software-stack overhead.
Like cuFile and hipFile it uses a filesystem slab: --gds-l1-path names
an NVMe directory, --gds-l1-use-direct-io applies, and the slab file
can share the disk with other data. Each GPU staging buffer is registered with
phxfs (phxfs_regmem, 64 KiB-aligned) and the slab is read and written
with stream-ordered submissions (phxfs_read_stream /
phxfs_write_stream) that keep the DMA ordered with the other work on
the stream. A libphoenix build without the stream-ordered API fails
to load. Follow the
Phoenix installation guide
to build libphoenix.so, load the phoenixfs kernel module, and
verify the installation.
备注
AMD hipFile 需要 ROCm >= 7.2.0。零拷贝 GPUDirect 快速路径还需要一个使用 CONFIG_PCI_P2PDMA 构建的内核、amdgpu-dkms >= 30.20.1,以及在本地 NVMe ext4/xfs 文件系统上的 slab;如果这些不可用,hipFile 会透明地回退到主机跳跃兼容路径(正确,但不是零拷贝)。
备注
uGDS requires its kernel module loaded and the NVMe device bound to it, and
a platform-matching libugds.so reachable through the loader
(LD_LIBRARY_PATH or ldconfig). Because the device is claimed by
ugds_drv rather than the kernel NVMe driver, it carries no filesystem
and cannot be shared with any other consumer while in use. Follow the
uGDS installation guide
to build and load the kernel module, bind the NVMe device, build
libugds.so, and verify the installation.
At startup LMCache queries the namespace capacity through
uGDSGetDeviceCapacity and rejects an aligned --l1-size-gb value larger
than the device. The installed libugds.so must provide this API; LMCache
fails closed with an upgrade message when an older library cannot report
capacity.
警告
uGDS requires an entire dedicated SSD whose contents may be destroyed. Ensure the SSD is not used for any other purpose and that its contents are not critical.
备注
Phoenix requires the phoenixfs kernel module loaded and a
platform-matching libphoenix.so reachable through the loader
(ldconfig or LD_LIBRARY_PATH). It has been validated on NVIDIA
GPUs; other platforms require a matching libphoenix build and are not
yet tested.
参数 |
默认 |
描述 |
|---|---|---|
|
未设置 |
NVMe directory for the GDS L1 slab, or the raw device path when
|
|
|
GDS implementation: |
|
|
Open the slab with |
L1 管理器 TTLs#
来源: lmcache/v1/distributed/config.py
参数 |
默认 |
描述 |
|---|---|---|
|
|
每个对象的写锁的生存时间(秒)。 |
|
|
每个对象的读取锁的生存时间(秒)。 |
逐出策略#
来源: lmcache/v1/distributed/config.py
参数 |
默认 |
描述 |
|---|---|---|
|
必需 |
逐出策略。可选项: |
|
|
触发逐出的内存使用比例 (0.0--1.0)。 |
|
|
触发时逐出的已分配内存比例 (0.0--1.0)。 |
L2 策略#
来源: lmcache/v1/distributed/config.py
参数 |
默认 |
描述 |
|---|---|---|
|
|
L2 存储策略。决定每个键被写入哪些适配器,以及 L2 存储完成后是否从 L1 删除该键。 |
|
|
L2 预取策略。当多个适配器均持有某个键时,决定由哪个适配器加载该键。 |
|
|
最大并发预取(L2 加载)请求数量。限制 PrefetchController 同时发起的在途加载数,防止 L1 内存压力过大。 |
|
|
定期事件通知器心跳的间隔(毫秒)。一个原生 C++ 后台线程按此间隔向所有已注册的文件描述符写入数据,以唤醒缺少原生异步完成回调的 L2 适配器的控制器轮询循环。 |
L2 适配器#
源: lmcache/v1/distributed/l2_adapters/config.py
L2 适配器通过可重复的 --l2-adapter <JSON> 参数进行配置。每个 JSON 对象必须包含一个 "type" 字段,用于选择适配器类型。--l2-adapter 参数的顺序决定了适配器的顺序(级联)。
Registered adapter types: nixl_store, nixl_store_dynamic, fs,
fs_native, mock, mooncake_store, aerospike, bigtable,
sagemaker-hyperpod, s3, hfbucket, resp, valkey,
plugin, native_plugin, raw_block, dax, fault_inject.
(A p2p type is also registered, but it is wired in dynamically by the
P2P subsystem rather than configured via --l2-adapter.)
Each adapter type's required and optional fields, plus per-backend examples, are
documented on its own page under Secondary KV Storage
-- including the adapters not detailed inline here (fs_native,
raw_block, dax, mooncake_store, aerospike, bigtable,
sagemaker-hyperpod, hfbucket, resp, valkey).
多个适配器(级联)#
多次传递 --l2-adapter。适配器按给定顺序使用:
--l2-adapter '{"type": "nixl_store", "backend": "POSIX", "backend_params": {"file_path": "/data/ssd/l2", "use_direct_io": "false"}, "pool_size": 64}' \
--l2-adapter '{"type": "nixl_store", "backend": "GDS", "backend_params": {"file_path": "/data/nvme/l2", "use_direct_io": "true"}, "pool_size": 128}'
可观察性#
源: lmcache/v1/mp_observability/config.py
三种模式(指标、日志记录、链路追踪)的完整说明,请参见 可观察性。
参数 |
默认 |
描述 |
|---|---|---|
|
关闭 |
总开关:完全禁用 EventBus。 |
|
关闭 |
跳过指标订阅者(不暴露 Prometheus 端点)。 |
|
关闭 |
跳过日志订阅者。 |
|
关闭 |
注册追踪订阅者。需要 |
|
|
事件总线队列中最大事件数,超过后将进行尾部丢弃。 |
|
(无) |
用于导出指标和链路追踪数据的 OTLP gRPC 端点。 |
|
|
Prometheus |
|
|
Fraction of chunks/blocks in |
|
(无) |
Enable trace recording at the given level. Currently only
|
|
(无) |
Path to write the trace file. If omitted while |
|
关闭 |
周期性 INFO 日志:每个 GPU 的 L0<->L1 传输统计和 L1 内存使用情况。请参阅 日志记录。 |
|
|
额外日志输出之间的秒数。 |
vLLM 客户端配置#
On the vLLM side, specify the LMCache server host and port via the
kv_connector_extra_config parameter. The tcp:// transport prefix
on lmcache.mp.host is optional -- a bare host is accepted and
normalized to tcp:// by the connector:
vllm serve Qwen/Qwen3-14B \
--kv-transfer-config \
'{"kv_connector":"LMCacheMPConnector", "kv_role":"kv_both", "kv_connector_extra_config": {"lmcache.mp.host": "127.0.0.1", "lmcache.mp.port": 6000}}'
要从单个 vLLM 部署目标多个 LMCache 服务器,通过 lmcache.mp.server_urls 传递服务器 URL 的列表(或以逗号分隔的字符串)。设置后,server_urls 优先于单服务器的 host / port 键;vLLM 的世界大小必须能被服务器数量整除,每个工作节点仅连接到其本地分配的服务器(全局排名被切分为连续块,每个服务器一个块)。多服务器模式目前仅支持张量并行 -- 管道并行(pp_size > 1)和数据并行(dp_size > 1)会被明确拒绝并报错。
vllm serve Qwen/Qwen3-14B \
--tensor-parallel-size 4 \
--kv-transfer-config \
'{"kv_connector":"LMCacheMPConnector", "kv_role":"kv_both", "kv_connector_extra_config": {"lmcache.mp.server_urls": "tcp://host1:6667,tcp://host2:6667"}}'
Decode context parallelism (DCP)#
--decode-context-parallel-size is supported. Under DCP, vLLM shards the
attention KV cache across ranks along the token axis, so each rank holds only
a strided 1/dcp slice and one block ID spans block_size * dcp tokens.
LMCache stores each rank's opaque page as its own object and a chunk counts as
a hit only when every rank's slice is present. Non-trivial
--cp-kv-cache-interleave-size values are supported when they evenly divide
every resolved attention cache block size. Because interleave changes the
token-to-slot byte layout, the connector automatically adds the DCP size and
interleave value to its internal cache namespace. This prevents pages written
by one interleave layout from being loaded by another. It does not change the
model name served by vLLM, but the decorated cache model name is visible in MP
metric labels so operators can distinguish incompatible cache layouts.
One configuration change is required: the LMCache chunk size must be a
multiple of vLLM's resolved scheduler block size. For a single attention
group, that is block_size * decode_context_parallel_size. For a hybrid
model, it is the least common multiple of every attention group's DCP-scaled
block span and every recurrent-state group's unscaled physical block span. If
the chunk size is incompatible, vLLM fails at connector startup with the
required multiple in the message (the LMCache server itself starts fine).
The example model also needs a vLLM build that can run it under DCP:
Kimi-Linear DCP support landed after v0.27.1 (vLLM commit 63ac04a61e,
PR #50484). On stock v0.27.1 the command below fails at startup with
Kimi-K3 MultiHeadLatentAttention does not support context parallelism.
# block_size 1024 x dcp 2 -> chunk size must be a multiple of 2048
lmcache server --host localhost --port 6000 --chunk-size 2048 \
--l1-size-gb 20 --eviction-policy LRU
vllm serve moonshotai/Kimi-Linear-48B-A3B-Instruct \
--trust-remote-code \
--tensor-parallel-size 2 \
--decode-context-parallel-size 2 \
--kv-transfer-config \
'{"kv_connector":"LMCacheMPConnector", "kv_role":"kv_both", "kv_connector_extra_config": {"lmcache.mp.host": "127.0.0.1", "lmcache.mp.port": 6000}}'
Pipeline parallelism and multiple LMCache servers may both be combined with DCP. These combinations are rejected at startup:
Rejected with DCP |
Reason |
|---|---|
|
Adds a second KV shard axis this connector does not map. |
Fewer than |
No server holds a complete set of shards, and lookup takes the minimum hit count across servers, so it reports no hits. |
An interleave value that is non-positive, larger than a resolved attention cache block, or does not evenly divide every resolved attention block is rejected at connector startup.
decode_context_parallel_size > tensor_parallel_size is rejected by vLLM
itself, so this connector does not re-check it.
LMCacheMPConnector 从 kv_connector_extra_config 中读取以下键:
连接器 extra_config 键#
所有连接器级别的选项都通过 kv_connector_extra_config 传递,并使用 lmcache.mp. 前缀。
键 |
默认 |
描述 |
|---|---|---|
|
(未设置) |
Multi-server deployment: list (or comma-separated string) of
|
|
|
Single-server deployment: host of the LMCache MP server. A ZMQ
transport prefix (e.g. |
|
|
单服务器部署:LMCache MP 服务器的端口。必须与服务器的 |
|
|
阻塞消息队列请求的超时时间(秒),包括初始块大小查询和 KV Cache 注册/注销。如果服务器在此时间窗口内未响应,连接器将在启动时引发 |
|
|
连接器向服务器发送周期性心跳 PING 的时间间隔(秒)。 |
|
|
Submit the LMCache lookup when a request enters vLLM's waiting queue, allowing L2-to-L1 KV staging to overlap with scheduler queue wait. Resumable requests are skipped because their token IDs may be incomplete at enqueue time. |
|
|
Defer store operations and submit finished requests in FIFO batches.
Available only with vLLM and |
|
|
Policy used to select finished pending requests. |
|
|
Number of finished pending requests required before a lazy-offload batch becomes eligible for submission. |
|
|
Maximum number of finished requests selected each time the lazy-offload threshold is met. |
|
|
工作进程与服务器传输上下文的路由模式。可以是 |
|
|
Assume the vLLM workers and the LMCache server run in containers
that share no host IPC namespace ( |
环境变量#
变量 |
描述 |
|---|---|
|
LMCache 的日志级别( |
|
设置为固定值以实现跨进程的可重复哈希(在使用 |
|
设置为 |
|
设置为 |
|
Seconds between continuous usage-telemetry flushes (default
|
完整示例#
lmcache server \
--host 0.0.0.0 \
--port 6555 \
--chunk-size 512 \
--max-workers 4 \
--max-gpu-workers 2 \
--hash-algorithm blake3 \
--engine-type default \
--lookup-hash-log-dir /data/lmcache/lookup_hashes \
--lookup-hash-log-rotation-interval 21600 \
--lookup-hash-log-rotation-max-size 104857600 \
--lookup-hash-log-max-files 100 \
--l1-size-gb 100 \
--l1-use-lazy \
--l1-init-size-gb 20 \
--l1-align-bytes 4096 \
--l1-write-ttl-seconds 600 \
--l1-read-ttl-seconds 300 \
--eviction-policy noop \
--l2-store-policy skip_l1 \
--eviction-trigger-watermark 0.9 \
--eviction-ratio 0.1 \
--l2-prefetch-policy default \
--l2-prefetch-max-in-flight 8 \
--periodic-notifier-interval-ms 5 \
--l2-adapter '{"type": "nixl_store", "backend": "POSIX", "backend_params": {"file_path": "/data/lmcache/l2", "use_direct_io": "false"}, "pool_size": 64}' \
--prometheus-port 9090 \
--metrics-sample-rate 0.01 \
--enable-tracing \
--otlp-endpoint http://localhost:4317
匿名使用统计#
MP 服务器报告匿名使用统计信息:在启动时进行一次环境/配置快照,并每 LMCACHE_USAGE_TRACK_INTERVAL 秒报告一次间隔计数器(检索/存储的令牌、存储的字节、正常运行时间)。绝不会发送提示、密钥、KV Cache 数据、模型名称或 --instance-id,并且报告绝不会影响服务。可以通过 LMCACHE_TRACK_USAGE=false 或 DO_NOT_TRACK=1 选择退出;有关详细信息,请参见 使用统计收集。