Skip to content

[PREF] Rigid: single-write acc update in func_update_acc#44

Open
suphilip wants to merge 1 commit intoamd-integrationfrom
dev/suphilip/perf-func_update_acc
Open

[PREF] Rigid: single-write acc update in func_update_acc#44
suphilip wants to merge 1 commit intoamd-integrationfrom
dev/suphilip/perf-func_update_acc

Conversation

@suphilip
Copy link
Copy Markdown

Summary
Refactor func_update_acc in genesis/engine/solvers/rigid/abd/forward_dynamics.py so that links_state.cdd_vel, cdd_ang, cacc_lin, and cacc_ang are no longer updated on every DOF iteration. The same values are built in local variables (ls_*) over the per-link DOF loop, then the corresponding global fields are assigned once per link index.

Motivation / performance
This cuts repeated global traffic and, for the backward path, removes the need for the previous pattern that relied on func_add_safe_backward (accumulation/atomics required by the autodiff global access rules) when updating these fields in the inner loop.

Autodiff (Taichi-style)
The change aligns with the global data access rules for differentiable programs: in particular, avoiding multiple writes to the same global field element in ways that are not the allowed += / accumulation pattern. With a single assignment to each links_state.*[i_l, i_b] per forward pass over that site, the refactor stays consistent with those constraints while simplifying the implementation.

Description

Related Issue

Resolves Genesis-Embodied-AI/Genesis#

Motivation and Context

How Has This Been / Can This Be Tested?

Screenshots (if appropriate):

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.

@suphilip suphilip self-assigned this Apr 28, 2026
@yaoliu13
Copy link
Copy Markdown
Collaborator

Pre-submit is 726705.4

@suphilip suphilip force-pushed the dev/suphilip/perf-func_update_acc branch from 718db34 to 9adc4d1 Compare April 28, 2026 16:00
@suphilip
Copy link
Copy Markdown
Author

/run-ci

@suphilip suphilip force-pushed the dev/suphilip/perf-func_update_acc branch from 9adc4d1 to 0188d7b Compare April 29, 2026 18:34
@suphilip
Copy link
Copy Markdown
Author

/run-ci

@suphilip suphilip force-pushed the dev/suphilip/perf-func_update_acc branch from 0188d7b to a7be949 Compare April 30, 2026 00:22
@suphilip
Copy link
Copy Markdown
Author

/run-ci

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.

2 participants