Skip to content

[BUG FIX] Fix per-environment and PD control commands in the differentiable rigid-body simulation. - #3089

Merged
duburcqa merged 6 commits into
Genesis-Embodied-AI:mainfrom
duburcqa:diff_rigid_tape_fixes
Jul 22, 2026
Merged

[BUG FIX] Fix per-environment and PD control commands in the differentiable rigid-body simulation.#3089
duburcqa merged 6 commits into
Genesis-Embodied-AI:mainfrom
duburcqa:diff_rigid_tape_fixes

Conversation

@duburcqa

@duburcqa duburcqa commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Description

Follow-up to #3087, fixing two ways differentiable-scene input commands were silently dropped, and closing the coverage gaps that hid them.

  • The input tape keyed tracked setters by (method, dofs subset) only, so two same-step calls on distinct environment subsets evicted each other: the evicted environments' inputs received no gradient at all and were skipped by the backward replay. The key now includes the environment subset.
  • The PD control setters (control_dofs_velocity, control_dofs_position, control_dofs_position_velocity) were neither tracked nor rejected in differentiable scenes, so per-step-varying targets were replayed as the last command for every step, corrupting the backward primals for all other tracked inputs. They are now tracked and replayed; a gradient-bearing PD target raises (use control_dofs_force for differentiable inputs).

Coverage: per-environment split inputs, per-step PD targets, multi-environment constraint tests (mixed per-environment limit activity), a tangential contact force component, and a nonzero cross-tree weld rotation bias. Both weld fixtures' relpose sign is also corrected (pose of body2 in body1's frame; the inverted value left them violated at rest - confirmed against MuJoCo).

Related Issue

Follow-up to #3087.

How Has This Been / Can This Be Tested?

  • pytest tests/grad/ --backend cpu: 48 passed, 10 skipped on macOS M4 Max (fp64); 46 passed, 12 skipped on Apple Metal (fp32); 58/58 on linux CPU (fp64) and CUDA (fp32).
  • The per-environment split arms and both PD-target arms were verified to FAIL on current main and pass with this PR.

Checklist:

  • I read the CONTRIBUTING document.
  • I followed the Submitting Code Changes section of CONTRIBUTING document.
  • I tagged the title correctly (including BUG FIX/FEATURE/MISC/BREAKING)
  • I updated the documentation accordingly or no change is needed.
  • I tested my changes and added instructions on how to test it for reviewers.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@duburcqa
duburcqa requested a review from YilingQiao as a code owner July 22, 2026 10:49
duburcqa added 4 commits July 22, 2026 13:27
…vel loss to a scalar before the buffer is overwritten.
… low-level loss to a scalar before the buffer is overwritten.
… low-level loss to a scalar before the buffer is overwritten.
@duburcqa
duburcqa merged commit ec0efcc into Genesis-Embodied-AI:main Jul 22, 2026
4 checks passed
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.

1 participant