feat(motrix): document and test cpu_ids worker affinity wiring (#962) - #1634
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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) exposesmotrixsim.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-pathcpu_idsvalidation mirroring the MuJoCoBatchEnvPoolcontract,init_thread_poolpinning before the first model load, and a read-onlybackend.cpu_idsproperty.EnvCfg.cpu_idsto every backend viaenv_backend_kwargs(src/unilab/base/backend_factory.py) and confines the env process viaapply_env_cpu_runtime(src/unilab/base/cpu_runtime.py).What was missing on the UniLab side, delivered here:
EnvCfg.cpu_idsdocstring generalized beyond MuJoCo to document the Motrix worker-pool pinning (src/unilab/base/base.py).tests/base/backend/test_motrix_cpu_affinity_wiring.pymirroring the MuJoCo wiring tests:env_backend_kwargsmapping,create_backendrouting (direct kwargs and viaEnvCfg), cold-path rejection of empty/duplicate/negative/unavailable ids, and the default path leaving the pool untouched.motrixsim.init_thread_poolis 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).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:
Results:
make check: ruff/mypy/pyright clean (2 pre-existing viser import 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-modeImpact
Linked work
BatchEnvPool.cpu_ids), feat: Motrix worker CPU affinity and motrixsim-core 0.10.1 upgrade unilabsim/unisim#234 (upstream adapter), perf(motrix): route get_body_state_w through fused get_link_states + affinity behavioral test unilabsim/unisim#288 (behavioral pinning test)