Skip to content

Keep replay storage independent of collection autograd graphs - #7

Open
Afloat16 wants to merge 7 commits into
HybridRobotics:mainfrom
Afloat16:afloat/20261111-replay-detached-storage
Open

Afloat16 wants to merge 7 commits into
HybridRobotics:mainfrom
Afloat16:afloat/20261111-replay-detached-storage

Conversation

@Afloat16

@Afloat16 Afloat16 commented Nov 11, 2026 •

Copy link
Copy Markdown

Problem

Inserting a transition produced with gradients enabled attaches its graph to the replay storage through the indexed copy. Repeated collection and ring overwrites keep that history alive, and later samples unexpectedly carry gradients back into collection.

Changes

Write transitions under torch.no_grad(). The buffer still copies the actual values but owns no collection graph. The regression crosses multiple wraps, checks sampled data and storage graph state, and verifies the original source graph remains usable.

Validation

PYTHONPATH=src python -m pytest --confcutdir=tests/standalone -q tests/standalone/test_replay_detached_storage.py

  • Base: 1 failed in 2.19s
  • Fix: 1 passed in 2.70s
  • Ruff lint/format and git diff --check pass.

The focused CPU tests import the changed production module directly and use synthetic tensors. The required source is now publicly available at HybridRobotics/mjlab_research. Full simulator/training integration was not run in this validation. The standalone test directory lets these independent checks run without the simulator fixtures.

Earlier branch verification

Rechecked the published head 83e6ad4b1a0c01d7ffbf30540cc2d2f65b74cc38 against upstream main at abc124c1bd5976341034668af3d12c087f2f1f55: the branch already contains this upstream commit. The focused CPU regression was rerun with Python 3.12.14, PyTorch 2.15.0+cpu and TensorDict 0.11.0: 1 passed in 2.92s. Complete Python 3.13 simulator and CUDA training validation was not run.

Current integration verification (2026-11-26)

Published head: 2c5a0c73ed0240e33e13e503e3e58111933ee821. Current upstream main: 5fb92297ab4fe3d86629d9f0c635334791bb0d5f. The local merge of this published head with that current main was validated; the local integration tree is 2261662440374b572a25ac529b0798b007d0169a. The upstream CI configuration is retained, and the feature diff remains limited to this PR's two original files.

Focused CPU validation used Python 3.12.14, PyTorch 2.15.0+cpu and TensorDict 0.11.0:

  • test_replay_detached_storage.py: 1 passed on the integrated tree.
  • The same regression on unmodified current main: 1 failed, 0 passed; no collection errors or skips.
  • Ruff 0.15.0 lint/format checks, syntax checks and git diff --check pass.

Where the current environment module imports simulator task registration, the local harness isolates that import while retaining the exact production environment code and observation-builder implementation with real Torch/TensorDict. This is focused CPU regression coverage; complete Python 3.13 simulator and GPU training validation remains outstanding. Upstream Actions approval and completion remain necessary before relying on hosted CI.

@qiayuanl
qiayuanl force-pushed the main branch 2 times, most recently from 76b6652 to 7e94b07 Compare November 16, 2026 23:15
Retain upstream main triggers, the public mjlab checkout, and the updated lockfile. Preserve the focused fix and regression coverage.
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