Files
myWiki/concepts/agentic-cache-manager.md

67 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: "Agentic Cache Manager"
created: 2026-06-20
updated: 2026-06-20
type: concept
tags: ["kv-cache", "memory", "drift", "streaming", "inference"]
sources: ["https://arxiv.org/abs/2606.17800"]
---
# Agentic Cache Manager (Agentic 缓存管理)
**Agentic Cache Manager** 是 [[maineCoon|MaineCoon]] [[agentic-streaming-inference|流式推理框架]] 中管理模型记忆的控制器:在单个持久 [[kv-cache|KV-Cache]] 上同时治理**记住多少**bounded keep-set和**记多准确**drift control
## 单持久缓存 → 连续流
传统方案的问题:
- **重生成增长前缀**:每块 cost 随长度增长 → 不可扩展
- **拼接独立段**:周期 re-anchoring → 身份/颜色/音频跳变
MaineCoon 使用**一个永不清理的 KV-cache**chunk 间连续性由 attention 原生携带,无拼接边界。
## Bounded Keep-Set有界保留集
缓存不能无限增长——模型使用有限 RoPE 位置编码。Manager 每次 commit 后重新计算保留集:
```
Keep = Subject Anchor Scene Sink Scene Anchors Recent Chunks Restored
```
- **Subject Anchor**:主体语义参考块(见 drift control
- **Scene Sink**:场景建立时的 persistent attention sink
- **Scene Anchors**:散布的场景关键帧
- **Recent Chunks**:固定预算的最新 chunk
- **Restored**:场景返回时恢复的历史 chunk
**四种 attention 类型各自独立追踪**visual self-attn, audio self-attn, cross-modal AV paths 的缓存增长速率不同,需要 per-type ledger 独立管理。
## Drift Control漂移控制
核心原则:**永不修改已发布的像素**——修正仅施加于写回缓存的 committed copy。
### Statistical Anchor (AdaStat)
写回缓存前对 clean latent 做 per-channel 统计匹配:
```
AdaStat(x) = σ* ⊙ (x - μ(x))/σ(x) + μ*
```
- 参考 (μ*, σ*) 从场景开头初始化,慢 EMA 更新
- 仅对**低漂移 chunk** 更新参考,追踪合法 scene evolution
- 音频通道使用降低的强度
### Subject Anchor主体锚
- 开放词汇分割器在周期性快照上对规划器的文本描述评分
- 从流的 clean latent 中收割最高分 token
- 作为 KV-cache 中的固定参考块,**永不输出**
- 使漂移从不可逆变为**可恢复**
## Bounded Positions
位置编码通过 bounded epoch slots 保持在训练范围内。epoch 耗尽时用保留的 clean latent 在新 slots 重建缓存,保留内容但刷新位置编码。
## 效果
在二十秒训练片段上训练的模型,可连续流式运行 **45 分钟无显著退化**
## 参考
- [[maineCoon|MaineCoon 论文]] Section 4.2
- [[kv-cache]]
- [[agentic-streaming-inference|Agentic Streaming Inference]]