← Back to projects

Project · 2026 – Present

RWKV SSD-streaming inference engine

An RWKV inference engine that streams model weights from SSD when they do not fit in RAM.

A manifest locates each layer in a model pack; a bounded cache and read-ahead path manage weight loading while recurrent state stays in memory. I compared streamed output with a resident run and exposed the engine through a local API.

Engine walkthrough

A token, one layer at a time

Watch weights move from storage through the cache and compute path, then into recurrent state.

Simulated token pass Small RAM cache · 3 layers
Token pass1
LayerWaiting
Weight memory3 layer cache
Pack reads0
Cache hits / misses0 hits · 0 misses
Read-ahead hits0 hits · 0 misses

Follow one layer through storage, cache, compute, and state.

01 · SSD storageidle
weights.binmanifest.json
L1L2L3L4L5L6L7L8L9L10L11L12
Global tensorsembeddingoutput head
Selected manifest groupblocks.0.*tensor name → codec, shape, offset, length
02 · RAM cachebounded retention
slot 1empty
slot 2empty
slot 3empty
slot 4empty
slot 5empty
slot 6empty
prefetch queueempty
Cached model layers stay in RAM.
03 · Stage and computewaiting
A
Decode / prepareprepare current layer for the backend
B
Install active layerset current weights in the execution path
C
Run RWKV blocktime mix, channel mix, and layer state
01Time mixprevious activation + recurrent matrix
02Channel mixfeed-forward work + previous activation
03Save statesave the updated state for each session
L1TMixCMix
L2TMixCMix
L3TMixCMix
L4TMixCMix
L5TMixCMix
L6TMixCMix
L7TMixCMix
L8TMixCMix
L9TMixCMix
L10TMixCMix
L11TMixCMix
L12TMixCMix
token activation → L1next layer
active layer buffer
idle
CPU execution path. Device transfer staging applies only to supported accelerator configurations.
04 · Recurrent stateresident
Session state ready each layer keeps its own recurrent state
session 1 · state ready
output head · logitswaiting
Read-ahead can overlap block workstage order · no time scale
StageFindReadPrepareInstallTMixCMixSave Block Read-ahead

Read-ahead begins during the current block. This example makes the queued spans ready before the next block asks for them.

Global weightsembedding + output headprepared before this token pass
Retained block weights0 / 3 cache slots
In-flight workno active layeractive layer and read-ahead are additional
Session state1 × 12 layer statesseparate state, shared weight sweep

Illustrative 12-layer pass. Read-ahead and counters are simulated. Backend docs · Streaming docs · Read-ahead code.

Measurement

Weight loading

One controlled comparison · 0.1B model

Warm decode throughput

ProfileWeight residencyTokens/s
F1Read every layer on demand50.98
F2Two-layer working set52.13
F3Three selected layers retained49.69
F4Four selected layers retained50.46
RAMAll weights resident53.07

Native CPU, 0.1B model, 64 output tokens, five samples per profile. This compares residency strategies within one local setup; it does not establish performance across hardware or model sizes.

Measurement

Multiple requests

Same model pack · concurrent local sessions

Combined completion speed

RequestsRelative throughputComparison
10.92×Sequential baseline
21.93×Shared weight loading
43.52×Shared weight loading

Warm CPU test, 16 generated tokens per request. Ratios compare combined completion with running the same requests sequentially; paired output text matched.