EXP-038: GDN snapshot / pin / restore / fork API + /tq HTTP routes (stages 0-4 hardware-proven)

Merged
KE
3mo ago
+5077-0

Env-gated (VLLM_TQ_GDN_SNAPSHOT, default off) serving primitive: park GDN recurrent state, pin KV blocks across request free, zero-kernel restore via cache hit, fork_from_handle into N children with divergent sampling, plus /tq/pin|fork|unpin HTTP routes and async-client plumbing. All four stages + the HTTP path verified on hardware (byte-exact continuations, 98% cache-hit children, zero leaked blocks; fork-research demo end-to-end). Known gaps documented in-tree: quiescent-only pin targeting, blocking fork (v2 = admit-as-normal-requests, also fixes fork children ignoring stop tokens), K-sizing interactions.

@cubic-dev-ai review

🤖 Generated with Claude Code


Summary by cubic

Adds a non-blocking fork path via /tq/fork2 with optional per‑child SSE streaming and a read‑only get_pin_handle, completing “prefill once, fork N” without changing default serve behavior. Old behavior: /tq/fork blocked the engine loop and bypassed eos/stop. New behavior: /tq/fork2 submits children as normal AsyncLLM.generate requests; with stream: true it emits SSE per‑child deltas; the loop stays free and finishes are stop‑correct. Stage‑6 window driver reports hardware PASS (4/4 stop‑correct, full‑cache adoption).

  • get_pin_handle(handle_id) returns pinned prefix metadata (token_ids, cache_salt) for server‑layer fan‑out; mirrored across async/sync clients, declared on the EngineClient protocol, and rejected under DP load balancing by DPLBAsyncMPClient.
  • Shared child‑spec validation lives in vllm/entrypoints/openai/tq_fork_specs.py and is used by both /tq/fork and /tq/fork2.
  • /tq/fork2 streaming: stream: true returns SSE events (fork_start; per‑child child_start → child_delta* → child_done; terminal fork_done). Streaming children use DELTA output; non‑stream keeps FINAL_ONLY. Per‑child errors and timeouts are isolated; validation errors remain JSON.

Rollout and limits

  • Opt‑in only: set VLLM_TQ_GDN_SNAPSHOT=1 (optional VLLM_TQ_GDN_SNAPSHOT_PARK_BLOCKS); the router attaches only when gated; never enable on :8001.
  • Single‑engine only; DP load balancing is rejected.
  • /tq/pin requires a quiescent engine with a single running request.
  • /tq/fork remains blocking and bounded by max_steps/max_total_tokens; /tq/fork2 is non‑blocking and each child runs as an ordinary generate request (streaming or final JSON).