mirror of
https://github.com/huggingface/lerobot.git
synced 2026-07-24 18:26:11 +00:00
fix(rl): enhance intervention handling in actor and learner
(cherry picked from commit ef8bfffbd7)
This commit is contained in:
@@ -337,7 +337,7 @@ def act_with_policy(
|
|||||||
|
|
||||||
# Check for intervention from transition info
|
# Check for intervention from transition info
|
||||||
intervention_info = new_transition[TransitionKey.INFO]
|
intervention_info = new_transition[TransitionKey.INFO]
|
||||||
is_intervention = intervention_info.get(TeleopEvents.IS_INTERVENTION, False)
|
is_intervention = bool(intervention_info.get(TeleopEvents.IS_INTERVENTION, False))
|
||||||
if is_intervention:
|
if is_intervention:
|
||||||
episode_intervention = True
|
episode_intervention = True
|
||||||
episode_intervention_steps += 1
|
episode_intervention_steps += 1
|
||||||
@@ -346,7 +346,10 @@ def act_with_policy(
|
|||||||
"discrete_penalty": torch.tensor(
|
"discrete_penalty": torch.tensor(
|
||||||
[new_transition[TransitionKey.COMPLEMENTARY_DATA].get("discrete_penalty", 0.0)]
|
[new_transition[TransitionKey.COMPLEMENTARY_DATA].get("discrete_penalty", 0.0)]
|
||||||
),
|
),
|
||||||
"is_intervention": is_intervention,
|
# Forward the intervention flag so the learner can route this transition
|
||||||
|
# into the offline replay buffer (see `process_transitions` in learner.py).
|
||||||
|
# Use the plain string key so the payload survives torch.load(weights_only=True).
|
||||||
|
TeleopEvents.IS_INTERVENTION.value: is_intervention,
|
||||||
}
|
}
|
||||||
# Create transition for learner (convert to old format)
|
# Create transition for learner (convert to old format)
|
||||||
list_transition_to_send_to_learner.append(
|
list_transition_to_send_to_learner.append(
|
||||||
|
|||||||
@@ -937,7 +937,7 @@ def process_transitions(
|
|||||||
|
|
||||||
# Add to offline buffer if it's an intervention
|
# Add to offline buffer if it's an intervention
|
||||||
if dataset_repo_id is not None and transition.get("complementary_info", {}).get(
|
if dataset_repo_id is not None and transition.get("complementary_info", {}).get(
|
||||||
TeleopEvents.IS_INTERVENTION
|
TeleopEvents.IS_INTERVENTION.value
|
||||||
):
|
):
|
||||||
offline_replay_buffer.add(**transition)
|
offline_replay_buffer.add(**transition)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user