You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
外部仓库分发实践:以 T800 为例的 unilab 包分发与外迁/新建指南
接续 #1451 的 P0 方向(发布真正可安装的 UniLab 包、降低首次使用门槛),最小外部仓库分发已完成闭环验证并正式化:
unilab 0.1.0—— https://pypi.org/project/unilab/0.1.0/ ;unilab-rl 0.2.0—— https://pypi.org/project/unilab-rl/0.2.0/ ;unisim-core此前已在 PyPI。下游不再需要任何 TestPyPI index 配置(UniLab 侧切换见 chore: switch unilab-rl distribution from TestPyPI to PyPI #1492)。uv sync后 PPO 冒烟训练、headless eval 跑通;SAC 默认参数完整训练跑通并产出 checkpoint(logs/fast_sac/EngineAIT800WalkFlat/)。PYPI_TOKENsecret,ci: publish releases to PyPI instead of TestPyPI unilabsim/unilab_rl#8);版本纪律(public contract 变更至少 minor bump + CHANGELOG)见其 AGENTS.md。外部仓库对接 UniLab 的两个缝(seam)
外部仓库不需要 fork 或 patch UniLab,只需使用两个已存在的扩展点:
UNILAB_EXTRA_REGISTRY_PACKAGES(src/unilab/base/registry.py)让
ensure_registries()在训练主进程和 spawn collector 子进程中额外导入外部任务包;任务包通过
__unilab_registry_modules__声明 leaf 模块,模块内调用registry.register_env_config/registry.register_env完成注册。--config-dir把外部仓库的 conf 目录追加进 UniLab 训练脚本的config search path。实践要点:conf 树按算法分目录(
conf/ppo/、conf/sac/),与 UniLab仓内布局一致;薄 CLI 按
--algo把对应的conf/<algo>注入--config-dir后转发给 wheel 内的
src/unilab/scripts/train_*.py。外部task=<task>/<sim>owner YAML(base.yaml任务声明 +<sim>.yaml后端 owner)直接参与组合。机器人资产策略(实践修正):最初按 UniLab 仓内模式把 mesh/纹理托管 HF、XML 入 git;实际
外迁后发现对外部仓库更省心的做法是全部资产(XML + mesh/纹理)直接入 git,开箱即用,
assets.py的snapshot_download仅作为文件缺失时的 HF 兜底(冷路径)。训练 run 的资产解析相对仓库根 cwd,无需任何下载等待。
指南一:内部已有机器人训练外迁
以 T800 为例(外迁实例:外部仓库
EngineAIT800WalkFlat,仓内删除 PR #1491):src/unilab/tasks/locomotion/<robot>/整目录迁到外部仓库src/<pkg>/tasks/<robot>/。manager terms 中对unilab.envs.mdp、unilab.managers、unilab.utils等公共 API 的 import 不变 —— 这些都在 wheel 里。src/unilab/conf/<algo>/task/<task>/的base.yaml+<sim>.yaml迁到外部仓库src/<pkg>/conf/<algo>/task/<task>/。实践教训:offpolicy 算法族(SAC/TD3/FlashSAC)容易漏迁 —— T800 第一版只迁了 PPO,
后来补齐
conf/sac/(base/mujoco owner + mjwarp 注册)才完整。迁移清单按ls src/unilab/conf/*/task/<task>/全量核对。然后:_target_/func中指向仓内任务模块的 dotted path 改为外部包路径(如
unilab.tasks.locomotion.t800.manager_terms.T800JointPositionActionCfg→
engineai_rl_unilab.tasks.t800.manager_terms.T800JointPositionActionCfg);指向
unilab.envs.mdp.*、unilab.tasks.locomotion.common.*等公共 term 的引用保持不变;env.scene.model_file改为外部仓库相对路径(训练从仓库根启动,cwd 相对解析);training.task_name与registry.register_env*的名字对齐;EngineAI…),避免与仓内同名注册冲突。src/unilab/assets/robots/<robot>/整目录(XML + mesh/纹理)入外部仓库 git。注意保持 robot.xml 为纯机器人描述,
<keyframe>放 task-level scene XML(仓库不变量)。__unilab_registry_modules__;仓库提供一个薄 CLI(参考
engineai_rl_unilab/cli.py,约 100 行)按--algo注入 env var 和--config-dir conf/<algo>后转发给 unilab 的训练脚本。__unilab_registry_modules__条目、conf owner YAML,并同步 support matrix / migration matrix / 相关测试(实例:chore: 移除仓内 T800 任务,完成到 engineai_rl_unilab 的外迁 (#1490) #1491)。
实践教训:删除 commit 不要夹带资产二进制 —— 如果同一提交动了
.gitignore再git add -A,会把本应忽略的资产文件带进历史;一旦发现用git rm -r --cached+ amend修复,不要让大文件污染仓库历史。
指南二:新机器人仓库从零基于 unilab 分发构建
pyproject 依赖 PyPI 分发包(无需任何额外 index):
pip 等价:
pip install "unilab[mujoco]==0.1.0"。注意
[mujoco]extra 里的mujoco-uni-runtime需要对着解析出的 mujoco 版本本机编译(uv 项目需照抄 unilab 的
no-build-isolation-package/no-binary-package设置);torch 走 cu128 index 的
tool.uv.sources配置也要照抄。准备机器人资产:robot.xml 保持纯机器人描述(body/joint/actuator/sensor),
<keyframe>放 task-level scene XML;XML + mesh/纹理全部入 git(或按 UniLab 仓内模式托管 HF + 冷路径下载兜底)。
写任务:Manager-Based 路线下,多数任务只需一份
base.yaml任务声明(obs/action/command/event/termination 组合
unilab.envs.mdp.*公共 term)+每后端一份 owner YAML;机器人专属 term(如 T800 的 hold-joint action)放本仓库
tasks/<robot>/manager_terms.py。要支持多个算法就在conf/<algo>/task/<task>/各备一套。注册 + 薄 CLI:照抄
engineai_rl_unilab的tasks/__init__.py与cli.py模式即可。验证:PPO 冒烟 —
uv run <pkg>-train --algo ppo --task <task> --sim mujoco algo.num_envs=4 algo.max_iterations=2 training.no_play=true training.play_env_num=4。实践教训:offpolicy(SAC)不要用极限缩小的 override 冒烟(过小 num_envs/buffer 会卡在
collector 启动),直接用默认参数短跑确认 checkpoint 落盘即可。
当前边界
unilab/unilab-rl已是 PyPI 正式分发(0.1.0 / 0.2.0),但版本策略仍处早期:外部仓库pin 死
unilab==0.1.0;unilab 公共 API(unilab.envs.mdp、unilab.managers、registry、Hydra 配置契约)的稳定性决定下游维护成本,后续版本演进需要明确的兼容承诺或迁移说明。
owner、资产权限模型仍是开放项。
的模式上试水并反馈缺口。
All reactions