镜像自地址
https://github.com/MINT-SJTU/Evo-RL.git
已同步 2026-11-20 18:17:06 +00:00
support Evo1 policy (#11)
* feat(evo1): integrate evo1 with lerobot training * chore(evo1): drop v21 export and local tests * docs(evo1): add setup notes and keep only 4gpu config * chore(evo1): clean up quality issues * fix(evo1): use batch_size consistently * docs(evo1): add handoff notes * docs(evo1): clarify resume pretrain semantics * fix(evo1): address review follow-ups * docs(evo1): refresh inherited issues note * fix(evo1): update Evo1 model to higher effience * fix(evo1): GPU version of dynamic process and ratio cache * fix(evo1): support stage2 checkpoint resume --------- Co-authored-by: t0mo0n <2423843425@qq.com>
这个提交包含在:
@ -161,8 +161,25 @@ class PreTrainedConfig(draccus.ChoiceRegistry, HubMixin, abc.ABC): # type: igno
|
||||
return None
|
||||
|
||||
def _save_pretrained(self, save_directory: Path) -> None:
|
||||
with open(save_directory / CONFIG_NAME, "w") as f, draccus.config_type("json"):
|
||||
draccus.dump(self, f, indent=4)
|
||||
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)
|
||||
|
||||
@classmethod
|
||||
def from_pretrained(
|
||||
@ -207,16 +224,34 @@ 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)
|
||||
|
||||
config.pop("type")
|
||||
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)
|
||||
with tempfile.NamedTemporaryFile("w+", delete=False, suffix=".json") as f:
|
||||
json.dump(config, f)
|
||||
config_file = f.name
|
||||
|
||||
@ -54,6 +54,9 @@ 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
|
||||
@ -89,6 +92,16 @@ 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")
|
||||
|
||||
在新工单中引用
屏蔽一个用户