PaperLeet

DiffMimic Demonstration Replay and Differentiable PD Control

DiffMimic · ICLR 2023 · Medium · 30 minutes

DiffMimic Demonstration Replay and Differentiable PD Control: implement the interfaces below and verify numerical, boundary and experimental behavior.

Implement error-triggered demonstration replay, PD torque and temporal state matching. The experiment uses a scalar differentiable integrator, not a Brax humanoid reproduction.

Functions to implement

DiffMimic Demonstration Replay and Differentiable PD Control

1. Exercise goal

DiffMimic Demonstration Replay and Differentiable PD Control: implement the interfaces below and verify numerical, boundary and experimental behavior.

Implement error-triggered demonstration replay, PD torque and temporal state matching. The experiment uses a scalar differentiable integrator, not a Brax humanoid reproduction.

2. Core equations

$$ \tilde s=\begin{cases}s&|s-s^|^2<\epsilon\s^&\text{otherwise}\end{cases},\quad\tau=k_p(q^-q)-k_d\dot q,\quad L=\frac1B\sum_{b,t}|s_{bt}-s^_{bt}|^2. $$

3. From equations to code

  • replay_state(state: Tensor, reference: Tensor, threshold: float) -> Tensor
  • pd_torque(position: Tensor, velocity: Tensor, target: Tensor, kp: float, kd: float) -> Tensor
  • state_matching_loss(states: Tensor, reference: Tensor) -> Tensor

Replay replaces excessive-error states before the next policy/physics transition. Kept states pass gradients; replayed branches cut gradients to old states. State-matching loss must still measure actual trajectory errors instead of erasing an error because replay occurs. The PD target angular velocity is zero.

4. Contract and boundaries

Replay state/reference are (B,D), threshold>=0. Retain state only for strictly smaller squared error; replay equality. References detach. PD tensors are matching (B,J), kp/kd nonnegative. Loss takes (B,T,D), sums time and coordinates, averages batch, and detaches reference.

Validation helpers are provided. All floating inputs are finite CPU float32/float64; do not mutate inputs. Invalid shape, dtype, range or mask arguments raise ValueError.

5. Deterministic experiment and visualization

experiment.py calls every submitted interface on fixed inputs and records a learning or sampling curve and terminal metrics. T3 states the behavioral thresholds; the visualization uses the same outputs.

The visualization is generated by viz/gen.py; T3 runs the same experiment with your functions and records its actual metrics. These are small deterministic teaching results, not a robot benchmark.

6. Run your implementation

Complete the functions in the Python editor on the right, then click Run tests. Inspect each failed check, update your implementation, and run again. Passing every required check marks the problem as solved and unlocks the notes.

7. Sources and extensions

Verified 2026-10-28. Extending this operator to the full paper requires the omitted model, data and environment described in the scope above.

Read paper · arXiv:2304.03274

Related exercises