Skip to content

feat: internalize bench scripts as the mxlab bench command - #164

Merged
wlgys8 merged 1 commit into
mainfrom
bench-cli
Nov 9, 2026
Merged

wlgys8 merged 1 commit into
mainfrom
bench-cli

Conversation

@wlgys8

@wlgys8 wlgys8 commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • 将 bench/bench_env.py 与 bench/bench_physics.py 内化为统一 CLI 命令 mxlab bench:
    • mxlab bench --mode env --env cartpole --duration 5 — env.step() 吞吐/延迟基准(NUMA shard 多 worker 共享测量窗口)
    • mxlab bench --mode physics --robot g1-29dof --numa shard — MotrixSim 纯物理 step_n 基准(numactl 绑定 worker)
  • 测量逻辑迁入 motrixlab/src/motrixlab/benchmark/(runner/workload/report/physics),CLI 解析在 motrixlab/commands/bench.py
  • env 模式的 train/play 参数改名为 --env-mode,让出 --mode 作为基准目标选择;--numa choices 取并集、按 mode 校验
  • physics 模式懒加载(env 模式及 shard 父进程不 import motrixsim);physics worker 改为 python -m motrixlab.commands.bench 再执行
  • 修复旧 bug:DirectEnv(torch 前端)此前收到 numpy actions 会 copy_() 报错,现与 ManagerEnv 一律转 zero-copy tensor
  • bench_live_metrics.py 为内部诊断工具,保留为独立脚本;bench/README.md 更新指向新命令

Test evidence

  • python -m pytest tests/test_bench_*.py motrixlab/tests -q → 38 passed(含 spawn 集成 3 个)
  • mxlab bench --mode env --env cartpole --steps 50 --num-envs 64 / --duration 3 --numa single / --env-mode play 真实运行正常
  • mxlab bench --mode physics --num-envs 64 / --numa node 真实运行正常(本机单 NUMA,node 模式 no-op 提示符合预期)
  • prek run --all-files 相关文件全绿
  • mxlab bench --mode env --numa node 正确报错 --numa node/_worker only apply to --mode physics

Move bench_env.py and bench_physics.py into the motrixlab CLI as
`mxlab bench --mode env` and `mxlab bench --mode physics`, with the
measurement logic living in motrixlab.benchmark. The env-mode train/play
option becomes --env-mode to free the --mode name for the benchmark
target. Physics mode re-executes its NUMA workers via python -m and both
heavy modes are imported lazily so env mode stays lightweight.

Also fix actions passed to DirectEnv as numpy arrays: both Direct and
Manager torch frontends now receive a zero-copy tensor view.

bench_live_metrics.py stays a standalone diagnostic script.
@wlgys8
wlgys8 merged commit 1ddbb5d into main Nov 9, 2026
12 checks passed
@wlgys8
wlgys8 deleted the bench-cli branch November 9, 2026 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant