test(ci): fix fast tests for ACP config and sarm import guards

- update ACP training tests to use current ACPConfig fields and shared ACP tag constants

- skip sarm subtask annotation tests when Qwen3VLMoe symbol is unavailable in transformers

- keep changes scoped to fast-tests paths and preserve runtime behavior
这个提交包含在:
Elvin
2026-03-04 12:40:04 +08:00
父节点 c96c678772
当前提交 a504d17713
共有 3 个文件被更改,包括 14 次插入 和 21 次删除

查看文件

@ -16,7 +16,12 @@
import pytest
pytest.importorskip("transformers")
transformers = pytest.importorskip("transformers")
if not hasattr(transformers, "Qwen3VLMoeForConditionalGeneration"):
pytest.skip(
"requires transformers with Qwen3VLMoeForConditionalGeneration",
allow_module_level=True,
)
from lerobot.data_processing.sarm_annotations.subtask_annotation import (
Subtask,

查看文件

@ -9,6 +9,7 @@ from lerobot.configs.types import FeatureType, PolicyFeature
from lerobot.policies.pi05.configuration_pi05 import PI05Config
from lerobot.policies.pi05.processor_pi05 import make_pi05_pre_post_processors
from lerobot.rl.acp_hook import build_acp_raw_batch_hook
from lerobot.rl.acp_tags import ACP_NEGATIVE_TAG, ACP_POSITIVE_TAG
from lerobot.utils.constants import OBS_LANGUAGE_ATTENTION_MASK, OBS_LANGUAGE_TOKENS
from tests.utils import require_package
@ -78,8 +79,6 @@ def test_acp_prompt_reaches_pi05_tokenizer(mock_auto_tokenizer):
ACPConfig(
enable=True,
indicator_field="complementary_info.acp_indicator",
positive_tag="Advantage: positive",
negative_tag="Advantage: negative",
indicator_dropout_prob=0.0,
),
seed=123,
@ -101,8 +100,8 @@ def test_acp_prompt_reaches_pi05_tokenizer(mock_auto_tokenizer):
prompts = tracking_tokenizer.calls[-1]
assert len(prompts) == 2
assert "Advantage: positive" in prompts[0]
assert "Advantage: negative" in prompts[1]
assert ACP_POSITIVE_TAG in prompts[0]
assert ACP_NEGATIVE_TAG in prompts[1]
assert prompts[0].startswith("Task: Pick bottle")
assert "State:" in prompts[0]
assert OBS_LANGUAGE_TOKENS in out

查看文件

@ -7,6 +7,7 @@ from torch.utils.data import DataLoader
from lerobot.configs.train import ACPConfig
from lerobot.datasets.lerobot_dataset import LeRobotDataset
from lerobot.rl.acp_hook import build_acp_raw_batch_hook
from lerobot.rl.acp_tags import ACP_NEGATIVE_TAG, ACP_POSITIVE_TAG
def test_acp_hook_accepts_integer_indicators():
@ -14,8 +15,6 @@ def test_acp_hook_accepts_integer_indicators():
ACPConfig(
enable=True,
indicator_field="acp_indicator",
positive_tag="POS",
negative_tag="NEG",
indicator_dropout_prob=0.0,
),
seed=42,
@ -27,8 +26,8 @@ def test_acp_hook_accepts_integer_indicators():
out = hook(batch, 0)
assert out["task"] == [
"pick bottle\nPOS",
"place bottle\nNEG",
f"pick bottle\n{ACP_POSITIVE_TAG}",
f"place bottle\n{ACP_NEGATIVE_TAG}",
]
@ -37,8 +36,6 @@ def test_acp_hook_injects_tags():
ACPConfig(
enable=True,
indicator_field="complementary_info.acp_indicator",
positive_tag="POS",
negative_tag="NEG",
indicator_dropout_prob=0.0,
),
seed=42,
@ -49,7 +46,7 @@ def test_acp_hook_injects_tags():
}
out = hook(batch, 0)
assert out["task"] == ["pick bottle\nPOS", "place bottle\nNEG"]
assert out["task"] == [f"pick bottle\n{ACP_POSITIVE_TAG}", f"place bottle\n{ACP_NEGATIVE_TAG}"]
def test_acp_hook_dropout_keeps_original_task():
@ -57,8 +54,6 @@ def test_acp_hook_dropout_keeps_original_task():
ACPConfig(
enable=True,
indicator_field="complementary_info.acp_indicator",
positive_tag="POS",
negative_tag="NEG",
indicator_dropout_prob=1.0,
),
seed=42,
@ -87,8 +82,6 @@ def test_acp_hook_non_integer_type_raises():
ACPConfig(
enable=True,
indicator_field="acp_indicator",
positive_tag="POS",
negative_tag="NEG",
indicator_dropout_prob=0.0,
),
seed=42,
@ -106,8 +99,6 @@ def test_acp_hook_non_binary_value_raises():
ACPConfig(
enable=True,
indicator_field="acp_indicator",
positive_tag="POS",
negative_tag="NEG",
indicator_dropout_prob=0.0,
),
seed=42,
@ -143,8 +134,6 @@ def test_acp_hook_with_real_local_dataset_batch(batch_size: int):
ACPConfig(
enable=True,
indicator_field="complementary_info.acp_indicator",
positive_tag="POS",
negative_tag="NEG",
indicator_dropout_prob=0.0,
),
seed=42,
@ -153,5 +142,5 @@ def test_acp_hook_with_real_local_dataset_batch(batch_size: int):
assert len(out["task"]) == batch_size
for i in range(batch_size):
expected_tag = "POS" if int(indicators[i].item()) == 1 else "NEG"
expected_tag = ACP_POSITIVE_TAG if int(indicators[i].item()) == 1 else ACP_NEGATIVE_TAG
assert out["task"][i].endswith(expected_tag)