Skip to content

perf(mjwarp): reduce g1 motion tracking reset latency - #1327

Merged
TATP-233 merged 1 commit into
dev/issue-1304-motion-numba-body-statefrom
perf/issue-1325-mjwarp-reset
Aug 26, 2026
Merged

perf(mjwarp): reduce g1 motion tracking reset latency#1327
TATP-233 merged 1 commit into
dev/issue-1304-motion-numba-body-statefrom
perf/issue-1325-mjwarp-reset

Conversation

@TATP-233

Copy link
Copy Markdown
Collaborator

Summary

  • Scale the MJWarp reset scratch allocation on the cold path (128/256/512 worlds by batch size, capped at 512) so the 8192-env motion-tracking workload stays on the bounded sparse-forward route for its usual ~250 reset rows.
  • Add MJWarp selected-row world body pose/velocity getters, matching the existing SimBackend row contract and avoiding full-batch cache materialization during MotionCommand partial reset.
  • Preserve the existing full-forward path for oversized resets and all eager/graph-disabled fallback behavior; MuJoCo, task config, runner, learner, and lifecycle code are unchanged.

Linked Work

Scope and governance

  • Owner layer: src/unilab/base/backend/mjwarp/ and focused backend tests only.
  • No new public contract, task/config change, runner/lifecycle path, or other backend change.
  • The PR is intentionally not configured for auto-merge; maintainer review and manual merge are required.
  • This PR targets the declared dev integration branch, not main; per the governance update in PR docs: streamline roadmap and PR governance #1313, the local make test-all result is the child-PR gate.

Validation

  • Focused host-cache/CUDA-graph/smoke tests
  • Real CUDA MJWarp slow tests and short differential tests
  • make test-all
  • git diff --check

Commands actually run:

uv run pytest -q tests/base/test_mjwarp_host_cache.py tests/base/test_mjwarp_cuda_graph.py tests/base/test_sim_backend_smoke.py
uv run --extra mjwarp pytest -q -m slow tests/base/test_mjwarp_backend.py tests/base/test_mjwarp_cuda_graph.py tests/base/test_mjwarp_host_cache.py tests/base/test_mjwarp_differential.py tests/base/test_mjwarp_capabilities.py tests/base/test_backend_conformance.py
make test-all
git diff --check

Results:

  • Focused tests: 40 passed.
  • MJWarp CUDA/differential set: 19 passed, 45 deselected.
  • make test-all: 2316 passed, 28 skipped, 281 deselected, 1 xfailed; benchmark smoke 33/34 module-mode and 34/35 script-mode (the one skip in each is platform-optional MLX).
  • Static checks inside make test-all: ruff, mypy (247 source files), and pyright all passed.

Performance evidence

Same-host SAC g1_motion_tracking, 8192 envs, 10 warmup + 100 measured vector steps, using benchmark_offpolicy_collector_active.py:

Metric Baseline (issue investigation) This branch
collector active throughput 184,852 env/s 229,587 env/s
env step 42.553 ms 33.995 ms
reset_done 14.501 ms 5.859 ms
reset_done_reset_call 14.348 ms 5.708 ms
reset rows / vector step 251.59 251.4
MJWarp set_state 5.995 ms 1.572 ms
MJWarp reset forward sub-item 5.206 ms 1.276 ms

The final run selected a 512-world scratch data for the 8192 batch; the measured reset-row population remained below that bound. MuJoCo source behavior is unchanged; in the paired final run its reset_done was 6.643 ms and throughput 85,497 env/s (within run-to-run variation of the investigation baseline).

Impact

  • Backend impact: MJWarp only; MuJoCo/Motrix code paths are unchanged.
  • Platform impact: Linux/CUDA MJWarp path; CPU-only and graph-disabled paths retain their existing fallback.
  • Training effect expected: no change to observations, reset semantics, action/reward dimensions, RNG, or sim2sim configuration; only reset latency should improve for bounded sparse resets.

Checklist

  • Added/updated focused tests for capacity routing, selected-row parity, and no full-batch getter fallback.
  • No documentation or configuration change required.
  • Linked the driving issue.
  • Noted oversized/graph-disabled fallback and manual-merge follow-up.

@TATP-233
TATP-233 merged commit f734cab into dev/issue-1304-motion-numba-body-state Aug 26, 2026
@TATP-233
TATP-233 deleted the perf/issue-1325-mjwarp-reset branch August 26, 2026 19:25
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