Skip to content

Commit f49fb20

Browse files
committed
Share prefix KV cache across instances with the Selene pool
Add an optional Selene pool so Flare instances can share prefix KV checkpoints across processes and hosts. Without --prefix-cache-pool, Flare keeps using Selene's in-process host tiers as before. - selene::shared holds the protocol and the definitions both sides use: wire messages, framing, rank slices, identity, limits, the record format and disk engine, the prefix index, regions, TLS setup and RDMA verbs. - The selene manager (binary selene) owns one pool's DRAM and NVMe store, keeps an index of what every attached instance holds, and brokers lookup, claim, copy and release with fencing and quarantine. Copies use shared-memory windows on one host, a TCP or TLS data channel between hosts, relay through the manager, and experimental write-only RDMA. - The pool client performs lookups, restores, exports and puts. A single-process instance is a world of one rank; multi-host tensor-parallel instances use per-rank slices and one rank link. - Host tiers never drop a record mid-chain. Records move VRAM to DRAM to local NVMe to the pool, demoted ahead of need and dropped only at the end of the chain. An opt-in --prefix-cache-drain-on-shutdown persists DRAM-only records on a clean stop. - Flare exposes checkpoint export chains and eviction headroom, attaches the pool at startup within its host and device budgets, and degrades to local tiers when the manager is unavailable. Design-Signed-Off-By: yatesdr; design-review=2d93
1 parent 7c1a9fd commit f49fb20

186 files changed

Lines changed: 72090 additions & 4208 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.dockerignore‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,20 @@ eos/**
2828
selene/**
2929
!selene/Cargo.toml
3030
!selene/Cargo.lock
31+
!selene/build.rs
32+
!selene/examples/
33+
!selene/examples/**
34+
!selene/proto/
35+
!selene/proto/**
3136
!selene/src/
3237
!selene/src/**
38+
!selene-manager/
39+
selene-manager/**
40+
!selene-manager/Cargo.toml
41+
!selene-manager/tests/
42+
!selene-manager/tests/**
43+
!selene-manager/src/
44+
!selene-manager/src/**
3345
!ignition/recipes/qwen38/assets/
3446
!ignition/recipes/qwen38/assets/**
3547
!ignition/recipes/step5/assets/

‎.github/workflows/native-serving.yml‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,13 @@ jobs:
3434
run: cargo build --locked --release --manifest-path flare/Cargo.toml
3535
- name: Test host OS helpers
3636
run: cargo test --locked --release --manifest-path eos/Cargo.toml --target-dir flare/target
37-
- name: Test host cache tiers
37+
- name: Test Selene and its manager on Linux
38+
if: runner.os == 'Linux'
39+
run: |
40+
cargo test --locked --release --manifest-path selene/Cargo.toml --features test-support --target-dir flare/target
41+
cargo test --locked --release --manifest-path selene-manager/Cargo.toml --features test-support --target-dir flare/target
42+
- name: Test host cache tiers on Windows
43+
if: runner.os == 'Windows'
3844
run: cargo test --locked --release --manifest-path selene/Cargo.toml --target-dir flare/target
3945
- name: Test native runtime on Linux
4046
if: runner.os == 'Linux'
@@ -65,3 +71,16 @@ jobs:
6571
with:
6672
name: flare-windows-native
6773
path: flare/target/release/flare.exe
74+
75+
rdma:
76+
runs-on: ubuntu-24.04
77+
steps:
78+
- uses: actions/checkout@v4
79+
- name: Install RDMA build dependencies
80+
run: |
81+
sudo apt-get update
82+
sudo apt-get install -y build-essential cmake ninja-build clang libclang-dev pkg-config protobuf-compiler libnl-3-dev libnl-route-3-dev libibverbs-dev librdmacm-dev liburing-dev
83+
- name: Compile experimental RDMA
84+
run: |
85+
cargo check --locked --manifest-path selene/Cargo.toml --tests --features rdma
86+
cargo check --locked --manifest-path selene-manager/Cargo.toml --tests --features rdma

‎Dockerfile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ COPY flare/ flare/
1515
COPY helios/ helios/
1616
COPY eos/ eos/
1717
COPY selene/ selene/
18+
COPY selene-manager/ selene-manager/
1819
COPY ignition/recipes/qwen38/assets/ ignition/recipes/qwen38/assets/
1920
COPY ignition/recipes/step5/assets/ ignition/recipes/step5/assets/
2021
COPY ignition/recipes/kimi3/assets/ ignition/recipes/kimi3/assets/

‎docs/api.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,13 @@ instantaneous gauges.
308308
| `host_bytes_in` | Bytes copied from the host store into GPU pages and rows | `flare_host_cache_bytes_in_total` |
309309
| `learned_drafter` | Boolean: the model has a learned drafter | none |
310310

311+
Host retention also exports `flare_host_cache_held_total{tier}` and
312+
`flare_host_cache_dropped_total{tier,reason}`, with `dram` and `nvme` tiers and
313+
`end_of_chain`, `oversize`, `io_error` drop reasons. The gauge
314+
`flare_host_cache_parked_records` counts complete DRAM copies awaiting disk
315+
writes. `flare_host_cache_store_skipped_total` still includes duplicates and
316+
retries; it is not a dropped-record counter.
317+
311318
Dashboard DEPTH is the change in `verification_drafts` divided by the change in
312319
`verification_rounds` over the sampling window. It averages each request's planned
313320
draft-prefix length, including zero-draft rounds, rather than graph width or batch

‎docs/cli-design.md‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -943,6 +943,7 @@ reserve = "0" # GPU memory left for processes started later.
943943

944944
[prefix_cache]
945945
memory = "" # Host retention budget; empty: disabled.
946+
drain_on_shutdown = "off" # Pooled DRAM persistence: on, off, or a duration.
946947
disk_limit = "" # Empty: 10% of free disk space when disk retention is enabled.
947948
disk_transport = "" # Empty: staged; also accepts direct.
948949

@@ -1040,6 +1041,20 @@ disabled unless configured. The memory setting includes registered checkpoint
10401041
slabs and ordinary retained CPU inputs; bounded transfer, preprocessing, and
10411042
decoded-source windows are accounted for separately at startup.
10421043

1044+
`--prefix-cache-pool ADDRESS` accepts `unix:PATH` for a local socket,
1045+
`HOST:PORT` for plain TCP, or `tls:HOST:PORT` for TLS. Network
1046+
addresses require a nonempty host and a port from 1 through 65535; IPv6
1047+
addresses use brackets, for example `[::1]:7000` or `tls:[::1]:7000`.
1048+
The manager's `--name` supplies the pool salt for scope and instance identities.
1049+
`--prefix-cache-pool-ca FILE` supplies the CA for a TLS manager;
1050+
without it, TLS verifies the manager against the host's trust store. A CA
1051+
cannot be used with a Unix socket or plaintext address. A manager declaring
1052+
a different encryption setting disables the pool for TCP clients. Unix-socket
1053+
clients trust filesystem permissions and can use the same TLS manager. The CA
1054+
requires the pool flag. These command-line options are forwarded to
1055+
every rank and have no configuration-file key. See
1056+
[the pool section](prefix-cache-offload.md#215-sharing-through-a-pool).
1057+
10431058
## 4. Derived settings
10441059

10451060
| Setting | Derived from |

0 commit comments

Comments
 (0)