fix: remove evo1 hardcodes and unused resume_pretrain from public code

Public training code should be policy-agnostic. This removes:
- resume_pretrain config field (pretrained_path without --resume already
  provides the same "load weights, fresh optimizer" behavior)
- evo1-specific DDP static graph and stage2 logging in lerobot_train.py
- drop_last sourced from policy config (DataLoader concern, not policy)
- type-inference fallback in PreTrainedConfig that was added to handle
  evo1 checkpoints missing a "type" field

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
这个提交包含在:
Elvinyk
2026-04-12 17:55:27 +08:00
父节点 ddb0738a76
当前提交 bd3d1fc549
共有 3 个文件被更改,包括 8 次插入 和 72 次删除

查看文件

@ -161,25 +161,8 @@ class PreTrainedConfig(draccus.ChoiceRegistry, HubMixin, abc.ABC): # type: igno
return None
def _save_pretrained(self, save_directory: Path) -> None:
with tempfile.NamedTemporaryFile("w+", delete=False, suffix=".json") as tmp, draccus.config_type("json"):
draccus.dump(self, tmp, indent=4)
tmp_path = tmp.name
with open(tmp_path) as f:
config = json.load(f)
if "type" not in config:
matching_choices = [
name for name in self.get_known_choices() if self.get_choice_class(name) is self.__class__
]
if len(matching_choices) != 1:
raise ValueError(
f"Expected exactly one registered choice for {self.__class__.__name__}, got {matching_choices}"
)
config["type"] = matching_choices[0]
with open(save_directory / CONFIG_NAME, "w") as f:
json.dump(config, f, indent=4)
with open(save_directory / CONFIG_NAME, "w") as f, draccus.config_type("json"):
draccus.dump(self, f, indent=4)
@classmethod
def from_pretrained(
@ -224,34 +207,16 @@ class PreTrainedConfig(draccus.ChoiceRegistry, HubMixin, abc.ABC): # type: igno
# apply cli overrides.
# This is very ugly, ideally we'd like to be able to do that natively with draccus
# something like --policy.path (in addition to --policy.type)
with draccus.config_type("json"):
orig_config = draccus.parse(cls, config_file, args=[])
if config_file is None:
raise FileNotFoundError(f"{CONFIG_NAME} not found in {model_id}")
with open(config_file) as f:
config = json.load(f)
if "type" in config:
with draccus.config_type("json"):
orig_config = draccus.parse(cls, config_file, args=[])
else:
parse_successes = []
for choice_name in cls.get_known_choices():
config_cls = cls.get_choice_class(choice_name)
try:
with draccus.config_type("json"):
parsed_config = draccus.parse(config_cls, config_file, args=[])
except Exception:
continue
parse_successes.append((choice_name, parsed_config))
if len(parse_successes) != 1:
raise ValueError(
f"Expected to infer exactly one policy type from {config_file}, got "
f"{[choice for choice, _ in parse_successes]}"
)
orig_config = parse_successes[0][1]
config.pop("type", None)
config.pop("type")
with tempfile.NamedTemporaryFile("w+", delete=False, suffix=".json") as f:
json.dump(config, f)
config_file = f.name

查看文件

@ -54,9 +54,6 @@ class TrainPipelineConfig(HubMixin):
# Note that when resuming a run, the default behavior is to use the configuration from the checkpoint,
# regardless of what's provided with the training command at the time of resumption.
resume: bool = False
# `resume_pretrain` mirrors Evo-1's stage2 handoff semantics: initialize from policy weights only while
# starting a fresh training run with a new optimizer, scheduler and step counter.
resume_pretrain: bool = False
# `seed` is used for training (eg: model initialization, dataset shuffling)
# AND for the evaluation environments.
seed: int | None = 1000
@ -92,16 +89,6 @@ class TrainPipelineConfig(HubMixin):
def validate(self) -> None:
# HACK: We parse again the cli args here to get the pretrained paths if there was some.
policy_path = parser.get_path_arg("policy")
if self.resume and self.resume_pretrain:
raise ValueError("'resume' and 'resume_pretrain' are mutually exclusive.")
if self.resume_pretrain and not policy_path and (
self.policy is None or self.policy.pretrained_path is None
):
raise ValueError(
"'resume_pretrain=true' expects weights via '--policy.path' or 'policy.pretrained_path'."
)
if policy_path:
# Only load the policy config
cli_overrides = parser.get_cli_overrides("policy")