Skip to content

perf(motion): 固定五个 update_state 热点改为 Numba-only - #1309

Merged
TATP-233 merged 1 commit into
dev/issue-1304-motion-numba-body-statefrom
perf/issue-1306-motion-hot-numba
Aug 25, 2026
Merged

perf(motion): 固定五个 update_state 热点改为 Numba-only#1309
TATP-233 merged 1 commit into
dev/issue-1304-motion-numba-body-statefrom
perf/issue-1306-motion-hot-numba

Conversation

@TATP-233

Copy link
Copy Markdown
Collaborator

Summary

  • Replace termination/anchor_pos and the four motion_body_* rewards with pre-warmed njit(nogil=True, parallel=True) kernels.
  • Keep the four reward formulas Numba-only in the production call graph; NumPy expressions remain only as test oracles.
  • Reuse caller-owned result buffers and preserve body subset, dtype, input immutability, and manager class-term contracts.
  • Add Numba as a runtime dependency.

Linked Work

Validation

  • make check
  • uv run pytest -m "not slow"
  • make test-all
  • Three-backend 8192-env benchmark, warmup 10 / measure 100, 3 runs per side, median of run means

Commands actually run:

make test-all
uv run --no-sync scripts/benchmark/rl/benchmark_offpolicy_collector_active.py --cases sac/g1_motion_tracking/mujoco --num-envs 8192 --warmup-steps 10 --measure-steps 100
uv run --no-sync scripts/benchmark/rl/benchmark_offpolicy_collector_active.py --cases sac/g1_motion_tracking/motrixsim --num-envs 8192 --warmup-steps 10 --measure-steps 100
uv run --no-sync --extra mjwarp scripts/benchmark/rl/benchmark_offpolicy_collector_active.py --cases sac/g1_motion_tracking/mjwarp --num-envs 8192 --warmup-steps 10 --measure-steps 100

make test-all result: 2294 passed, 27 skipped, 281 deselected, 1 xfailed; ruff, mypy, pyright, and benchmark smoke passed.

Maintainer override: local make test-all only; remote CI is intentionally not awaited or required for this roadmap.

Benchmark

Same host: Ryzen 9 9950X3D, RTX 4090. Values are before → after.

Backend update_state ms reset_done ms env/s
MuJoCo 29.766 → 25.778 (-13.4%) 7.031 → 7.077 (+0.6%) 70,297 → 73,628 (+4.7%)
Motrix 38.648 → 35.782 (-7.4%) 12.942 → 13.837 (+6.9%) 65,423 → 66,543 (+1.7%)
MJWarp 28.704 → 25.323 (-11.8%) 14.916 → 14.971 (+0.4%) 122,524 → 130,895 (+6.8%)

reset_done is not modified by this child. MuJoCo/MJWarp are flat; the Motrix delta tracks reset-count/backend run variance and is reported without claiming a reset improvement.

Impact

  • Backend impact: mujoco / motrix / mjwarp
  • Platform impact: Linux CPU hot path; Numba thread env overrides are respected
  • Training effect expected: same reward/termination semantics with lower update_state CPU cost
  • Configuration and runner/lifecycle behavior: unchanged

Artifacts

  • benchmark result: local gitignored JSON/CSV, 18 runs total
  • W&B/video/ONNX/checkpoint: not applicable

Checklist

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