mirror of
https://github.com/huggingface/lerobot.git
synced 2026-07-31 21:49:45 +00:00
feat(env): config to skip the discarded scene rebuild on reset Libero (#4272)
* perf(libero): skip the discarded scene rebuild on reset LIBERO's OffScreenRenderEnv defaults to hard_reset=True, so every reset() frees the MjSim, re-serialises the scene with model.get_xml(), recompiles it with MjSim.from_xml_string(), constructs a fresh offscreen GL context and re-wires every observable. When init states are in use, LiberoEnv.reset() immediately calls set_init_state(), which overwrites the whole sim state -- so all of that work is discarded. This passes hard_reset=not init_states instead. Without init states the randomisation reset() performs is the only thing placing the objects, so the hard reset is kept. Measured on an RTX 3060 Ti (EGL, robosuite 1.4.0, mujoco 3.2.7, 256x256 x2 cameras), through LiberoEnv.reset(), fresh env per arm: suite hard soft saved libero_spatial 1697 ms 233 ms 1464 ms libero_object 1394 ms 172 ms 1222 ms libero_goal 1177 ms 164 ms 1013 ms libero_10 1528 ms 207 ms 1321 ms Equivalence ----------- Immediately after set_init_state, qpos, qvel, ctrl and act are bit-identical between the two paths on every suite tested. After the 10 settle steps that reset() runs, 9 of 41 qpos entries differ: robot0_joint1..7 (<= 2.4e-5 rad) and gripper0_finger_joint1/2 (<= 2.1e-4 rad). No object joint differs on any suite. The drift is driven by the gripper component of the settle action ([0,0,0,0,0,0,-1]); replacing it with zeros keeps the two paths bit-identical for 12 further steps, and with num_steps_wait=0 there is no divergence at all. Wrist-camera pixels can differ by up to ~87/255, because a sub-millimetre finger displacement crosses rasterisation boundaries at 256x256. The pixel metric badly overstates the physical difference here; 2.1e-4 rad is 0.012 degrees. So this is not bit-identical end to end, and reviewers should decide whether 0.012 degrees of gripper drift is acceptable for the benchmark. It does not change object placement, which is what the fixed init states exist to control. * refactor(env): config param libero + docs --------- Co-authored-by: Dimitar Dimitrov <dvdimitrov13@gmail.com>
This commit is contained in:
@@ -134,6 +134,20 @@ LIBERO-plus supports two control modes — `relative` (default) and `absolute`.
|
||||
--env.control_mode=relative # or "absolute"
|
||||
```
|
||||
|
||||
### Reset performance
|
||||
|
||||
By default, LeRobot preserves LIBERO's hard-reset behavior. With fixed initial
|
||||
states enabled, you can opt into soft resets to skip rebuilding the simulator
|
||||
model and renderer on every episode:
|
||||
|
||||
```bash
|
||||
--env.init_states=true --env.hard_reset=false
|
||||
```
|
||||
|
||||
Soft resets are faster but are not bit-identical to hard resets after the
|
||||
environment's settling steps, so camera observations and policy results may
|
||||
differ slightly. Use hard resets when reproducing benchmark results.
|
||||
|
||||
### Policy inputs and outputs
|
||||
|
||||
**Observations:**
|
||||
|
||||
Reference in New Issue
Block a user