CLI 参考#

lmcache 命令行接口提供了启动、管理、检查和基准测试 LMCache 服务器及其前面的推理引擎的工具。

lmcache <command> [options]

安装 LMCache 后,lmcache 命令可以全局使用。运行 lmcache -h 查看所有命令,或运行 lmcache <command> -h 查看特定命令的帮助。

安装#

lmcache CLI 包含两个软件包:

包

安装

何时使用

lmcache

pip install lmcache

完整安装:服务器、CLI 和 CUDA 扩展。server、bench server、bench l2 和 trace 所需。Linux + GPU。

lmcache-cli

pip install lmcache-cli

CLI only: ping, query, describe, kvcache, quota, bench engine, bench quality (run also needs pip install transformers). No GPU required, any OS.

备注

请勿在同一环境中安装这两个软件包 — 它们都提供 lmcache 入口点。

可用命令#

命令

描述

lmcache server

Launch the LMCache MP server (gRPC or the deprecated ZMQ, plus HTTP). Requires the full install.

lmcache coordinator

启动 LMCache MP 协调器(HTTP 实例注册表)。

lmcache describe

显示正在运行的 LMCache 服务的详细状态。

lmcache ping

对 LMCache 或 vLLM 服务器的存活检查。

lmcache query

Single-shot queries: one inference request to a serving engine (engine), or a read of the MP coordinator's read-only HTTP APIs (coordinator).

lmcache bench

Run sustained benchmarks against an inference engine (engine), an LMCache MP server (server), or an L2 cache adapter (l2), compare a candidate serving stack's answer quality with a reference (quality), or analyze a recorded request trace offline (trace-analyze).

lmcache kvcache

在运行的服务器上管理 KV Cache 状态(例如,清除 L1 缓存)。

lmcache quota

管理每个盐值的缓存配额(设置、获取、列出、删除)。

lmcache trace

检查和重放存储级跟踪文件。

lmcache tool

运行离线分析工具(例如缓存模拟器)。

输出格式#

产生指标的命令共享三个常见标志:

  • --format {terminal,json} — 标准输出格式(默认:terminal)。

  • --output PATH — 还将指标写入文件(使用 --format)。

  • -q / --quiet — 抑制 stdout;依赖退出代码。

终端输出使用人类可读的标签(例如 "Round trip time (ms)"),而 JSON 使用机器可读的键(例如 "round_trip_time_ms")。

添加新命令#

通过在 lmcache/cli/commands/ 下创建 BaseCommand 子类来添加新的 CLI 子命令;它们会被自动发现和注册。有关详细信息,请参见 扩展 CLI。