Back to blog

Execution-State Capsules: Graph-Bound Execution-State Checkpoint and Restore for Low-Latency, Small-Batch, On-Device Physical-AI Serving

FlashRT 提出 execution-state capsule:把整个 forward 用 CUDA Graph 静态缓冲区捕获,再把已提交边界处的 KV / 循环 / 卷积 / MTP / 元数据整个 buffer set 作为可 freeze/restore/fork/rollback 的显式对象。相较 vLLM 冷路径,同 hybrid LLM 单流 TTFT 从 200/365/723ms 降到 51/53/54ms,相较 vLLM APC 也快 1.4–2.8×;16k prefix 时相较自身 cold 加速 27×,restore/snapshot 亚毫秒完成,KV-only 恢复的 97.9% token 会发散,证明 hybrid recurrent 状态必须整体 snapshot。

Execution-State Capsules: Graph-Bound Execution-State Checkpoint and Restore for Low-Latency, Small-Batch, On-Device Physical-AI Serving

一、论文概述

字段内容
标题Execution-State Capsules: Graph-Bound Execution-State Checkpoint and Restore for Low-Latency, Small-Batch, On-Device Physical-AI Serving
作者Liang Su
机构独立作者(论文未列机构;代码 repo flashrt-project/FlashRT)
论文链接https://arxiv.org/abs/2606.20537
HTMLhttps://arxiv.org/html/2606.20537v1
PDFhttps://arxiv.org/pdf/2606.20537
发布2026-06-19
分类cs.LG(primary)、cs.DC
系统别名FlashRT / Execution-State Capsule

二、核心思想

问题定义

vLLM 和 SGLang 是 throughput-first 的当代 SOTA 推理服务,用 paged KV / radix prefix 高效摊薄共享 KV。但在 physical-AI serving 场景(单/少流交互、on-device VRAM 有限、控制回路间歇会话、硬 TTFT 预算)——例如:

  • coding agent / assistant,10–50k 系统 prompt+repo prefix,逐轮追加;
  • 语音/TTS 前端 barge-in;
  • 视觉-语言-动作 (VLA) / 机器人策略 loop;

throughput-first 机制的假设(多并发摊薄 auto-managed cache)不成立,且 KV cache 不能表达整个 continuation state。作者观察三个 paged/radix 不作为一等对象暴露的能力:

  1. Hybrid recurrent 状态(linear-attention 循环态、conv state)是 prefix 的 fold,不可按位置切片。
  2. fork:把一个已提交边界 1→N 个独立会话。
  3. rollback:回到本会话较早边界(undo turn)。

解决方案概述

FlashRT 是一个 latency-first 白盒运行时。核心创新:

  • 静态缓冲区 + 全图捕获:不用可变 block-table 索引,把整个 forward(含 attention)在 contiguous static buffers 上用 CUDA Graph 捕获,bound buffers 就是完整 state。
  • Execution-State Capsule:在已提交位置 PP 把 KV + linear-attention recurrent + conv state + MTP 尾 + metadata 整体 freeze 为一个 tiered (GPU/host/disk) 可命名对象。
  • 四个 serving verbs:snapshot / restore + append / fork 1→N / rollback。

Managed object diagram

三、技术架构/方法

与 paged/radix 的机制差异

Paged/radix:attention kernel 通过可变 index 从 paged pool 读 KV,captured graph replayable but not self-contained;hybrid recurrent/conv 存在 side cache。要 fork/rollback 需要额外新对象。

FlashRT:所有 state 存在 static contiguous buffers 上,captured graph replay = 一个自包含快照 + 一个字节复制 + append。“graph decides how to compute; capsule decides which state to compute from.”

Capsule 定义

在位置 PP 冻结固定 named 缓冲区集合:

  • 小尺寸部分:linear-attention recurrent state、conv state、MTP tail & compact cache with valid range、last hidden as MTP seed、metadata (cur_pos, token-prefix digest)。
  • KV 区域:full-attention KV over [0,P)[0,P)、FP8 dequant stage 的 valid end。KV 随 PP 增长、主导 footprint(FP8-KV 大约减半)。

Capsule 只在有意义的 boundary 上产生:pinned shared prefix、episode start、turn boundary,不密集打点。

四个 serving 动词(Fig. 2)

  1. snapshot:整个 live set (KV, R, C, MTP) 冻结为 C0C_0。
  2. restore + append:C0C_0 回写 live buffers;只追加新 suffix ss;replay 已有 captured graph(无 recapture、无 prefix recompute)。
  3. fork 1→N:把 C0C_0 恢复到 N 个独立 session,token-exact。
  4. rollback:restore 更早的 committed boundary(撤销一次 turn)。

Serving verbs

Execution Contract(§4)

188 行 C ABI,仅暴露:Buffer(唯一 state 原语)、Graph(ShapeKey→captured graph-exec)、Plan(DAG of graph nodes)、ShapeKey (opaque u64)。Contract 是 capture-agnostic:captured graph 可以包住 FlashRT 内核、torch ops、或原生 backend;两个 graph 共用一个 Buffer 就是 zero-copy 多模型 hand-off 全部机制。

  • 层级:serving/(policy)→ flash_rt/(frontend)→ exec/(contract)→ csrc/(kernels)。
  • Contract 不知道 session/KV append/scheduler;这些都是上层策略。
  • Capsule 仅新增一个原语:host-backed buffers + cross-space async copy(可 park 到 host/disk)。

Serving-layer verbs(Listing 2):

cap = session.snapshot(boundary="turn", tier="gpu", pin=True)
session.restore(cap, suffix=new_tokens, shape_key=key)  # no recapture
branches = session.fork(cap, n)                          # 1 boundary → N sessions
session.rollback(cap_earlier)
registry.promote(cap, tier="gpu"); registry.evict(policy="lru")

正确性(§5)

三层:

  • Byte restore:字节精确回写。
  • State completeness:对抗测试——snapshot 后用无关 prompt 完全覆盖所有 live buffer 并 decode;再 restore、decode 得到与”从未跑过无关 prompt”完全一致 token。任何遗漏的 recurrent register / conv window / MTP entry / metadata 都会发散。
  • End-to-end equivalence:greedy decode 后 pure restore = cold prefill;restore+append = 直接 append;fork branches 匹配。

Chunk-alignment 条件:linear-attention chunked prefill 按 chunk 折叠 recurrent state。若 boundary PP 不是 chunk 大小 CC 的整数倍,会引入 cold prefill 没有的 chunk split,FP8 rounding 下发散。修复:P′=⌊P/C⌋⋅CP'=\lfloor P/C\rfloor\cdot C,剩余 <CC tokens 由 append 廉价重跑。

三个域用一个机制(§6)

  • Coding agent:pin C0C_0,每轮 restore + append 新 turn(不重跑 10–50k prefix)。
  • Fork(tree-of-thought / best-of-N):C0C_0 恢复到 N 独立 branch,逐 token 精确。
  • Robot RL rollout:episode reset = restore(C0C_0);host 每 tick replay 一个 action chunk。
  • Planner–actor hand-off:不需要 capsule,直接 zero-copy Buffer 共享;一次改写 subgoal buffer 下轮 replay 自动使用。

Physical-AI scenarios

四、核心创新

#创新点说明
1Static-buffer whole-graph capture相较 paged/radix 让 captured graph 自包含,是 capsule 的先决条件
2Execution-State Capsule把整个 continuation state(KV + recurrent + conv + MTP + meta)作为第一等可 snapshot/restore/fork/rollback 对象
3Chunk-aligned recurrent reuse显式利用 linear-attention chunk 边界做精确 recurrent state 复用
4188 行 C ABI Execution Contract机制不涉策略;一份 contract 同时支撑 LLM、TTS、VLA policy
5三域统一的 verbsLLM warm start = robot episode reset = 同一 snapshot/restore;planner-actor 用 zero-copy Buffer

五、实验结果

环境

  • 主测:单卡 NVIDIA GeForce RTX 5090(sm_120,33.7 GB),CUDA 13。
  • On-device 复现:Jetson AGX Thor (sm_110)、DGX Spark (GB10, sm_121)。
  • 模型:hybrid LLM(NVFP4,MTP heads K=3);此 checkpoint 使用 Qwen3.5 hybrid(Qwen3_5ForConditionalGeneration)。
  • 并发:1(single-stream)。
  • 基线:vLLM 0.22.0 + APC(NVFP4,full CUDA-graph mode,max_num_seqs=1,max_model_len=12288);SGLang 结构性对比(其 hybrid recurrent 存在 side cache,见附录 A 关于 NVFP4 W4A16 兼容性问题)。

Runtime Floor (§7.1, Table 6)

4096-token prefix, 30 repeats:

Metricp50p90p99
Cold TTFT (ms)366.8367.2367.2
Capsule TTFT (ms)53.053.053.1
Peak GPU mem22.8 GB (load+capture)Capsule = 224 MB—

FlashRT cold 相对 throughput-first runtime 低 2.6–2.8×(Table 9)。

Capsule 操作分解(Table 7)

PrefixCapsule 大小snapshotrestoreappendCold TTFTCapsule TTFTSpeedup
2048160 MB0.3 ms0.3 ms25 ms200 ms51 ms3.92×
4096224 MB0.4 ms0.4 ms26 ms365 ms53 ms6.91×
8192352 MB0.7 ms0.7 ms28 ms723 ms54 ms13.33×
16384608 MB1.2 ms1.2 ms28 ms1541 ms57 ms26.94×

snapshot / restore 亚毫秒(带宽受限的 buffer copy),append 平坦 ~25–28 ms;speedup 随 prefix 长度单调扩大。

Runtime floor scaling

KV-only Ablation(Table 8)

4096-token boundary,greedy K=0:

Restore variantFirst divergenceMismatch
Full state (KV + recurrent + conv + MTP)—0 / 48
KV only, recurrent fold zeroedtoken 147/48 (97.9%)
KV only, recurrent fold staletoken 345/48 (93.8%)

Recurrent state 是全 prefix 的 fold,无位置分块;仅 KV 恢复必然发散——capsule 是必要的,不是 memcpy 的重命名。

对 vLLM (Table 9/10)

Absolute TTFT (ms), same hybrid model & GPU:

PrefixvLLM coldFlashRT coldvLLM APC hitFlashRT capsule
204851920014351
409610263657653
8192205772312054
  • 冷路径 FlashRT 比 vLLM 快 2.6–2.8×。
  • Reuse 路径:capsule 比 APC hit 快 1.4–2.8×。
  • 更关键的是”miss mode”:APC 是 opportunistic + LRU,capsule 是显式 pinned;miss 时 vLLM 回落到 cold column,capsule 保持 51–54 ms。

Embodied Loop (Figure 5)

Cycle NN 个 2048-token contexts(技能/subgoal/中断-恢复):

  • vLLM APC 命中每 context 缓存 1568 tokens (TTFT 144 ms),直到 working set 达 ~8k tokens;≥ 16k tokens 后 num_cached_tokens 崩到 0,TTFT 回到 519 ms cold prefill——这远小于 vLLM 本身 34,629 token 全 KV 容量的一半,作者分析 vLLM 的 hybrid mamba prefix cache 是 experimental 路径。
  • Capsule 保持 ~50 ms 平坦;20 contexts (3.4 GB capsules) 在 27.5 GB peak 中容纳,与 vLLM 报告的 ~30 GB residency 相当。

Embodied loop

Barge-in / LLM+TTS composed (Figure 6)

再入 (re-entry) 场景下 capsule 保持低 TTFT;TTS 侧另测端点终止延迟。

LLM+TTS barge-in

Fork/Rollback(Thor)

从一个 capsule 分叉两条 branch A、B:branch A = cold(prefix+A)、branch B = cold(prefix+B),验证 40/40 token match;rollback 之后 branch B 与 cold prefix+B 完全一致。

9 项 pytest correctness

  • pure-restore = cold prefill;
  • restore 幸存于被 dirty 的 state;
  • restore+append = 非 capsule append path;
  • fork branches match;
  • chunk-aligned long boundary = cold full prefill;
  • 未接入的 “TQ” KV mode 显式抛异常而非产出部分 capsule。

所有 capsule 结果对 cold reference 均 token-exact。

六、总结

核心贡献

  1. 提出 execution-state capsule:把 committed boundary 的完整 forward state(KV + recurrent + conv + MTP + meta)作为服务系统的第三种一等对象(对齐 vLLM 的 PagedAttention 与 SGLang 的 RadixAttention)。
  2. 提出 static-buffer whole-graph 捕获,使 capsule 成为 self-contained 可冻结对象;相较可变索引的 paged/radix,captured graph 完整持有 state。
  3. 显式识别 chunk-aligned reuse 条件,使 linear-attention 循环态可 exact 复用。
  4. 提供 188 行 C ABI Execution Contract,机制/策略分离;一份 contract 覆盖 LLM warm start、robot episode reset、planner-actor zero-copy hand-off。
  5. 实验:同 hybrid LLM 单流下 cold TTFT 200/365/723 ms、capsule TTFT 51/53/54 ms(vs. vLLM cold 519/1026/2057 ms 与 vLLM APC 143/76/120 ms);16k prefix 相对自身 cold 加速 27×,snapshot/restore 亚毫秒;KV-only 恢复导致 97.9% token 发散,证明 recurrent 状态整体 snapshot 必要。

技术影响

  • 为 low-latency on-device / physical-AI 服务系统提供了一个新的第一等 managed object,可扩展至 fork / rollback / hybrid state reuse。
  • 与 checkpoint/restore(CRIU)、Prompt Cache、Pensieve、Hydragen 等前作在”reuse 对象”层面上定位清晰。
  • Execution Contract 的机制-策略分离范式(188 行 header)为其他跨模型 (LLM+TTS+VLA) 系统提供参考。

局限性

  • 单节点、低并发、latency-first;不与 paged/radix 争 throughput 主战场。
  • capsule 是绑定精确 weight/quant/kernel/graph bucketing 的 binary state blob,跨版本/团队不可携带;持久化仅用于 warm-start 同一部署。
  • 静态缓冲区 + 图捕获需要固定 shape 集合与最大序列长度;不适合高度动态 shape。
  • 生产 agent 集成、on-robot 评估尚是未来工作;“TQ” 长 KV mode 未接入(显式抛错)。
  • 同模型 SGLang 未能提供 latency 对比(NVFP4 W4A16 quant scheme 尚未支持)。

七、参考资源