feat(lingbot_va): RoboTwin eef-pose eval, single-file model, Hub checkpoints

Make the LingBot-VA port runnable on both LIBERO and RoboTwin and clean up the
package to LeRobot conventions.

- Consolidate all vendored Wan2.2 model code (transformer, attention, VAE helpers,
  flow-matching scheduler, grid utils, flex-attention) into a single
  modeling_lingbot_va.py; remove the separate wan_*/schedulers modules.
- Move the fixed action (un)normalization quantiles out of the config and into the
  post-processor (LIBERO 7-DoF + RoboTwin 16-d eef); remove the conversion script in
  favour of ready-to-use LeRobot-format checkpoints on the Hub.
- Fixes found via on-sim validation: undo LIBERO's 180-degree image flip
  (image_hflip), encode obs as a multi-frame streaming-VAE clip, reset the streaming
  VAE cache between episodes, run the transformer in config.dtype, lazy-load frozen
  VAE/UMT5 by subfolder with the text encoder on CPU.
- RoboTwin: add an end-effector-pose action mode to RoboTwinEnv (16-d per-arm
  xyz+quat+gripper deltas composed onto the initial eef pose, executed via CuRobo IK)
  and the robotwin_tshape latent layout (full-res head + half-res wrists via a second
  streaming VAE) with the upstream RoboTwin action quantiles + camera mapping.
- Predicted-video saving works for both benchmarks; docs + tests updated.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
pepijn223
2026-06-06 15:20:51 +02:00
committed by Maxime Ellerbach
parent d600a52943
commit b81909fc28
20 changed files with 2372 additions and 2834 deletions
@@ -76,8 +76,3 @@ def test_validate_features_no_visual_raises() -> None:
def test_invalid_attn_mode_raises() -> None:
with pytest.raises(ValueError, match="attn_mode"):
make_config(attn_mode="banana")
def test_quantile_length_mismatch_raises() -> None:
with pytest.raises(ValueError, match="action_q01"):
make_config(used_action_channel_ids=[0, 1, 2], action_q01=[0.0, 0.0], action_q99=[1.0, 1.0, 1.0])
-14
View File
@@ -36,17 +36,3 @@ def test_get_policy_class_resolves_lazily() -> None:
cls = get_policy_class("lingbot_va")
assert cls.name == "lingbot_va"
assert cls.config_class is LingBotVAConfig
def test_convert_build_config_libero() -> None:
pytest.importorskip("diffusers")
from lerobot.policies.lingbot_va.convert_lingbot_va_checkpoints import build_config
cfg = build_config("libero", wan_pretrained_path="dummy/path", dtype="float32")
assert cfg.height == 128 and cfg.width == 128
assert cfg.used_action_channel_ids == list(range(7))
# validate_features (called inside build_config) must have populated the action feature.
from lerobot.utils.constants import ACTION
assert cfg.output_features[ACTION].shape == (7,)
assert len(cfg.obs_cam_keys) == 2
+9 -3
View File
@@ -14,14 +14,20 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""Pure-torch unit tests for the vendored LingBot-VA helper modules (no diffusers needed)."""
"""Unit tests for the vendored LingBot-VA helper code (scheduler + grid utilities)."""
from __future__ import annotations
import pytest
import torch
from lerobot.policies.lingbot_va.schedulers import FlowMatchScheduler
from lerobot.policies.lingbot_va.wan_utils import data_seq_to_patch, get_mesh_id
pytest.importorskip("diffusers") # the model code lives in modeling_lingbot_va, which imports diffusers
from lerobot.policies.lingbot_va.modeling_lingbot_va import ( # noqa: E402
FlowMatchScheduler,
data_seq_to_patch,
get_mesh_id,
)
def test_flow_match_scheduler_timesteps_monotone_decreasing() -> None:
+3 -2
View File
@@ -21,6 +21,7 @@ import torch
from lerobot.configs.types import FeatureType, PolicyFeature
from lerobot.policies.lingbot_va.configuration_lingbot_va import LingBotVAConfig
from lerobot.policies.lingbot_va.processor_lingbot_va import (
LIBERO_ACTION_Q01,
LingBotVAActionUnnormalizeStep,
make_lingbot_va_pre_post_processors,
)
@@ -75,7 +76,7 @@ def test_make_pre_post_processors_names_and_steps() -> None:
def test_postprocessor_applies_unnormalization() -> None:
cfg = _make_config()
_, post = make_lingbot_va_pre_post_processors(cfg, dataset_stats=None)
# A normalized action of all -1 should map back to q01.
# A normalized action of all -1 should map back to q01 (the LIBERO 7-DoF default quantiles).
normed = torch.full((1, len(cfg.used_action_channel_ids)), -1.0)
out = post(normed)
assert torch.allclose(out, torch.tensor(cfg.action_q01).unsqueeze(0), atol=1e-4)
assert torch.allclose(out, torch.tensor(LIBERO_ACTION_Q01).unsqueeze(0), atol=1e-4)