CacheRoute

AstraNetLabApache-2.0活跃维护

CacheRoute 是一套 LLM 调度方案,让不同 LLM 系统之间灵活复用 KV cache,从而提升任务表现和整体推理效率。

CacheRoute is an innovative LLM scheduling scheme dedicated to enabling flexible KV cache reuse across LLM systems, improving task performance and system efficiency.

v0.1.9发布于 2026-07-15 03:11 UTC264star2fork同步于 2026-11-07 07:28 UTC

怎么上手

由 README 提炼,执行前请确认
cd test
python3 demo_scheduler.py --cacheroute
python3 demo_kdn.py
python3 demo_proxy.py --strategy round_robin --injection-strategy iws --ready-release-policy text_bypass
python3 demo_instance.py --port 9001 --host 127.0.0.1
python3 demo_client.py --with-ui
硬件要求按 README 说明

README 未给出最低显存要求;完整部署示例用 8 张 GPU 跑 LLaMA-70B(tensor-parallel-size 8、gpu-memory-utilization 0.75),需按实际机器调整。另提供 USE_MOCK=True 的无模型轻量 Demo,可在无 GPU 环境下跑通组件。

需要 CUDA多卡 / 张量并行有 Docker 镜像
下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

基于 vLLM 和 LMCache 的 LLM 调度框架,通过跨系统复用 KV 缓存减少知识注入的重复预填充

CacheRoute 是一套 LLM 调度方案,让不同 LLM 系统之间灵活复用 KV cache,从而提升任务表现和整体推理效率。

核心能力

  • 按任务队列、计算与网络负载动态选择文本注入或 KVCache 注入
  • 用专用 KDN 服务器注册、存储、查询并注入知识对应的 KV 缓存块
  • 调度前解析知识需求,结合知识可用性、系统负载与拓扑做跨系统路由
  • 提供 Proxy 浏览器观测面板与可选的 Instance 资源仪表盘
  • 基于 vLLM + LMCache 接入,Instance 上报确定性能力标识

容易踩的坑

轻量 Demo 需先在 core/config.py 里把 USE_MOCK 设为 True;完整部署需自行准备模型权重和 embedding 模型路径,并先启动 Redis(默认 6379);v1 环境(CUDA 13/PyTorch 2.11/vLLM 0.25.1/LMCache 0.5.2)与旧版 YAML/offloading 命令不可混用。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v0.1.9
  1. v0.1.9CacheRoute-v0.1.9最新正式版2026-07-15 · 2026-07-15 03:11 UTC

    CacheRoute v0.1.9

    CacheRoute v0.1.9 is a major prototype update focused on adaptive knowledge injection, queue-time prediction, topology-aware scheduling, resource observability, and performance experimentation.

    Highlights

    Adaptive Text/KVCache Injection

    • Added the Intelligent Work Selection (IWS) strategy for dynamically choosing between text and kvcache injection.

    • IWS compares estimated end-to-end costs, including:

      • ready-queue waiting time;
      • text prefill cost;
      • KVCache transfer time;
      • KDN link contention;
      • Redis-to-GPU loading cost;
      • remaining text recomputation cost.
    • Added runtime and demo configuration through PROXY_INJECTION_STRATEGY and --injection-strategy.

    • Improved decision logging and trace fields for analyzing the selected injection path and its predicted cost.

    Queue Prediction and Scheduling

    • Replaced the previous single-tail predictor with a dual-layer reservation model:

      • per-worker slot availability;
      • a shared per-Instance Prefill timeline.
    • Added ordered prepare-to-ready sequencing with per-task sequence numbers and a prepared-task buffer.

    • Added optional text_bypass ready-release policy so completed text tasks can bypass blocked KVCache tasks without stalling the release cursor.

    • Added per-KDN-link KVCache transfer queues, serialization, prediction recomputation, and actual-time correction using kv_ack timestamps.

    • Added cold-start penalties and online correction of pending task predictions.

    • Refined prediction semantics around first-token completion and added decode-stage lifecycle and TPOT-related tracing.

    • Expanded predicted and actual timing fields for queue wait, Prefill, KV transfer, Redis loading, first token, forwarding, and total latency.

    CacheRoute Scheduler Strategy and Topology Awareness

    • Added the cacheroute Scheduler strategy for knowledge- and topology-aware KDN/Proxy selection.

    • KDN selection can now consider:

      • text and KVCache knowledge coverage;
      • KDN overload state;
      • pending and active network transfers;
      • network queue latency.
    • Proxy selection can consider:

      • Instance-to-KDN topology;
      • Proxy load;
      • knowledge affinity;
      • configured safety windows.
    • Added automatic Instance-to-KDN topology discovery using measured latency and interface bandwidth.

    • Proxy aggregates Instance-reported links and reports the best available KDN links to the Scheduler.

    • Added strategy and topology debug information for inspecting scheduling decisions.

    KDN Network and KVCache Transfer Modeling

    • Added real-link serialization for KDN text and KVCache transfers.
    • Text retrieval is prioritized over queued bulk KVCache transfers to reduce user-facing blocking.
    • Added transfer timestamps, queue delays, observed throughput, and bandwidth-utilization metrics.
    • Added configurable Redis target rewriting to support cross-host and non-loopback experiments.
    • Added KVCache size alignment and transfer-time prediction for Proxy scheduling.
    • Corrected KDN-link timelines using actual injection completion times and recomputed predictions for waiting tasks.

    TTFT, TPOT, and Redis Prediction Tooling

    • Added Proxy-side TTFT regression and runtime prediction utilities.

    • Added the instance/TPOT_predictor package for collecting per-token decode measurements across prompt-length and batch-size combinations.

    • Improved TTFT warmup with:

      • per-configuration warmup;
      • non-blocking server startup;
      • configurable sample-selection policies;
      • unique prompt prefixes and noise;
      • minimum target-token enforcement;
      • per-request TTFT reporting.
    • Added Redis pull-time regression and KVCache latency breakdown helpers.

    • Improved knowledge-length calculation by preserving full KDN content and applying the target model tokenizer when possible.

    Performance and Trace Collection

    • Added client/kv_timing_sender.py for RPS-driven
  2. v0.1.8CacheRoute-v0.1.82026-05-08 · 2026-05-08 04:00 UTC
    查看更新说明

    CacheRoute v0.1.8

    Overview

    CacheRoute v0.1.8 focuses on making scheduling-time prediction and runtime timing observability consistent across both KVCache injection and text injection workflows.

    This release improves:

    • prepare-stage time modeling,
    • KDN→Instance KV transfer serialization behavior,
    • high-RPS prediction stability,
    • and per-task timing transparency for controlled experiments.

    Highlights

    1) KVCache injection timing model upgrade

    • Added more complete KVCache prepare-time decomposition.
    • Introduced KDN-link-aware prediction behavior for KV transfer waiting/servicing.
    • Improved alignment between predicted and observed timings under contention.

    2) Prepare-stage prediction is now more practical for experiments

    • Prediction fields now better represent the full prepare lifecycle for KVCache tasks.
    • Timing breakdown is easier to interpret for replay/debug/reporting workflows.

    3) Better pending-task prediction behavior under concurrency

    • Added pending-task recompute behavior to reduce drift when many KVCache tasks queue on the same KDN link.
    • Helps reduce underestimation during sustained load.

    4) Stronger observability and timing diagnostics

    • Added/expanded task-level trace fields and timing logs for:
      • prepare prefix,
      • KV link wait,
      • KV transfer estimate,
      • KV ack timestamps,
      • full prepare correction points.
    • This improves reproducibility and supports strategy research.

    What’s unchanged in v0.1.8

    • Text-mode serving behavior remains compatible.
    • Ready-queue core flow and decode-path logic are preserved.
    • Existing Redis load predictor input convention remains unchanged.
    • Existing KV size modeling convention remains unchanged.

    Why this matters

    v0.1.8 is a foundation release for strategy research:

    • it improves timing signal quality,
    • keeps behavior incremental and observable,
    • and prepares the scheduler/proxy stack for policy-level routing decisions.

    Next Stage (Planned)

    A) Injection-intent decision strategy

    Build upper-layer policy logic to dynamically choose among:

    • kvcache
    • text
    • hybrid

    based on queue state, transfer cost, compute cost, and resource availability.

    B) Prefix-cache-aware routing

    Develop routing policies that consider:

    • prefix reuse potential,
    • cache affinity,
    • and routing cost/benefit tradeoffs across instances.

    Goal: improve TTFT/cost efficiency while keeping throughput and experiment stability.


    Version

    Release: v0.1.8

  3. v0.1.7CacheRoute-v0.1.72026-04-24 · 2026-04-24 03:20 UTC
    查看更新说明

    This release formalizes the queue-prediction path around Prefill-first (TTFT-centric) behavior and adds explicit task stage lifecycle markers for future Decode modeling.

    🚀 Highlights Prefill-focused queue prediction remains the mainline behavior Queue reservation/recompute continues to advance by first_token in the prefill chain, preserving TTFT-oriented queue semantics and avoiding decode-driven queue contamination.

    Stage-aware task metadata is now explicit ProxyTask includes predict_stage (default: "prefill"), and stage transitions can be represented directly in task state and trace fields.

    Decode lifecycle tracking is introduced (without decode scheduling impact) On the first token, tasks transition into the decode stage and are added to per-instance active decode tracking; on the forward end, they are removed, and the decode end timestamp is recorded. This is lifecycle observability only and does not alter prefill scheduling decisions.

    Timing observability expanded Existing timing logs now include stage visibility and active decode count for easier experiment analysis and future model extension planning.

    ✅ Compatibility No queue-mainline redesign.

    No decode batch-size tracker was introduced in this version.

    No change to the forward request flow contract.

    Existing prefill-driven queue prediction behavior is preserved while adding decode-stage observability hooks.

    🔭 What this enables next v0.1.7 establishes clean extension points for upcoming KVCache-based injection predictors while keeping the current prefill queue behavior stable and reproducible.

  4. v0.1.6CacheRoute-v0.1.62026-03-24 · 2026-03-24 08:56 UTC
    查看更新说明

    CacheRoute-v0.1.6 是一个面向 Scheduler 侧 CacheRoute 策略 的阶段版本:在不引入加权打分黑箱的前提下,完成了从“可运行”到“可解释、可验证”的关键能力落地,包括 KDN/Proxy 联动决策、策略观测与实验入口统一化。

    核心更新亮点

    1. 新增 CacheRoute 调度策略(Scheduler) 本版本引入 cacheroute 策略,采用 非加权词典序规则,避免权重参数难以自证的问题:

    KDN 选择:text_full -> not_overloaded -> kv_cover_len -> load/tie-break。

    Proxy 选择:topology_best_group -> load_safe_window -> knowledge_affinity -> load/tie-break。 该实现可直接消费 Scheduler 内部上下文,不依赖任务注入模式前置分流。.

    1. 可观测性增强:策略加载显示 + 决策快照 Scheduler 启动时明确输出当前加载策略(如 cacheroute)。

    /debug/status 新增 strategy 字段,可快速确认生效策略。

    /debug/strategy 返回最近一次策略决策快照(候选与最终选择)。

    CacheRoute 默认输出简洁的一行日志(请求ID、选中KDN/Proxy、候选数),并支持开关关闭。.

    1. KDN↔Proxy 拓扑接入能力(静态 tier) 支持通过 meta.kdn_links 提供 KDN 到 Proxy 的拓扑分层信息(如 bandwidth/latency tier),供 CacheRoute 在 proxy 侧选择时使用,且保持兼容(不提供则自动退化)。 同时 demo 入口提供了便捷参数:

    demo_scheduler.py --cacheroute

    demo_proxy.py --kdn-links-json。

    1. 文档同步:阶段总结与验证路径 scheduler/README.md 与主 README 已同步补充阶段说明、最小验证命令、关键观测字段,便于发布后团队统一验证流程。

    What's Changed

    New Contributors

    Full Changelog: https://github.com/BJTU-ANT/CacheRoute/compare/v0.1.5...v0.1.6

  5. v0.1.5CacheRoute-v0.1.52026-03-11 · 2026-03-11 14:18 UTC
    查看更新说明

    The CacheRoute prototype system supports concurrent task knowledge injection. It enhances the client's concurrent requests and KDN batch knowledge registration. It features a foundational knowledge base and task set. However, it still fails to resolve the issue of fixed hash block keys and lacks specific resource maintenance and knowledge policy integration.

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    [!IMPORTANT] Modern v1 environment: for CUDA 13 / PyTorch 2.11 / vLLM 0.25.1 / LMCache 0.5.2, use the complete v1 end-to-end guide and the v1 image/environment guide. The existing deployment content below remains the legacy stable path; do not mix its YAML/offloading commands with the LMCache MP startup interface.

    CacheRoute

    CacheRoute is a lightweight LLM scheduling framework built on vLLM and LMCache to enable flexible KV cache reuse across LLM systems. It targets knowledge-intensive LLM services, such as browser AI and knowledge QA systems, where many requests repeatedly use the same external knowledge. Existing systems usually prepend long knowledge texts to the user question and send the whole prompt to the model for recomputation. Although this approach helps reduce model hallucination and improve answer quality, it introduces heavy prefill overhead and redundant computation when the same knowledge appears across many requests.

    CacheRoute addresses this problem by using dedicated servers to store KVCache blocks for popular knowledge. For each request, CacheRoute dynamically chooses between text-based injection and KVCache-based injection according to task queues, compute load, and network load. CacheRoute therefore shifts knowledge-injection cost between compute and network resources, improving task latency and system throughput.

    Why CacheRoute?

    • 🚀 Less redundant prefill computation: reuse repeated knowledge through KV cache instead of recomputing long prompts.
    • 🔁 Cross-system KV cache reuse: share reusable knowledge across LLM systems through KDN servers.
    • 🌐 Compute-network coordination: dynamically choose between recomputation and KV cache injection based on real-time resource load.

    Key Features

    FeatureDescription
    ⚙️ Compute-network-aware knowledge injectionCacheRoute dynamically chooses between text recomputation and KVCache reuse. It predicts task cost at the Proxy and selects the injection strategy based on current task queues, compute load, and network load.
    🧭 Knowledge-oriented cross-system routingCacheRoute parses the knowledge requirement before resource-pool scheduling. The Scheduler jointly considers knowledge availability, system load, and topology information, and routes requests to the LLM system that can serve the required knowledge more efficiently.
    🗂️ KDN-based KV cache managementCacheRoute follows the Knowledge Delivery Network concept and uses dedicated KDN servers to register, store, query, and inject KV cache blocks for reusable knowledge.
    📊 Proxy browser UI and Instance resource dashboardCacheRoute provides a browser-based Proxy observability dashboard and an optional Instance resource dashboard for control-plane state, Instance liveness, resource snapshots, topology information, and short-term trends.

    Architecture

    CacheRoute separates global routing, local injection decisions, and KV cache management into Scheduler, Proxy, Instance, and KDN Server components.

    • Scheduler: performs global resource-pool selection and knowledge-oriented task routing.
    • Proxy: manages local task queues, selects the knowledge-injection strategy, validates Instance capability identity, and exposes the main Proxy browser UI.
    • Instance: connects CacheRoute to vLLM + LMCache, reports a deterministic capability identity, and handles execution signaling.
    • KDN Server: stores reusable knowledge and injects KVCache blocks when needed.
    • Resource Agent/Dashboard: optionally observes local Instance resource snapshots for validation and future control-plane integration.

    Default ports

    ComponentService PlaneControl Plane / AuxiliaryUI
    Scheduler70017002TBD
    Proxy800180028202
    Client UI--7071
    Instance900190029202
    vLLM8000--
    KDN Server9101-TBD

    Frontend URLs

    ComponentFrontendDefault URLHow to startStatus
    ProxyProxy browser observability dashboardhttp://127.0.0.1:8202cd test && python3 demo_proxy.py ... starts it by default. Use --no-proxy-ui to disable it.Available
    InstanceBrowser resource dashboardhttp://127.0.0.1:9202python3 instance/resource_dashboard/dashboard_server.py --dashboard-listen 0.0.0.0:9202 --agent-listen 127.0.0.1:9201Available
    ClientBrowser request UIhttp://127.0.0.1:7071/ui/clientcd test && python3 demo_client.py --with-uiAvailable
    SchedulerScheduler browser UITBDTBDPlanned
    KDN ServerKDN browser UITBDTBDPlanned

    The URLs above assume a single-machine deployment with loopback addresses. Containers without host networking must publish the corresponding ports or use reachable host addresses.

    System Workflow

    1. The Client sends an OpenAI-compatible request to the Scheduler.
    2. The Scheduler analyzes the knowledge requirement and selects a target resource pool.
    3. The Proxy predicts the cost of text-based and KVCache-based injection.
    4. The KDN Server injects reusable KVCache blocks when KVCache reuse is selected.
    5. The Instance forwards the request to vLLM + LMCache and returns the response.
    6. Instance resource snapshots can flow through the Proxy control plane. The Proxy aggregates a compact pool_resource snapshot and reports it to the Scheduler through registration and heartbeat payloads.
    7. The optional Proxy UI and Instance Resource Dashboard visualize control-plane and resource state for debugging and validation.

    Requirements

    CacheRoute has been tested with the following core environment:

    ComponentVersion
    Python3.12.x
    CUDA toolkit in container12.8
    PyTorch2.9.1
    vLLM0.13.x
    LMCache0.3.11
    Redis7
    Rust/CargoStable toolchain; required only for instance/resource_agent
    Tkinterpython3.12-tk; required only for the desktop dashboard

    Install CacheRoute's application dependencies with:

    python3 -m pip install -r requirements.txt
    python3 -m pip check
    

    requirements.txt is the dependency source of truth for the complete CacheRoute application and development environment. pyproject.toml provides package metadata and a deliberately smaller install surface; installing the project package alone does not replace the complete requirements installation.

    requirements.txt intentionally does not pin PyTorch, vLLM, or LMCache. These packages belong to the serving image and must remain compatible with its CUDA environment.

    For the complete Docker, source-build, Rust, Tkinter, X11, Redis, and LMCache setup, use env/README.md as the deployment source of truth.


    Quick Start

    CacheRoute provides two ways to get started.

    Option 1: Lightweight Demo without a vLLM model

    Set USE_MOCK = True in core/config.py, then start the demo components in separate terminals. The main demo entrypoints can be executed directly from test/; they add the repository root to Python's module search path automatically.

    cd test
    
    python3 demo_scheduler.py --cacheroute
    python3 demo_kdn.py
    python3 demo_proxy.py \
      --strategy round_robin \
      --injection-strategy iws \
      --ready-release-policy text_bypass
    python3 demo_instance.py --port 9001 --host 127.0.0.1
    python3 demo_client.py --with-ui
    

    demo_proxy.py starts the Proxy browser UI at a URL similar to http://127.0.0.1:8202. demo_client.py --with-ui starts the Client UI at http://127.0.0.1:7071/ui/client.

    Option 2: Full CacheRoute deployment

    The recommended host/container paths are:

    Host repository:      /llm-stack/CacheRoute
    Container repository: /workspace/llm-stack/CacheRoute
    

    When a compatible complete image already exists, create the headless/browser-mode container with:

    sudo docker run --gpus all -it \
      --name cacheroute-main \
      --network host \
      --ipc=host \
      --shm-size=64g \
      --ulimit memlock=-1 \
      --ulimit stack=67108864 \
      --memory=0 \
      --memory-swap=0 \
      -v /llm-stack:/workspace/llm-stack \
      -w /workspace/llm-stack \
      cacheroute:vllm0.13-lmcache3.11-pytorch2.9.1 \
      bash
    

    Use env/README.md when building the image, installing PyTorch/vLLM/LMCache from source, enabling Tkinter/X11, repairing an older image, or recreating a deleted container.

    The commands below assume:

    • the complete image and cacheroute-main container already exist;
    • the repository is mounted at /workspace/llm-stack/CacheRoute;
    • all CacheRoute components use host networking and loopback addresses;
    • the example model is served as llama3-70b;
    • each long-running service is started in a separate terminal with sudo docker exec -it cacheroute-main bash.
    1. Check the CacheRoute configuration

    In core/config.py, verify at least the following values before starting the services:

    DEFAULT_MODEL = "/workspace/llm-stack/models/LLM-Research/Meta-Llama-3-70B-Instruct"
    DEFAULT_MODEL_SHORTNAME = "llama3-70b"
    EMBEDDING_MODEL = "/workspace/llm-stack/CacheRoute/model/embedder/intfloat__multilingual-e5-large-instruct"
    USE_MOCK = False
    

    Install the CacheRoute application dependencies once inside the container:

    cd /workspace/llm-stack/CacheRoute
    python3 -m pip install -r requirements.txt
    python3 -m pip check
    
    2. Start Redis on the host

    Create the Redis container the first time:

    sudo docker run -d \
      --name lmcache-redis \
      --network host \
      redis:7 \
      redis-server \
        --bind 0.0.0.0 \
        --protected-mode no \
        --save "" \
        --appendonly no \
        --maxmemory 200gb \
        --maxmemory-policy allkeys-lru
    

    For later runs, use:

    sudo docker start lmcache-redis
    

    Verify Redis:

    sudo docker exec -it lmcache-redis redis-cli ping
    # Expected: PONG
    
    3. Create the LMCache configuration inside cacheroute-main
    mkdir -p /workspace/llm-stack/config
    
    cat > /workspace/llm-stack/config/lmcache_with_redis.yaml <<'EOF'
    chunk_size: 256
    pre_caching_hash_algorithm: "sha256_cbor"
    
    local_cpu: true
    max_local_cpu_size: 80.0
    
    remote_url: "redis://127.0.0.1:6379"
    remote_serde: "cachegen"
    
    local_disk: null
    max_local_disk_size: 0
    
    save_decode_cache: false
    cache_policy: "LRU"
    numa_mode: null
    EOF
    
    4. Terminal 1: start vLLM with LMCache

    The following example uses eight GPUs for a LLaMA-70B model. Adjust CUDA_VISIBLE_DEVICES, tensor parallelism, model path, memory utilization, and batch limits for the actual machine.

    sudo docker exec -it cacheroute-main bash
    
    export CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7
    export PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True
    export MODEL_DIR=/workspace/llm-stack/models/LLM-Research/Meta-Llama-3-70B-Instruct
    export LMCACHE_CONFIG_FILE=/workspace/llm-stack/config/lmcache_with_redis.yaml
    export PYTHONHASHSEED=0
    export OMP_NUM_THREADS=8
    
    python3 -m vllm.entrypoints.openai.api_server \
      --model "$MODEL_DIR" \
      --served-model-name llama3-70b \
      --host 0.0.0.0 \
      --port 8000 \
      --tensor-parallel-size 8 \
      --gpu-memory-utilization 0.75 \
      --dtype auto \
      --max-model-len 4096 \
      --max-num-seqs 8 \
      --max-num-batched-tokens 16384 \
      --kv-offloading-backend lmcache \
      --kv-offloading-size 64 \
      --disable-hybrid-kv-cache-manager \
      --kv-cache-metrics
    

    From another terminal, wait until the model endpoint is ready:

    curl -sS http://127.0.0.1:8000/v1/models | python3 -m json.tool
    
    5. Terminal 2: start the Scheduler
    sudo docker exec -it cacheroute-main bash
    cd /workspace/llm-stack/CacheRoute/test
    
    python3 demo_scheduler.py \
      --cacheroute \
      --kdn-pending-overload-th 8 \
      --kdn-active-overload-th 4 \
      --kdn-queue-ms-overload-th 30 \
      --cacheroute-log-decision 1
    

    The Scheduler service plane listens on 127.0.0.1:7001, and its control plane listens on 127.0.0.1:7002.

    6. Terminal 3: start the KDN Server
    sudo docker exec -it cacheroute-main bash
    cd /workspace/llm-stack/CacheRoute/test
    python3 demo_kdn.py
    

    The KDN Server listens on 127.0.0.1:9101 and registers its runtime state with the Scheduler.

    7. Terminal 4: register sample knowledge and build its KVCache

    Create a small knowledge file inside the shared workspace:

    sudo docker exec -it cacheroute-main bash
    cd /workspace/llm-stack/CacheRoute
    mkdir -p data/quickstart
    
    cat > data/quickstart/cacheroute.txt <<'EOF'
    CacheRoute is a knowledge-oriented LLM scheduling framework. It reduces repeated prefill computation by storing and reusing KVCache blocks for frequently requested external knowledge. The Scheduler selects a KDN server and a Proxy, while the Proxy chooses between text recomputation and KVCache reuse.
    EOF
    

    Start the interactive KDN CLI:

    python3 kdn_server/kdn_register_cli.py
    

    At the CLI prompt, register the file and build its KVCache:

    :buildkv_file /workspace/llm-stack/CacheRoute/data/quickstart/cacheroute.txt --api-url http://127.0.0.1:8000/v1/chat/completions --model llama3-70b
    :pool
    

    The Scheduler automatically refreshes KDN knowledge metadata. With the default configuration, allow up to 30 seconds for the new item to appear. Check the Scheduler state from another terminal:

    curl -sS http://127.0.0.1:7001/debug/status | python3 -m json.tool
    
    8. Terminal 5: start the Proxy
    sudo docker exec -it cacheroute-main bash
    cd /workspace/llm-stack/CacheRoute/test
    
    python3 demo_proxy.py \
      --strategy round_robin \
      --injection-strategy iws \
      --ready-release-policy text_bypass
    

    The Proxy service plane listens on 127.0.0.1:8001, its control plane listens on 127.0.0.1:8002, and the browser observability UI is available at:

    http://127.0.0.1:8202
    
    9. Terminal 6: start the Instance
    sudo docker exec -it cacheroute-main bash
    cd /workspace/llm-stack/CacheRoute/test
    
    python3 demo_instance.py \
      --host 127.0.0.1 \
      --port 9001 \
      --proxy-cp-url http://127.0.0.1:8002
    

    The Instance forwards inference to vLLM at 127.0.0.1:8000. It also starts or reuses the Rust Resource Agent by default. To skip resource monitoring during a minimal functional test, add --no-resource-monitor.

    Before sending a request, confirm that the Scheduler sees the KDN and Proxy and that the Proxy sees the Instance:

    curl -sS http://127.0.0.1:7001/debug/status | python3 -m json.tool
    curl -sS http://127.0.0.1:8002/v1/instance/list?include_dead=true | python3 -m json.tool
    
    10. Terminal 7: start the Client UI or CLI

    Browser UI:

    sudo docker exec -it cacheroute-main bash
    cd /workspace/llm-stack/CacheRoute/test
    python3 demo_client.py --with-ui
    

    Open:

    http://127.0.0.1:7071/ui/client
    

    For terminal-only use, run:

    python3 demo_client.py
    
    11. Send a simple end-to-end request

    Send the request to the Scheduler rather than directly to vLLM:

    curl http://127.0.0.1:7001/v1/chat/completions \
      -H "Content-Type: application/json" \
      -d '{
        "model": "llama3-70b",
        "messages": [
          {
            "role": "user",
            "content": "What does CacheRoute reuse to reduce repeated prefill computation?"
          }
        ],
        "temperature": 0,
        "max_tokens": 64,
        "stream": false,
        "RAG": true
      }'
    

    Inspect the most recent routing decision:

    curl -sS http://127.0.0.1:7001/debug/strategy | python3 -m json.tool
    

    The expected request path is:

    Client/curl
      -> Scheduler :7001
      -> selected Proxy :8001
      -> Instance :9001
      -> vLLM + LMCache :8000
      -> response returned through the same chain
    

    See kdn_server/README.md for detailed knowledge registration and KVCache injection commands, and core/README.md for multi-machine configuration.

    Optional: Instance Resource Dashboard

    Build-check the Rust resource agent:

    cargo check --manifest-path instance/resource_agent/Cargo.toml
    

    Start the Tkinter desktop dashboard only when the image contains python3.12-tk and the container was created with X11 forwarding as documented in env/README.md:

    python3 instance/resource_dashboard/dashboard_app.py \
      --agent-listen 127.0.0.1:9201 \
      --sample-interval-ms 1000 \
      --instance-id hp_127.0.0.1:9001
    

    Use the browser fallback in headless environments:

    python3 instance/resource_dashboard/dashboard_server.py \
      --dashboard-listen 0.0.0.0:9202 \
      --agent-listen 127.0.0.1:9201
    

    Open:

    http://127.0.0.1:9202
    

    The resource dashboard is a validation helper and does not change Scheduler, Proxy, Instance, or KDN behavior.


    API Usage

    CacheRoute exposes OpenAI-compatible API endpoints through the Scheduler.

    EndpointMode
    /v1/chat/completionsChat completion
    /v1/completionsCompletion

    Chat Completion

    curl http://127.0.0.1:7001/v1/chat/completions \
      -H "Content-Type: application/json" \
      -d '{
        "model": "llama3-70b",
        "messages": [{"role": "user", "content": "What is DeepSeek"}],
        "max_tokens": 1,
        "stream": false,
        "RAG": true
      }'
    

    Completion

    curl http://127.0.0.1:7001/v1/completions \
      -H "Content-Type: application/json" \
      -d '{
        "model": "llama3-70b",
        "prompt": "What is DeepSeek",
        "max_tokens": 1,
        "RAG": true
      }'
    

    Request Options

    OptionRequiredDescription
    modelYesModel name served by vLLM.
    messages / promptYesInput content for chat or completion mode.
    max_tokensNoMaximum number of generated tokens.
    streamNoWhether to enable streaming responses.
    RAGNoWhether to enable knowledge injection.

    Demo Screenshots

    Scheduler task scheduling

    The Scheduler selects KDN and Proxy according to knowledge coverage, topology, and current load.

    Proxy task scheduling

    The Proxy maintains local task queues and prepares requests for instance-level execution.

    Injection strategy selection

    The Proxy dynamically chooses between text-based injection and KVCache-based injection.

    vLLM + LMCache reuse

    The Instance reuses injected KVCache blocks through LMCache.

    Client response

    The Client receives OpenAI-compatible responses through the Scheduler endpoint.


    Current Status

    CacheRoute is under active development. The current release supports:

    • Scheduler-side knowledge-oriented routing.
    • KDN selection based on knowledge coverage and overload filtering.
    • Proxy selection based on topology, load safety window, and knowledge history.
    • Proxy-side dynamic injection strategy selection.
    • KDN-based text registration and KVCache registration.
    • Deterministic Instance capability identity and compatibility-aware registration.
    • Proxy browser UI for control-plane, topology, Instance liveness, and resource-snapshot observability.
    • Optional Instance resource snapshots through a Rust agent and dashboard.
    • Debugging APIs such as /debug/status and /debug/strategy.

    Suggested minimum validation commands:

    cd test
    python3 demo_scheduler.py --cacheroute
    curl -s http://127.0.0.1:7001/debug/status
    curl -s http://127.0.0.1:7001/debug/strategy
    

    Roadmap

    • Scheduler-side knowledge-oriented routing
    • Proxy-side dynamic injection strategy selection
    • KDN-based text and KVCache registration
    • OpenAI-compatible request forwarding
    • Compatibility-aware Instance capability identity
    • Proxy browser observability UI
    • Optional Instance resource dashboard
    • Scheduler browser UI
    • KDN Server browser UI
    • More deployment examples
    • Benchmark scripts and reproducible evaluation
    • More KV cache placement policies
    • Paper and citation release

    Documentation

    DocumentDescription
    doc/developer-handbook/README.mdDeveloper and maintenance handbook for public surfaces, architecture status, runtime flows, compatibility, and validation governance.
    core/README.mdShared configuration, request model, and multi-machine deployment settings.
    scheduler/README.mdGlobal routing, KDN / Proxy pool management, and Scheduler control plane.
    proxy/README.mdLocal Instance pool, capability-aware registration, heartbeat recovery, prepare / ready queues, injection strategy, and Proxy resource APIs.
    instance/README.mdInstance service and control planes, capability construction, KVCache signaling, resource monitoring, and TTFT predictor.
    kdn_server/README.mdKDN service, knowledge registration, KVCache build, and injection utilities.
    client/README.mdClient CLI, OpenAI-compatible request examples, and workload tools.
    env/README.mdDocker environment setup and vLLM + LMCache installation.
    test/README.mdDemo scripts, focused capability validation, smoke-test entry points, and local test helpers.
    doc/blog/README.mdEngineering changelog and milestone notes.