mirror of
https://github.com/huggingface/lerobot.git
synced 2026-07-10 11:31:57 +00:00
refactor(runtime): template-method adapter base + policy registry; rename CLI
Make the policy adapter architecturally clean and set up a single general entry point for any language-conditioned policy. Adapter architecture (Template Method): - New lerobot/runtime/adapter.py: BaseLanguageAdapter owns the generic control loop (throttle → generate → gibberish/empty reject → subtask→memory cascade → diagnostics) and plan_from_text/handle_interjection. A policy supplies only select_action + generate_text + build_messages. The subtask→memory cascade is an overridable hook (_regenerate_context). - GenerationConfig (typed, constructor-time) replaces config smuggled through RuntimeState.extra (temperature/top_p/min_new_tokens/chunks_per_regen). - LanguageDiagnostics (typed, keyed by kind) replaces ~8 loose state.extra counter keys; the panel reads it via the adapter. - looks_like_gibberish + split_plan_and_say move to runtime (generic). Contract: - LanguageConditionedPolicyAdapter protocol now states the true contract (select_action, update_language_state, handle_interjection); the runtime drops both getattr fallbacks. - PI052PolicyAdapter shrinks to just its primitives (132 → ~half). General entry point: - lerobot/runtime/registry.py maps policy type → adapter (lazy import). - run() resolves the adapter from the registry by policy type and defaults the panel label to it, so one CLI serves every policy. - Rename lerobot-pi052-runtime → lerobot-language-runtime (general script); a new policy just registers its adapter, no new script. Tests: new tests/runtime/test_adapter.py covers throttle/reject/cascade/ interjection; adapter + runtime + CLI-smoke tests updated for the new shape. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
+2
-2
@@ -346,8 +346,8 @@ lerobot-edit-dataset="lerobot.scripts.lerobot_edit_dataset:main"
|
||||
lerobot-setup-can="lerobot.scripts.lerobot_setup_can:main"
|
||||
lerobot-annotate="lerobot.scripts.lerobot_annotate:main"
|
||||
lerobot-rollout="lerobot.scripts.lerobot_rollout:main"
|
||||
# Interactive hierarchical-VLA runtime for PI052 (PaliGemma backbone).
|
||||
lerobot-pi052-runtime="lerobot.scripts.lerobot_pi052_runtime:main"
|
||||
# Interactive high/low-level runtime for language-conditioned policies (pi052, ...).
|
||||
lerobot-language-runtime="lerobot.scripts.lerobot_language_runtime:main"
|
||||
|
||||
# ---------------- Tool Configurations ----------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user