Skip to content

perf: migrate MotrixSim writes to batched compile_write FFI plan - #45

Open
wlgys8 wants to merge 1 commit into
mainfrom
perf/write-compiler-ffi-plan
Open

wlgys8 wants to merge 1 commit into
mainfrom
perf/write-compiler-ffi-plan

Conversation

@wlgys8

@wlgys8 wlgys8 commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Closes #20

Summary

  • upgrade motrixsim to 0.10.1.dev123565, whose compile_write supports compile-time reset and forward_kinematic flags
  • semantic writes (ctrl targets, body pose/velocities, kp/damping/mass/com/friction overrides, mocap poses) compile into one native WritePlan; each execute scatters in a single FFI call, applies the native reset first when compiled with reset=True, and refreshes kinematics at most once
  • mocap pose declarations expand into per-body interleaved BodyPosition/BodyRotation fields; buffer(name) synthesizes the neutral (N, B, 7) layout as one zero-copy slice, so consumers are unchanged
  • dof-channel writes keep the numpy scatter path but land through the explicit set_dof_pos/set_dof_vel setters: SceneData property projections are read-only copies, so in-place patches never reached the sim state
  • keep compile-time conflict detection for dof and ctrl targets with the existing error messages; native duplicate-channel rejection covers the override fields
  • drop _MultiTargetOp (unused after the migration) and the post-reset op branch (all remaining numpy ops fold into the reset state)

Test plan

  • full workspace suite: 871 passed
  • prek run clean on changed files
  • smoke: cartpole skrl training, shadow-hand / go2 / stewart / manipulator envs step loops

- upgrade motrixsim to 0.10.1.dev123565, whose compile_write supports
  compile-time reset and forward_kinematic flags
- semantic writes (ctrl targets, body pose/velocities, kp/damping/mass/
  com/friction overrides, mocap poses) compile into one native WritePlan;
  each execute scatters in a single FFI call, applies the native reset
  first when compiled with reset=True, and refreshes kinematics at most
  once
- mocap pose declarations expand into per-body interleaved
  BodyPosition/BodyRotation fields; buffer(name) synthesizes the neutral
  (N, B, 7) layout as one zero-copy slice, so consumers are unchanged
- dof-channel writes keep the numpy scatter path but land through the
  explicit set_dof_pos/set_dof_vel setters: SceneData property
  projections are read-only copies, so in-place patches never reached
  the sim state
- keep compile-time conflict detection for dof and ctrl targets with the
  existing error messages; native duplicate-channel rejection covers the
  override fields
- drop _MultiTargetOp (unused after the migration) and the post-reset op
  branch (all remaining numpy ops fold into the reset state)

Closes #20
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.

perf: migrate MotrixSim write compiler to batched compile_write FFI plan

1 participant