Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions lelab/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,14 @@ def _list_imported_hub(api, repo_id: str) -> list[JobCheckpoint]:
return []


_LANGUAGE_CONDITIONED_POLICY_TYPES = {"smolvla", "pi0", "pi0_fast", "pi05"}
# Policies known to ignore the task string. Everything else (including plugin
# policies we can't enumerate) gets the task field, since an unused task is
# harmless but a missing one makes a language-conditioned policy unusable.
_TASK_FREE_POLICY_TYPES = {"act", "diffusion", "vqbet", "tdmpc", "sac"}


def _policy_requires_task(policy_type: object) -> bool:
return policy_type not in _TASK_FREE_POLICY_TYPES


_HUB_CKPT_REF_RE = re.compile(r"^(?P<repo>[^@]+)@checkpoints/(?P<step_dir>\d+)$")
Expand Down Expand Up @@ -1086,7 +1093,7 @@ def get_policy_config_summary(self, job_id: str, step: int) -> dict[str, object]
return {
"policy_type": policy_type,
"image_features": image_features,
"requires_task": policy_type in _LANGUAGE_CONDITIONED_POLICY_TYPES,
"requires_task": _policy_requires_task(policy_type),
}

def delete(self, job_id: str) -> None:
Expand Down
14 changes: 14 additions & 0 deletions tests/test_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,3 +271,17 @@ def list_repo_files(self, repo_id, repo_type):
assert rec.output_dir == ""
cks = reg.list_checkpoints(rec.id)
assert [c.ref for c in cks] == ["user/some-model@root"]


@pytest.mark.parametrize("policy_type", ["act", "diffusion", "vqbet", "tdmpc", "sac"])
def test_policy_requires_task_false_for_task_free_policies(policy_type: str) -> None:
from lelab.jobs import _policy_requires_task

assert _policy_requires_task(policy_type) is False


@pytest.mark.parametrize("policy_type", ["smolvla", "pi0", "pi05", "groot", "xvla", "some_plugin", None])
def test_policy_requires_task_true_for_language_or_unknown_policies(policy_type: object) -> None:
from lelab.jobs import _policy_requires_task

assert _policy_requires_task(policy_type) is True