Skip to content

feat(motrix): document and test cpu_ids worker affinity wiring (#962) - #1634

Merged
TATP-233 merged 2 commits into
mainfrom
feat/issue-962-motrix-cpu-affinity
Sep 23, 2026
Merged

TATP-233 merged 2 commits into
mainfrom
feat/issue-962-motrix-cpu-affinity

Conversation

@TATP-233

Copy link
Copy Markdown
Collaborator

Summary

Closes the UniLab side of #962 (Motrix worker CPU affinity). The upstream pieces are already delivered and locked in this repo:

  • motrixsim-core==0.10.1 (uv.lock) exposes motrixsim.init_thread_pool(core_ids=...).
  • unisim-core==1.7.4 (uv.lock; feat: add Motrix worker CPU affinity and upgrade motrixsim-core to 0.10.1 unilabsim/unisim#235) implements the Motrix adapter: cold-path cpu_ids validation mirroring the MuJoCo BatchEnvPool contract, init_thread_pool pinning before the first model load, and a read-only backend.cpu_ids property.
  • UniLab already forwards EnvCfg.cpu_ids to every backend via env_backend_kwargs (src/unilab/base/backend_factory.py) and confines the env process via apply_env_cpu_runtime (src/unilab/base/cpu_runtime.py).

What was missing on the UniLab side, delivered here:

  • EnvCfg.cpu_ids docstring generalized beyond MuJoCo to document the Motrix worker-pool pinning (src/unilab/base/base.py).
  • New tests/base/backend/test_motrix_cpu_affinity_wiring.py mirroring the MuJoCo wiring tests: env_backend_kwargs mapping, create_backend routing (direct kwargs and via EnvCfg), cold-path rejection of empty/duplicate/negative/unavailable ids, and the default path leaving the pool untouched. motrixsim.init_thread_pool is mocked because the pool is process-wide and initializable only once; the behavioral per-thread pinning check lives in unisim (tests/adapters/motrix/test_cpu_ids.py, perf(motrix): route get_body_state_w through fused get_link_states + affinity behavioral test unilabsim/unisim#288).
  • Motrix backend user-guide pages (en + zh_CN) document the affinity option.

No hot-path changes: affinity is only validated/applied during backend construction.

Validation

Commands run on the final head:

uv run --no-sync pytest tests/base/backend/test_motrix_cpu_affinity_wiring.py -q
uv run --no-sync pytest tests/base/backend/ tests/base/test_motrix_backend_options.py -q
make check
uv run --no-sync pytest tests/scripts/test_check_docs.py -q
cd docs/sphinx && UNILAB_DOCS_SKIP_AUTODOC=1 uv run --no-project --with-requirements requirements.txt sphinx-build -b html -n source build/html
make test-all

Results:

  • wiring tests: 8 passed
  • make check: ruff/mypy/pyright clean (2 pre-existing viser import warnings)
  • doc checks: 19 passed; sphinx build succeeded with no new warnings
  • make test-all: exit 0 — test-cov suite passed (1518 passed, 28 skipped after pulling the allegro_hand asset pack; the 2 initial smoke failures were missing local meshes, not code) and benchmark smoke 35/35 module-mode + 36/36 script-mode

Impact

  • Backend impact: Motrix adapter wiring tests + docs only; runtime behavior unchanged (the affinity path already ships in unisim-core 1.7.4)
  • Platform impact: Linux (affinity); validation errors are platform-independent
  • Training effect expected: none

Linked work

The unisim-core 1.7.4 Motrix adapter already consumes the forwarded
cpu_ids block (cold-path validation + motrixsim.init_thread_pool pinning).
Close the UniLab-side gap: generalize the EnvCfg.cpu_ids docstring beyond
MuJoCo, pin the env_backend_kwargs/create_backend routing into the Motrix
adapter with wiring tests, and document the option on both Motrix backend
pages.
ubuntu-slim CI exposes a single CPU; hardcoded [0, 1] blocks fail cold-path
validation there. Mirror the MuJoCo wiring tests and derive the block from
sched_getaffinity.
@TATP-233
TATP-233 merged commit b1b0cea into main Sep 23, 2026
8 checks passed
@TATP-233
TATP-233 deleted the feat/issue-962-motrix-cpu-affinity branch September 23, 2026 05:51
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.

feat(motrix): 为 motrixsim 后端增加显式 CPU affinity

1 participant