Files
myWiki/concepts/thinker-performer-pipeline.md

77 lines
2.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: "Thinker-Performer Pipeline"
created: 2026-06-25
updated: 2026-06-25
type: concept
tags: [inference, streaming, pipeline, kv-cache, flow-matching]
sources:
- "[[wan-streamer]]"
---
# Thinker-Performer Pipeline
**Thinker-Performer Pipeline** 是 Wan-Streamer 的推理部署架构,将统一的端到端模型拆分为两个协作进程,通过 [[kv-cache|KV-cache]] 交换维持统一因果状态,实现感知和生成的流水线重叠。
## 架构
```
Thinker (GPU 0) Performer (GPU 1)
───────────────── ─────────────────
编码用户观测 uk 接收 KV slice
更新 KV cache 全历史 flow-matching 求解
解码前帧响应 y_{k-1} → 发射 生成 clean latents yk
发送当前 KV slice → ← 返回 clean latents
```
## 两个角色的职责
### Thinker思考者
- 消费当前流式单元的**用户音视频观测**(文本、语音、视频帧)
- 运行因果编码器进行编码
- 运行 Transformer 的短 token-causal pass语言预测 + 状态更新)
- 生成新 KV-cache slice当前交互状态
- 解码 Performer 返回的前一帧潜变量为可发射的音频/视频输出
- **不运行**昂贵的 flow-matching solver
### Performer执行者
- 接收 Thinker 发送的 KV-cache slice
- 将 KV slice 追加到自己的全历史缓存中
- **只运行** flow-matching solver 生成下一帧的音视频潜变量
- 将 clean latents 保持在 Performer 侧
- 在下一个流式步返回给 Thinker
- **不运行**解码器或编码器
## 流水线重叠
关键洞察:相邻流式单元之间的工作可以重叠:
| 时间片 | Thinker | Performer |
|--------|---------|-----------|
| 时刻 k 前半 | 编码 u_k更新 KV_k | — |
| 时刻 k 中 | 解码 y_{k-1},发射 | — |
| 时刻 k 后 | 发送 KV slice → | ← 接收 KV slice求解 y_k |
| 时刻 k+1 前 | 编码 u_{k+1} | 求解 y_k继续 |
| 时刻 k+1 中 | 更新 KV_{k+1} | ← 返回 y_k |
这样,感知/状态更新、前帧解码、KV/潜变量通信、下一帧去噪在连续流式单元间重叠执行。
## 实时性条件
系统能实时运行的条件是:
> Performer wall time + KV-cache/latent 通信开销 < 160ms一个流式单元
这**不同于**模型侧响应延迟(从接收用户输入到发射对应响应的时间,约 200ms
## 关键优化
- CUDA graph capture 减少 kernel launch 开销
- 编译优化
- 优化的 KV-cache 交换格式
## 参考
- [[wan-streamer]]
- [[kv-cache]]
- [[flow-matching]]
- [[streaming-inference]]