Skip to content

Snapshot initial observation padding before source buffers are reused - #561

Open
sylvesterkaczmarek wants to merge 1 commit into
google-deepmind:mainfrom
sylvesterkaczmarek:fix/snapshot-initial-observation-padding
Open

sylvesterkaczmarek wants to merge 1 commit into
google-deepmind:mainfrom
sylvesterkaczmarek:fix/snapshot-initial-observation-padding

Conversation

@sylvesterkaczmarek

@sylvesterkaczmarek sylvesterkaczmarek commented Sep 28, 2026 •

Copy link
Copy Markdown

Summary

Fixes #559.

Copy the initial observation before using it for initial-value buffer padding. Those padding entries previously retained the caller's array, so later mutation or reuse of a MuJoCo state view rewrote the apparent initial observations. Regular inserted observations already copy their input.

Keep a single private snapshot for the padding entries. Buffer reads remain independent copies, and zero padding, arrival ordering, later samples and source arrays are unchanged. This also makes delayed scalar/list padding use the same ndarray representation as regular entries. No dynamics, rewards, dependencies or workflows change.

Validation

Added 21 cases covering source reuse, immediate/delayed observations, scalar/list/strided/Fortran inputs, several buffer sizes and numeric dtypes, returned-array independence, delayed arrival controls and zero padding. Two tests run the actual Updater with a native MuJoCo sliding body whose observable returns its live qpos array, with and without mean aggregation.

  • New cases against unchanged main: 19 failed, 2 passed.
  • Selected observation, variation, RL and utility suites: 189 passed, 6 camera-related cases deselected, on both Python 3.12.11 and 3.11.16.
  • Both independent observation fixes from this round in a separate worktree: 221 passed, 6 deselected, on both Python versions.
  • Ruff E9/F on both changed files, Pyink on the added tests and changed source lines, compilation and git diff --check: passed.

Based on main at a04e3e4cf56c12117d2294bb090f9acec21e5c67. Tested on macOS with MuJoCo 3.14.0, NumPy 2.3.2 and SciPy 1.16.1; bindings were generated using the repository's build_mjbindings command. Rendering was disabled. A broader run failed the same three camera-rendering tests on unchanged main and both branches; the CPU selection above excludes camera-related cases only, without modifying repository test settings. The existing axis-angle warning is unchanged. The complete repository suite, rendering, training runs, package builds and other operating systems were not tested. Nested objects in object-dtype arrays are not deep-copied, matching ordinary insertion semantics.

Reference: NumPy array copy semantics.

Upstream checks

At submission the CLA passed, the GitHub Actions Scan was queued, and the organization security workflow reported action_required: https://github.com/google-deepmind/dm_control/actions/runs/36484650446. The test counts above are local results, not completed upstream CI.

@sylvesterkaczmarek

Copy link
Copy Markdown
Author

@saran-t This is current with main, has no failing or pending public checks, and touches the delayed observation-buffer behavior you originally introduced. It snapshots the initial padding value so later reuse/mutation of the source buffer cannot alter already-buffered history, with focused regression coverage. Could you review the current head when convenient?

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.

Initial observation padding changes when source arrays are reused

1 participant