# @nous/wm-serving

Real-time world-model inference runtime (Phase 176.8.1.1), Rust, zero external
dependencies.

`rust/crates/wm-serving-kernel`:

- **`WorldModelRuntime`** — batched, action-conditioned autoregressive token
  generation. One decode state (KV cache + token history) per concurrent world
  session; `generate_frame` advances every session under its own action.
- **`KvCache`** — a growing key/value cache with `truncate` for speculative
  rollback.
- **Speculative decoding** (`speculative.rs`) — the Leviathan et al. acceptance
  rule (accept `min(1, p/q)`, resample the normalised residual on rejection,
  bonus token on full acceptance) for a future-frame preview from a cheap draft
  model; preserves the target distribution exactly.
- **`FrameScheduler`** — paces generation to a target FPS: achievable-FPS and
  meets-target checks plus a virtual-clock pacer (the 24 FPS / 720p target from
  the task is a `meets_target` query given tokens-per-frame and per-token cost).
- **`LogitModel`** — the trained-weights boundary; `ReferenceWorldModel` is a
  deterministic peaked model that makes the runtime end-to-end runnable and
  testable without accelerator weights.

The WebRTC egress and the actual H100-resident weights are deployment
boundaries; this crate is the CPU-testable serving kernel (generation loop,
cache, speculation, pacing).

```
cd libs/nous/wm-serving/rust && cargo test && cargo clippy --all-targets
```
