# LeRobot PI0.5微调精度策略致性能下降及优化器dtype报错

> 原文链接：https://robotics.hellobike.com/pitfalls/2026-11-06-lerobot-3259
> 频道：pitfalls | 更新日期：2026-11-06 | 标签：auto, github-issue, lerobot
> 核心摘要：LeRobot v0.5.0将vision_tower全量设为fp32导致微调成功率降低4-5%，建议参照openpi仅保留embedding权重为fp32并在模块边界转回bf16以兼容优化器。

# LeRobot PI0.5微调精度策略致性能下降及优化器dtype报错

::: v-pre
> 本文由 AI 根据公开内容整理，可能有误，请以原文为准：[Question: Why does lerobot keep the entire vision_tower in float32, while the original openpi only preserves 3 specific embedding weights?](https://github.com/huggingface/lerobot/issues/3259)（GitHub huggingface/lerobot #3259）

**状态**：有绕过办法

## 问题

LeRobot v0.5.0中`to_bfloat16_for_selected_params`将整个`vision_tower`和`multi_modal_projector`保持fp32，而原版openpi仅保留3个embedding权重。实测该策略导致LIBERO微调成功率比类openpi策略低4-5个百分点。

## 环境

LeRobot v0.5.0及main分支，PI0/PI0.5模型，SigLIP视觉编码器，使用fused或foreach模式的AdamW优化器进行bfloat16训练。

## 解决办法

1. 修改`src/lerobot/policies/pi05/modeling_pi05.py`中的`to_bfloat16_for_selected_params`，移除`vision_tower`与`multi_modal_projector`的全局fp32设定。
2. 采用openpi的白名单策略，仅将`patch_embedding.weight/bias`、`position_embedding.weight`及各类`layernorm`保留为fp32。
3. 在vision tower模块输出边界处显式将fp32 embedding输出cast回bf16，避免优化器因参数组内dtype不一致触发'same dtype'异常。
4. 若需兼顾兼容性，可通过config flag切换两种精度策略，并监控peak VRAM与step time验证收益。

讨论原作者：@XueSongTap 等，版权归原作者所有。
:::

## 原始参考来源 (Sources)

- [GitHub huggingface/lerobot #3259：Question: Why does lerobot keep the entire vision_tower in float32, while the original openpi only preserves 3 specific embedding weights?](https://github.com/huggingface/lerobot/issues/3259)