refactor: 收敛训练入口的重复样板 (#1241) - #1247
Merged
TATP-233 merged 1 commit intoAug 21, 2026
Merged
Conversation
…1241) Move the mechanically duplicated helpers out of the four training entries into the library layer: - run dir naming, algo_config_dict (OmegaConf -> dict), the checkpoint-not-found play diagnostic, and NanGuard wiring now live in src/unilab/training/run.py and are re-exported from unilab.training - run-config snapshot serialization is shared through write_run_config_snapshot in experiment.py; ExperimentTracker and the HORA distill entry both use it, with distill_run_config.json keeping its exact byte format (key order + trailing newline) Entry scripts (train_rsl_rl / train_him_ppo / train_offpolicy / train_appo / play_interactive / play_viser / train_hora_distill) now call the shared helpers. Algo-specific validation stays in the scripts, run dir naming rules and all output file formats are unchanged. Validation: make test-all green.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
Fixes #1241(Part of #1239)。基于 309894b 入口拆分后的现状,base 为
dev/issue-1042-manager-based-api(该拆分尚未合入 main)。改动
库层收敛(
src/unilab/training/):run.py新增共享 helper:build_run_dir_name(run 目录命名)、algo_config_dict(OmegaConf→dict)、format_play_checkpoint_error(checkpoint 未找到诊断)、resolve_nan_guard_cfg/apply_env_nan_guard(NanGuard 接线),并经unilab.training导出。experiment.py新增build_run_config_payload/write_run_config_snapshot;ExperimentTracker.start()的run_config.json与train_hora_distill.py的distill_run_config.json共用同一写入路径,消除第二套快照写入逻辑。入口脚本(train_rsl_rl / train_him_ppo / train_offpolicy / train_appo / play_interactive / play_viser / train_hora_distill)改为调用共享 helper;offpolicy 三个入口(sac/td3/flashsac)经共享实现
train_offpolicy.py一处生效。不做什么(与 issue 一致)
run_slug的命名是不同规则,保留);distill_run_config.jsonkey 顺序与结尾换行已实测保持一致)。Validation
make test-all通过(本地,最终提交内容一致;仅 1 个平台可选 mlx benchmark skip)。_gpux/must resolve to a dict/Could not resolve a checkpoint for play mode/ NanGuardCfg 接线)。tests/scripts/test_train_scripts.py的 monkeypatch 目标与unilab.trainingstub。