close the RECAP critic-policy loop

This commit is contained in:
seeker
2026-07-12 19:33:15 +08:00
parent 53ef020b46
commit bd88a46b23
13 changed files with 780 additions and 314 deletions
+11 -4
View File
@@ -27,8 +27,8 @@ classifier-free guidance(CFG)策略。
| 1. Base policy | `64×64` 图像、离散历史 XY、任务提示 | 小型 VLM policy + stop-gradient flow expert | subtask、FAST-lite tokens、连续 `16×2` action chunk | token CE + flow matching |
| 2. Experience | 一条真实示范轨迹 | 确定性经验构造 | 成功示范、understeer、提前停止、人工纠正 4 类 episode | 无梯度,仅构造 buffer |
| 3. Value | 图像、离散状态、任务、episode return | 小型独立 value VLM | `201` 个 return bins,期望 value 位于 `[-1,0]` | distributional CE |
| 4. Advantage | reward、当前/未来 value、intervention mask | n-step estimator + quantile threshold | positive/negative indicator;人工纠正强制 positive | 无梯度,生成策略条件 |
| 5. Mixed warm-up | 示范与合成经验、advantage 条件 | advantage-conditioned policy | 条件化离散动作和连续 flow | token CE + flow matching |
| 4. Advantage | reward、学习到的当前/未来 value、intervention mask | critic inference + n-step estimator + quantile threshold | positive/negative indicator;人工纠正强制 positive | value 更新后重新标注策略数据 |
| 5. Mixed SFT baseline | 示范与合成经验,不提供 advantage | unconditioned mixed policy | 离散动作和连续 flow | token CE + flow matching |
| 6. RECAP extraction | 更新后的 value、重新标注的全部经验 | policy 从 base checkpoint 再训练 | 改进后的 `π*0.6`-style policy | 条件化 token CE + flow matching |
| 7. CFG inference | 同一 observation 分别使用 positive 和 omitted 条件 | 两次 flow 前向 + CFG,默认 `β=2` | guided 连续 action chunk | 与真值及 unguided 输出比较 |
@@ -43,6 +43,11 @@ advantage token 位于 subtask 之后、动作之前,因此它只改变动作
读取 teacher-forced FAST-lite 真值动作。flow loss 对 policy/VLM prefix 使用
stop-gradient,以最小形式模拟论文的 Knowledge Insulation(KI)训练原则。
critic 只读取 observation/state(本单任务实验隐含固定任务提示),不读取
`demo_success`、失败类型或 intervention source 等结果标签。value 训练完成后,
程序会对每条 episode 的所有状态重新运行 critic,并用预测值重新计算 n-step
advantage;最终 RECAP policy 使用该重标注结果,而不是手工 baseline。
## 与 π0.5 最小项目的重点差异
| π0.5 minimal | π0.6 / `π*0.6` minimal |
@@ -66,7 +71,7 @@ width 为 96,value width 为 64;没有复现这些规模和数据改进。
- `autonomous_stop`:中途停止;
- `intervention_correction`:先偏离,再由“人工”轨迹拉回。
默认用 4-step bootstrapped advantage,`gamma=0.99`。训练集的 advantage
默认用 4-step bootstrapped advantage,按论文使用无折扣 return(`gamma=1.0`)。训练集的 advantage
第 70 百分位作为 positive 阈值,即约 30% 普通样本为 positive;intervention
动作无条件标为 positive。这个合成 buffer 只用于检验 RECAP 接口,不能替代
真实机器人 rollout、任务成功标签或在线人工干预。
@@ -120,7 +125,7 @@ python -m pi06mini.train --config configs/overfit.yaml
|---|---:|---|
| base | 300 | 先记住示范的 subtask、FAST-lite 和连续动作 |
| value | 400 | 记住成功、失败和纠正 episode 的 201-bin return |
| mixed | 300 | 让策略学会 positive/negative/omitted 三种条件 |
| mixed | 300 | 训练不带 advantage 的全经验 SFT 对照组 |
| recap | 700 | 使用合成经验中的 n-step advantage 标签与 30% 条件 dropout 提取最终策略 |
训练应保存 checkpoint、每阶段 loss、value/advantage 诊断和最终评估。CPU 可以
@@ -148,6 +153,8 @@ python -m pi06mini.infer --checkpoint outputs/overfit/checkpoint.pt
在极小数据过拟合场景中,目标是看到 value 能区分合成成功/失败,positive 或
CFG 策略比 negative/unguided 更接近专家轨迹。它不代表模型具备泛化能力。
推理链会先由 VLM 预测 subtask token,再将该预测与 advantage indicator 一起
交给连续 action expert,不使用数据集中的真值 subtask 作为低层条件。
## 关键配置