diff --git a/docs/cli/list-info.en.md b/docs/cli/list-info.en.md index ae97e35c..0a60668b 100644 --- a/docs/cli/list-info.en.md +++ b/docs/cli/list-info.en.md @@ -11,20 +11,29 @@ genelab list envs genelab list tasks ``` -If an extension is not installed, import it explicitly: +If an extension is not installed as an entry point, import it explicitly: ```bash PYTHONPATH=examples/inverted_pendulum/src \ genelab --import genelab_inverted_pendulum.tasks list tasks ``` -## Inspect a task +To see only the bundled asset zoo (skip user-installed entry-point extensions): ```bash -genelab info GeneLab-Inverted-Pendulum-v0 +genelab --no-entry-points list robots ``` -The task view includes: +## Inspect any registered name + +```bash +genelab info GeneLab-Inverted-Pendulum-v0 # task +genelab info CartPole-Env-v0 # env +genelab info anymal_c # robot +``` + +`info` does not require you to know which registry the name belongs to. Task views additionally +include: | Section | Meaning | |---|---| @@ -32,6 +41,9 @@ The task view includes: | Task config | `TaskCfg` summary: env, robot, trainable flag, agent. | | Overridable paths | Dotted paths accepted by `play` and `train`. | +If the inspected task needs an asset that isn't cached yet, `info` fetches it inline behind the +same progress bar used by `play` / `train` / `asset download`. + ## Use copied override paths ```bash @@ -39,9 +51,11 @@ genelab play GeneLab-Inverted-Pendulum-v0 \ --env.rewards_cfg.pole_upright.weight 4.0 ``` -When `play_env` exists, play-mode shortcut flags target `play_env`; explicit paths remain explicit. +When `play_env` exists, play-mode shortcut flags (`--vis` / `--gpu` / `--dt` / `--steps`) target +`play_env`; explicit dotted paths still write the exact subtree you spelled. ## See also - [Configuration Reference](../reference/configuration.md) - [CLI Reference](../reference/cli.md) +- [Asset zoo](../concepts/asset_zoo.md) diff --git a/docs/cli/list-info.zh.md b/docs/cli/list-info.zh.md index b5bb671b..82365f24 100644 --- a/docs/cli/list-info.zh.md +++ b/docs/cli/list-info.zh.md @@ -10,20 +10,28 @@ genelab list envs genelab list tasks ``` -如果扩展尚未安装,显式导入: +如果扩展尚未通过 entry point 安装,显式导入: ```bash PYTHONPATH=examples/inverted_pendulum/src \ genelab --import genelab_inverted_pendulum.tasks list tasks ``` -## 查看任务 +要只看随包 asset zoo(不加载用户已安装的扩展),加 `--no-entry-points`: ```bash -genelab info GeneLab-Inverted-Pendulum-v0 +genelab --no-entry-points list robots ``` -任务视图包括: +## 查看任意已注册名字 + +```bash +genelab info GeneLab-Inverted-Pendulum-v0 # task +genelab info CartPole-Env-v0 # env +genelab info anymal_c # robot +``` + +`info` 不要求事先知道是哪一类。Task 视图额外包含: | 区域 | 含义 | |---|---| @@ -31,6 +39,9 @@ genelab info GeneLab-Inverted-Pendulum-v0 | 任务配置 | `TaskCfg` 摘要:env、robot、trainable、agent。 | | 可覆盖路径 | `play` 和 `train` 接受的 dotted path。 | +若该 task 需要的 asset 尚未缓存,`info` 会即时下载并显示进度条 +(和 `play` / `train` / `asset download` 走的是同一条 progress UI)。 + ## 使用复制出的 override 路径 ```bash @@ -38,9 +49,11 @@ genelab play GeneLab-Inverted-Pendulum-v0 \ --env.rewards_cfg.pole_upright.weight 4.0 ``` -当 task 有 `play_env` 时,play 模式短标志会作用到 `play_env`;显式路径仍保持显式语义。 +当 task 提供 `play_env` 时,play 模式下的简写 flag(`--vis` / `--gpu` / `--dt` / +`--steps`)会作用到 `play_env`;显式的 dotted 路径仍按字面写的子树生效。 ## 另见 - [配置参考](../reference/configuration.md) - [CLI 参考](../reference/cli.md) +- [Asset zoo](../concepts/asset_zoo.md) diff --git a/docs/cli/overview.en.md b/docs/cli/overview.en.md index afe339be..31d2fc6c 100644 --- a/docs/cli/overview.en.md +++ b/docs/cli/overview.en.md @@ -12,10 +12,21 @@ genelab [global options] [arguments] | Area | Commands | |---|---| -| Registry discovery | `list robots`, `list envs`, `list tasks`, `info NAME` | -| Runtime | `play TASK`, `train TASK` | +| Registry | `list robots\|envs\|tasks`, `info NAME`, `asset list\|info\|download\|purge` | +| Runtime | `play TASK`, `train TASK`, `eval TASK CHECKPOINT`, `export TASK CHECKPOINT`, `benchmark --suite ...` | +| Project | `project new NAME` | | Utilities | `cache`, `prof open` | -| Project scaffolding | `project new NAME` | + +Running `genelab` with no subcommand prints a landing page with quickstart commands and a count of +registered robots / envs / tasks. + +## Global options + +| Option | Meaning | +|---|---| +| `--version` | Print the version and exit. | +| `--import MODULE` | Import an extension module before dispatch; repeatable. | +| `--no-entry-points` | Skip extensions from the `genelab.extensions` entry-point group. | ## Extension loading order @@ -30,7 +41,7 @@ Use entry points for daily work and `--import` for local experiments. ## Overrides Runtime commands accept unknown `--a.b.c VALUE` options after the task id. The CLI forwards them to -`apply_overrides`. +`apply_overrides`: ```bash genelab play TASK_ID --env.simulation.dt 0.005 @@ -48,3 +59,4 @@ When stdin is a TTY, the CLI can prompt for a missing task id, unknown registry - [CLI Reference](../reference/cli.md) - [Discovery: list and info](list-info.md) - [Play and Train](play-train.md) +- [Eval and export](../concepts/eval-and-export.md) diff --git a/docs/cli/overview.zh.md b/docs/cli/overview.zh.md index 6916f131..d6ad9aa3 100644 --- a/docs/cli/overview.zh.md +++ b/docs/cli/overview.zh.md @@ -1,6 +1,7 @@ # CLI 总览 -`genelab` CLI 是注册表和任务配置上的薄调度层。它不拥有任务逻辑;它负责发现扩展、解析已注册对象、应用 override,然后调用 task 或 runner。 +`genelab` CLI 是注册表(registry)与任务配置之上的薄分发层。它不持有 task 逻辑—— +发现扩展、解析已注册对象、应用 override,然后调用 task 或 runner。 ## 命令模型 @@ -8,40 +9,53 @@ genelab [全局选项] <命令> [参数] ``` -| 区域 | 命令 | +| 分组 | 命令 | |---|---| -| 注册表发现 | `list robots`、`list envs`、`list tasks`、`info NAME` | -| 运行时 | `play TASK`、`train TASK` | -| 工具 | `cache`、`prof open` | -| 项目骨架 | `project new NAME` | +| Registry | `list robots\|envs\|tasks`、`info NAME`、`asset list\|info\|download\|purge` | +| Runtime | `play TASK`、`train TASK`、`eval TASK CHECKPOINT`、`export TASK CHECKPOINT`、`benchmark --suite ...` | +| Project | `project new NAME` | +| Utilities | `cache`、`prof open` | + +不带子命令运行 `genelab` 会打印 landing 页:包含 quickstart 命令以及已注册的 +robots / envs / tasks 数量。 + +## 全局选项 + +| 选项 | 含义 | +|---|---| +| `--version` | 打印版本并退出。 | +| `--import MODULE` | 分发前导入扩展模块;可重复。 | +| `--no-entry-points` | 跳过 `genelab.extensions` entry point 组的扩展。 | ## 扩展加载顺序 -任何需要注册表数据的命令都会按顺序加载: +每个需要 registry 数据的命令按以下顺序加载扩展: -1. 通过 `load_bundled_asset_zoo()` 加载随包 asset zoo robot。 -2. 已安装的 `genelab.extensions` entry point,除非设置 `--no-entry-points`。 -3. 重复传入的显式 `--import MODULE`。 +1. 通过 `load_bundled_asset_zoo()` 装入随包的 asset zoo 机器人。 +2. 已安装的 `genelab.extensions` entry points(除非传 `--no-entry-points`)。 +3. 多次显式的 `--import MODULE`。 -日常工作用 entry point,本地实验用 `--import`。 +日常工作用 entry points,临时实验用 `--import`。 ## Overrides -运行时命令在 task id 后接受未知的 `--a.b.c VALUE` 选项。CLI 会把它们转发给 -`apply_overrides`。 +Runtime 命令在 task id 后接受未知的 `--a.b.c VALUE` 选项,由 CLI 转发到 +`apply_overrides`: ```bash genelab play TASK_ID --env.simulation.dt 0.005 ``` -用 `genelab info TASK_ID` 查看有效路径。 +可用路径见 `genelab info TASK_ID`。 ## 交互模式 -stdin 是 TTY 时,CLI 可以为缺失 task id、未知注册表名字、非法 `--agent`、未知 override 路径弹出选择器。CI 和脚本中会直接抛出相同错误。 +当 stdin 是 TTY 时,CLI 可以为缺失的 task id、未知的注册名、非法 `--agent` 或 +未知 override 路径弹出交互选择器;CI 与脚本中则直接抛出同样的错误。 ## 另见 - [CLI 参考](../reference/cli.md) - [发现:list 与 info](list-info.md) - [play 与 train](play-train.md) +- [Eval 与 export](../concepts/eval-and-export.md) diff --git a/docs/cli/play-train.en.md b/docs/cli/play-train.en.md index 51d8a24a..5c49bd41 100644 --- a/docs/cli/play-train.en.md +++ b/docs/cli/play-train.en.md @@ -1,7 +1,8 @@ -# Play and Train +# Runtime: play and train `play` runs a registered task. `train` runs a registered task through a supported runner when the -task provides an agent config. +task provides an agent config. This page also covers the post-training runtime subcommands — +`eval`, `export`, and `benchmark` — which take the same checkpoint produced by `train`. ## Play @@ -23,8 +24,8 @@ The policy options (`--agent`, `--checkpoint`, `--num-envs`, `--prof*`) apply on tasks — those whose play env config is a `ManagerBasedRlEnvCfg`. Non-RL **scene-playback demos** (e.g. `GeneLab-Rubiks-Play-v0`, `GeneLab-Wuji-Hand-Playback-v0`), whose config subclasses the base `ManagerBasedEnvCfg`, run their own built-in playback; passing those -options prints a warning and they are ignored. `--steps` / `--vis` / `--gpu` and dotted -config overrides still apply to both. +options prints a warning and they are ignored. `--steps` / `--vis` / `--headless` / `--gpu` / +`--dt` and dotted config overrides still apply to both. Checkpoint replay: @@ -44,6 +45,19 @@ genelab play TASK_ID \ --checkpoint --headless ``` +## Shortcut flags + +Both `play` and `train` rewrite the following shortcuts into `env.simulation.*` overrides: + +| Shortcut | Override | +|---|---| +| `-v`, `--vis` | `env.simulation.vis=true` | +| `--headless` | `env.simulation.vis=false` (mutually exclusive with `--vis`) | +| `--gpu` | `env.simulation.gpu=true` | +| `--steps N` | play: `env.simulation.steps=N`; train: alias for `--max_iterations N` | +| `--dt SECONDS` | `env.simulation.dt=SECONDS` | +| `--a.b.c VALUE` | Any dotted cfg path | + ## Train ```bash @@ -57,7 +71,38 @@ genelab train TASK_ID --gpus 4 --num_envs 4096 ``` `--num_envs` is total across ranks and must divide evenly by `--gpus`. Use -`--num_envs_per_gpu` for per-rank semantics. +`--num_envs_per_gpu` for per-rank semantics (mutually exclusive with `--num_envs`). +Multi-GPU is RSL-RL only; the first entry automatically relaunches under `torchrun`. + +### In-training eval + +Pass `--eval_every K` to run a deterministic rollout every K iterations. On improvement, the +runner writes `best_model.` into `--log_dir`: + +```bash +genelab train TASK_ID --eval_every 50 --eval_episodes 20 +``` + +| Option | Meaning (default) | +|---|---| +| `--eval_every K` | Evaluate every K iterations. | +| `--eval_episodes N` | Episodes per evaluation (10). | +| `--eval_num_envs N` | Parallel envs during eval (matches training). | +| `--eval_seed N` | RNG seed for the eval rollout (0). | + +### Multi-seed train + +`--seeds 1,2,3` fans out the current `train` invocation into one independent subprocess per seed: + +```bash +genelab train TASK_ID --seeds 1,2,3,4 --parallel 2 --num_envs 4096 +``` + +- `--parallel N` caps concurrency (default 1 — sequential). +- Each child is invoked with `--seed S` and `--log_dir /seed_`. +- Without an explicit `--log_dir`, the parent is + `logs/multi-seed///`. +- If any seed fails, the command exits non-zero. ## RL backends @@ -95,6 +140,47 @@ GENELAB_SB3_DEMO_PATH=/tmp/franka_pp_demos.npz \ --gpu --num-envs 32 --max-iterations 2000000 ``` +## Post-training subcommands + +`eval`, `export`, and `benchmark` all take a registered task plus a checkpoint and reuse the +task's play env config — see [Eval and export](../concepts/eval-and-export.md) for the +conceptual picture and script-level details. + +### Eval + +Deterministic rollout that writes `eval.json` (`return_mean`, `length_mean`, and +`success_rate` if the task publishes `extras['is_success']`): + +```bash +genelab eval TASK_ID logs/.../model_300.pt \ + --num-envs 64 --episodes 100 --out eval.json +``` + +`--deterministic` / `--stochastic` toggles the policy mode; `--max-steps` caps the rollout. + +### Export + +Export the policy as TorchScript or ONNX (per-term scale/clip baked into the model): + +```bash +genelab export TASK_ID logs/.../model_300.pt --format onnx --out policy.onnx +``` + +A sibling `.metadata.json` records the observation schema. + +### Benchmark + +Batch eval driven by a JSON suite, aggregated into one report: + +```bash +genelab benchmark --suite suite.json --out report.json +genelab benchmark --suite suite.json --reference baseline.json --tolerance 0.1 +``` + +`suite.json` is `[{"task": ..., "checkpoint": ..., "episodes": ..., "seed": ..., "num_envs": ...}, ...]`. +With `--reference`, the command compares `return_mean` against the baseline and exits non-zero +when any task drops more than `--tolerance` — usable directly as a CI regression gate. + ## Config overrides Any unknown option after the task id is treated as a dotted config override: @@ -110,3 +196,4 @@ genelab play TASK_ID \ - [Run RL Experiments](../best-practices/rl-experiments.md) - [CLI Reference](../reference/cli.md) - [RL runner](../concepts/rl-runner.md) +- [Eval and export](../concepts/eval-and-export.md) diff --git a/docs/cli/play-train.zh.md b/docs/cli/play-train.zh.md index 1c925e4a..9a629979 100644 --- a/docs/cli/play-train.zh.md +++ b/docs/cli/play-train.zh.md @@ -1,6 +1,8 @@ -# play 与 train +# 运行时:play 与 train `play` 运行已注册任务。`train` 在 task 提供 agent 配置时,通过支持的 runner 训练任务。 +这一页还覆盖训练后用同一个 checkpoint 做 `eval` / `export` / `benchmark` 的几条 +runtime 子命令。 ## Play @@ -16,12 +18,13 @@ genelab play TASK_ID --agent random --steps 128 |---|---| | `zero` | 零动作。未提供 checkpoint 时默认。 | | `random` | `[-1, 1]` 均匀随机动作。 | -| `trained` | 加载 checkpoint 并使用 runner inference policy。 | +| `trained` | 加载 checkpoint 并使用 runner 的 inference policy。 | -策略相关选项(`--agent`、`--checkpoint`、`--num-envs`、`--prof*`)仅适用于 RL 任务,即 play -环境配置为 `ManagerBasedRlEnvCfg` 的任务。对于配置继承自基类 `ManagerBasedEnvCfg` 的非 RL -**场景回放示例**(如 `GeneLab-Rubiks-Play-v0`、`GeneLab-Wuji-Hand-Playback-v0`),将运行其 -自带的回放逻辑;传入这些选项会打印告警并被忽略。`--steps` / `--vis` / `--gpu` 以及点号配置 +策略相关选项(`--agent`、`--checkpoint`、`--num-envs`、`--prof*`)仅适用于 RL 任务, +即 play 环境配置为 `ManagerBasedRlEnvCfg` 的任务。对于配置继承自基类 +`ManagerBasedEnvCfg` 的非 RL **场景回放示例**(如 `GeneLab-Rubiks-Play-v0`、 +`GeneLab-Wuji-Hand-Playback-v0`),将运行其自带的回放逻辑;传入这些选项会打印 +警告并被忽略。`--steps` / `--vis` / `--headless` / `--gpu` / `--dt` 以及点号配置 覆盖对两类任务都生效。 checkpoint 回放: @@ -42,6 +45,19 @@ genelab play TASK_ID \ --checkpoint --headless ``` +## 简写 flag + +`play` 和 `train` 都会把以下简写改写为 `env.simulation.*` override: + +| 简写 | 等价 override | +|---|---| +| `-v`、`--vis` | `env.simulation.vis=true` | +| `--headless` | `env.simulation.vis=false`(与 `--vis` 互斥) | +| `--gpu` | `env.simulation.gpu=true` | +| `--steps N` | play: `env.simulation.steps=N`;train: 等价于 `--max_iterations N` | +| `--dt SECONDS` | `env.simulation.dt=SECONDS` | +| `--a.b.c VALUE` | 任意 dotted cfg path | + ## Train ```bash @@ -55,7 +71,38 @@ genelab train TASK_ID --gpus 4 --num_envs 4096 ``` `--num_envs` 表示所有 rank 的总数,必须能被 `--gpus` 整除。每 rank 语义用 -`--num_envs_per_gpu`。 +`--num_envs_per_gpu`(与 `--num_envs` 互斥)。多 GPU 仅 RSL-RL 后端支持, +首次进入会自动通过 `torchrun` 重启。 + +### 训练中评估 + +加 `--eval_every K` 即可每 K 次迭代跑一次确定性 rollout;如有改进,会把 +`best_model.` 写入 `--log_dir`: + +```bash +genelab train TASK_ID --eval_every 50 --eval_episodes 20 +``` + +| 选项 | 含义(默认) | +|---|---| +| `--eval_every K` | 每 K 次迭代评估一次。 | +| `--eval_episodes N` | 每次评估的回合数(10)。 | +| `--eval_num_envs N` | 评估用的并行 env 数(与训练相同)。 | +| `--eval_seed N` | 评估的 RNG seed(0)。 | + +### 多 seed train + +`--seeds 1,2,3` 把当前 `train` 调用拆成多个独立子进程,每个 seed 一个: + +```bash +genelab train TASK_ID --seeds 1,2,3,4 --parallel 2 --num_envs 4096 +``` + +- `--parallel N` 限制并发数,默认 1(顺序跑)。 +- 每个子进程会被注入 `--seed S` 和 `--log_dir /seed_`。 +- 不显式指定 `--log_dir` 时,父目录是 + `logs/multi-seed///`。 +- 任一 seed 失败,命令以非零状态退出。 ## RL 后端 @@ -90,6 +137,47 @@ GENELAB_SB3_DEMO_PATH=/tmp/franka_pp_demos.npz \ --gpu --num-envs 32 --max-iterations 2000000 ``` +## 训练后的工具命令 + +`eval`、`export`、`benchmark` 都以已注册 task + checkpoint 作为入参,复用 task 的 +play env 配置——理论上的概念与脚本细节见 +[Eval 与 export](../concepts/eval-and-export.md)。 + +### Eval + +确定性 rollout,写出 `eval.json`(包含 `return_mean`、`length_mean`,若 task 暴露 +`extras['is_success']` 则附带 `success_rate`): + +```bash +genelab eval TASK_ID logs/.../model_300.pt \ + --num-envs 64 --episodes 100 --out eval.json +``` + +`--deterministic` / `--stochastic` 切换策略;`--max-steps` 设安全步上限。 + +### Export + +把 policy 导出为 TorchScript 或 ONNX(per-term scale/clip 烘焙进模型): + +```bash +genelab export TASK_ID logs/.../model_300.pt --format onnx --out policy.onnx +``` + +同时写出 `.metadata.json`,记录 obs schema。 + +### Benchmark + +按 JSON 套件批量 eval 并聚合参考数: + +```bash +genelab benchmark --suite suite.json --out report.json +genelab benchmark --suite suite.json --reference baseline.json --tolerance 0.1 +``` + +`suite.json` 是 `[{"task": ..., "checkpoint": ..., "episodes": ..., "seed": ..., "num_envs": ...}, ...]`。 +传 `--reference` 时与 baseline 比 `return_mean`,下降超过 `--tolerance` 视为回归, +命令以非零状态退出——可直接作为 CI 回归门。 + ## 配置 override task id 后的任何未知选项都会被当作 dotted config override: @@ -105,3 +193,4 @@ genelab play TASK_ID \ - [运行 RL 实验](../best-practices/rl-experiments.md) - [CLI 参考](../reference/cli.md) - [RL runner](../concepts/rl-runner.md) +- [Eval 与 export](../concepts/eval-and-export.md) diff --git a/docs/cli/profiling.en.md b/docs/cli/profiling.en.md index 378040f5..eddc8c21 100644 --- a/docs/cli/profiling.en.md +++ b/docs/cli/profiling.en.md @@ -15,21 +15,26 @@ genelab train TASK_ID \ Open traces: ```bash -genelab prof open logs/torch_profile +genelab prof open # defaults to logs/torch_profile +genelab prof open # explicit directory +genelab prof open --port 6007 # custom TensorBoard port +genelab prof open --host 0.0.0.0 ``` ## Flags -| Flag | Meaning | -|---|---| -| `--prof` | Enable profiling. | -| `--prof-out PATH` | Trace output directory. | -| `--prof-wait N` | Initial wait steps. | -| `--prof-warmup N` | Warmup steps before recording. | -| `--prof-active N` | Recorded steps per cycle. | -| `--prof-repeat N` | Number of cycles. | -| `--prof-record-shapes` | Record tensor shapes. | -| `--prof-with-stack` | Capture Python stacks. Higher overhead. | +| Flag | Env-var equivalent | Meaning (default) | +|---|---|---| +| `--prof` | `GENELAB_PROFILE` | Enable profiling. | +| `--prof-out PATH` | `GENELAB_PROFILE_OUT` | TensorBoard trace directory. | +| `--prof-wait N` | `GENELAB_PROFILE_WAIT` | Initial wait steps (10). | +| `--prof-warmup N` | `GENELAB_PROFILE_WARMUP` | Warmup steps before recording (5). | +| `--prof-active N` | `GENELAB_PROFILE_ACTIVE` | Recorded steps per cycle (10). | +| `--prof-repeat N` | `GENELAB_PROFILE_REPEAT` | Number of cycles (2). | +| `--prof-record-shapes` | `GENELAB_PROFILE_RECORD_SHAPES` | Record tensor shapes. | +| `--prof-with-stack` | `GENELAB_PROFILE_WITH_STACK` | Capture Python stacks. Higher overhead. | + +CLI flags always take precedence over the env vars. ## Practical defaults @@ -41,6 +46,11 @@ quickly on large vectorized runs. Only the main process writes profiler traces. Keep `--prof-active` small when profiling distributed training. +## `prof open` prerequisites + +- `tensorboard` must be on `PATH` (`uv pip install tensorboard`, or via this checkout's `rl` extra). +- The directory you pass must exist; an empty directory is fine. + ## See also - [Run RL Experiments](../best-practices/rl-experiments.md) diff --git a/docs/cli/profiling.zh.md b/docs/cli/profiling.zh.md index d22005cf..a295d10e 100644 --- a/docs/cli/profiling.zh.md +++ b/docs/cli/profiling.zh.md @@ -15,30 +15,41 @@ genelab train TASK_ID \ 打开 trace: ```bash -genelab prof open logs/torch_profile +genelab prof open # 默认 logs/torch_profile +genelab prof open # 指定目录 +genelab prof open --port 6007 # 指定 TensorBoard 端口 +genelab prof open --host 0.0.0.0 ``` ## 参数 -| 标志 | 含义 | -|---|---| -| `--prof` | 启用 profiling。 | -| `--prof-out PATH` | trace 输出目录。 | -| `--prof-wait N` | 初始等待步数。 | -| `--prof-warmup N` | 记录前 warmup 步数。 | -| `--prof-active N` | 每个周期记录的步数。 | -| `--prof-repeat N` | 周期数。 | -| `--prof-record-shapes` | 记录 tensor shape。 | -| `--prof-with-stack` | 捕获 Python stack,开销更高。 | +| 标志 | 等价环境变量 | 含义(默认) | +|---|---|---| +| `--prof` | `GENELAB_PROFILE` | 启用 profiling。 | +| `--prof-out PATH` | `GENELAB_PROFILE_OUT` | TensorBoard trace 目录。 | +| `--prof-wait N` | `GENELAB_PROFILE_WAIT` | 初始等待步数(10)。 | +| `--prof-warmup N` | `GENELAB_PROFILE_WARMUP` | 记录前 warmup 步数(5)。 | +| `--prof-active N` | `GENELAB_PROFILE_ACTIVE` | 每个周期记录的步数(10)。 | +| `--prof-repeat N` | `GENELAB_PROFILE_REPEAT` | 周期数(2)。 | +| `--prof-record-shapes` | `GENELAB_PROFILE_RECORD_SHAPES` | 记录 tensor shape。 | +| `--prof-with-stack` | `GENELAB_PROFILE_WITH_STACK` | 捕获 Python stack,开销更高。 | + +命令行 flag 始终优先于环境变量。 ## 实用默认值 -先跑短 profile。GeneLab 的 RL loop 每个 env step 推进一次 profiler step,大规模 vectorized run 的 trace 会增长很快。 +先跑短 profile。GeneLab 的 RL loop 每个 env step 推进一次 profiler step,大规模 +vectorized run 的 trace 会增长很快。 ## 分布式运行 只有 main process 写 profiler trace。profile 分布式训练时保持 `--prof-active` 较小。 +## `prof open` 前置条件 + +- `tensorboard` 必须在 PATH 上(`uv pip install tensorboard`,或本仓库的 `rl` extra)。 +- 指定的目录必须存在;空目录是合法的。 + ## 另见 - [运行 RL 实验](../best-practices/rl-experiments.md) diff --git a/docs/cli/project-new.en.md b/docs/cli/project-new.en.md index bea81543..0dc81cc2 100644 --- a/docs/cli/project-new.en.md +++ b/docs/cli/project-new.en.md @@ -1,7 +1,8 @@ -# Project New +# Project: project new `genelab project new` creates a standalone extension package. Use it for downstream projects rather -than editing `src/genelab/`. +than editing `src/genelab/`. `project` is a Typer subcommand group: `genelab project` (with no +subcommand) lists the available actions. ## Usage @@ -13,10 +14,10 @@ Options: | Option | Description | |---|---| -| `--path PATH`, `-p PATH` | Parent directory for the generated project. | +| `--path PATH`, `-p PATH` | Parent directory for the generated project (default `.`). | | `--package NAME` | Python package name. Defaults to normalized `NAME`. | | `--task-id ID` | Initial task id. Defaults to `-Example-v0`. | -| `--force` | Overwrite scaffold files if the target exists. | +| `--force` | Overwrite scaffold files when the target directory exists and is non-empty. Targets that exist but are not directories still error out. | ## Generated structure @@ -32,6 +33,9 @@ my_robot_project/ └── tasks.py ``` +The generated `pyproject.toml` references the local GeneLab source by relative path +(`tool.uv.sources`), so `uv pip install -e .` works without publishing anything. + ## After scaffolding ```bash @@ -40,6 +44,9 @@ genelab list tasks genelab play MyRobotProject-Example-v0 --steps 3 ``` +If the target directory is non-empty and `--force` is not set, the command exits non-zero without +overwriting any existing file. + ## See also - [Build an Extension Project](../best-practices/extension-projects.md) diff --git a/docs/cli/project-new.zh.md b/docs/cli/project-new.zh.md index 1353b2a7..d16d56c6 100644 --- a/docs/cli/project-new.zh.md +++ b/docs/cli/project-new.zh.md @@ -1,6 +1,7 @@ -# 新建项目 +# 项目:project new `genelab project new` 创建独立扩展包。下游项目应使用它,而不是直接修改 `src/genelab/`。 +`project` 是 Typer 子命令组:`genelab project`(不带子命令)会列出可用动作。 ## 用法 @@ -12,10 +13,10 @@ genelab project new my_robot_project | 选项 | 说明 | |---|---| -| `--path PATH`、`-p PATH` | 生成项目的父目录。 | +| `--path PATH`、`-p PATH` | 生成项目的父目录(默认 `.`)。 | | `--package NAME` | Python 包名,默认由 `NAME` 规范化得到。 | | `--task-id ID` | 初始 task id,默认 `-Example-v0`。 | -| `--force` | 目标已存在时覆盖骨架文件。 | +| `--force` | 目标已存在且非空时覆盖骨架文件;目标存在但非目录时仍会报错。 | ## 生成结构 @@ -31,6 +32,9 @@ my_robot_project/ └── tasks.py ``` +生成的 `pyproject.toml` 通过相对路径 (`tool.uv.sources`) 引用本地 GeneLab 源码, +以便不必发布也能 `uv pip install -e .`。 + ## 生成后 ```bash @@ -39,6 +43,8 @@ genelab list tasks genelab play MyRobotProject-Example-v0 --steps 3 ``` +如果目标目录非空且未传 `--force`,命令会以非零状态退出而不会覆盖现有文件。 + ## 另见 - [构建扩展项目](../best-practices/extension-projects.md) diff --git a/mkdocs.yml b/mkdocs.yml index efefd895..423e0fe7 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -201,11 +201,11 @@ nav: - PointCloudTactileSensor: reference/sensors/tactile_pointcloud.md - API Reference: api/reference.md - CLI: - - Overview: cli/overview.md + - CLI Overview: cli/overview.md - 'Discovery: list and info': cli/list-info.md - - Play and Train: cli/play-train.md + - 'Runtime: play and train': cli/play-train.md - Profiling: cli/profiling.md - - Project New: cli/project-new.md + - 'Project: project new': cli/project-new.md - Concepts: - Registry: concepts/registry.md - Configs: concepts/configs.md diff --git a/pyproject.toml b/pyproject.toml index c8a5a600..f521a29a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -185,12 +185,11 @@ addopts = ["-ra"] pythonpath = ["examples/genelab_examples/src", "examples/unitree/src", "examples/inverted_pendulum/src", "examples/genelab_showcase/src", "examples/franka_pick_and_place/src"] testpaths = ["tests"] -# Layering contracts (ROADMAP §9 PR R0.3 / ADR-0009). +# Layering contracts. # -# Currently runs in CI as a non-required step (`continue-on-error: true`). -# Lint-only mode is the explicit choice for R0–R6: every R-phase that lands -# trims the baseline violation list, and R7 (ADR-0009 §"R7 — flip to blocking") -# converts this job to a required check once the list is empty. +# Currently runs in CI as a non-required step (`continue-on-error: true`) +# until the baseline violation list is empty, at which point this job +# converts to a required check. # # ``exclude_type_checking_imports`` skips ``if TYPE_CHECKING: from ... import`` # blocks. The manager-based MDP design intentionally has domain modules @@ -201,7 +200,7 @@ testpaths = ["tests"] root_packages = ["genelab"] exclude_type_checking_imports = true -# Domain modules must not reach UP into cli / rl. (After R7.3a + R7.3b this is clean.) +# Domain modules must not reach UP into cli / rl. [[tool.importlinter.contracts]] name = "Domain modules are below cli / rl" type = "forbidden" @@ -225,7 +224,7 @@ forbidden_modules = [ # Term logic must not trigger asset downloads. ``asset_zoo`` is the deliberate # exception: it is the asset catalog, so fetching assets via ``utils.download`` -# (a downward domain -> utils import) is its purpose (ADR-0009 / R7.3c). +# (a downward domain -> utils import) is its purpose. [[tool.importlinter.contracts]] name = "Domain (except asset_zoo) does not import utils.download" type = "forbidden" @@ -245,7 +244,7 @@ forbidden_modules = [ "genelab.utils.download", ] -# ADR-0001 / R1: this contract reports violations until the cycle is broken. +# This contract reports violations until the cycle is broken. [[tool.importlinter.contracts]] name = "rl.backends does not import rl.runner" type = "forbidden" @@ -258,7 +257,7 @@ forbidden_modules = ["genelab.rl.runner"] # importlinter treats as mutually *independent* — that wrongly forbids the legitimate # intra-domain imports a manager-based env relies on (envs -> scene, mdp -> managers, # entity -> actuator, …). The contracts below capture "no band imports a band above -# it" while leaving intra-band imports free (ADR-0009 / ROADMAP §9 R7.3d). +# it" while leaving intra-band imports free. # rl sits below cli. [[tool.importlinter.contracts]] @@ -303,7 +302,7 @@ modules = [ "genelab.rl.backends.rsl_rl", ] -# ADR-0014: the contracts band (ports) is dependency-free within genelab — it must +# The contracts band (ports) is dependency-free within genelab — it must # not reach up into the domain / rl / cli bands. (Importing torch / stdlib is fine.) [[tool.importlinter.contracts]] name = "contracts band imports nothing in domain / rl / cli" @@ -325,10 +324,10 @@ forbidden_modules = [ "genelab.envs", ] -# ADR-0014: domain terms type-hint against ``contracts.EnvContext`` rather than the +# Domain terms type-hint against ``contracts.EnvContext`` rather than the # concrete env. Runtime imports of ``genelab.envs`` from the domain are forbidden; # the remaining ``TYPE_CHECKING`` env hints are excluded globally -# (``exclude_type_checking_imports``) and are migrated to ``contracts`` in PR 3.2–3.4. +# (``exclude_type_checking_imports``) and will be migrated to ``contracts``. [[tool.importlinter.contracts]] name = "Domain does not import concrete envs at runtime" type = "forbidden" diff --git a/uv.lock b/uv.lock index 7ea5ef4d..ecf65ba8 100644 --- a/uv.lock +++ b/uv.lock @@ -863,7 +863,7 @@ wheels = [ [[package]] name = "genelab" -version = "0.2.0" +version = "0.3.0" source = { editable = "." } dependencies = [ { name = "genesis-world" },