Skip to content

feat(reset): support ResetSelection in built-in model-field DR terms (#2623) - #2630

Merged
TATP-233 merged 1 commit into
mainfrom
feat/issue-2623-masked-dr-reset-terms
Nov 19, 2026
Merged

TATP-233 merged 1 commit into
mainfrom
feat/issue-2623-masked-dr-reset-terms

Conversation

@TATP-233

Copy link
Copy Markdown
Collaborator

Summary

  • Built-in reset-mode model-field DR terms (GeomFriction, DofArmature, PdGains, RandomizeRigidBodyCom, RandomizeEncoderBias) now declare supports_reset_selection and accept a ResetSelection mask, so tasks carrying them can run the default-on fixed-shape autoreset path (autoreset_cuda_graph=true) instead of failing startup as reset_selection_blockers.
  • New public masked writers on Entity mirror the existing write_actuator_gains_tensor_mask: write_geom_friction_tensor_mask, write_joint_armature_tensor_mask, write_body_ipos_tensor_mask (local-id normalization → backend ids → write_randomization_tensor_mask). No private-interface workarounds needed anymore.
  • ResetStateTransaction._materialize_tensor_randomization_default now caches the immutable per-field full-width default table on the packed reset device: previously every write_randomization_tensor_mask call re-ran torch.as_tensor(np.array(...), device=...) (pageable H2D + sync); KP/KD also paid this per call despite their host-side cache. Cache is cleared when the packed reset device is (re)declared.
  • Mask path validation is deferred: the negative/NaN check in _ModelFieldRandomizer and friends routes through the env's existing require/deferred-verdict channel instead of a host read, and _sample_axis staging plus RandomizeEncoderBias column indexing moved from per-call H2D to cold-path device staging.
  • Docs: 8-sync_free_autoreset.md gains a "Reset-mode DR replay cannot be disabled" behavior note (backends that restore model-field defaults on reset — e.g. MJWarp — diverge obs from physics in step 1 if replay is dropped).
  • Follow-up (out of scope, listed in changelog): RandomizeRigidBodyMass, RandomizeBodyMassInertia, RandomizePhysicsSceneGravity remain row-index-only reset terms.

Linked Work

Validation

  • make test-all passed on the final local head before this PR was created or updated
  • Additional task-specific validation listed below

Commands actually run (final head 5446d703):

uv run pytest tests/base/test_reset_state.py tests/envs/mdp/test_events.py tests/managers -q   # 275 passed
uv run pytest tests/envs/test_fixed_shape_autoreset.py -q                                       # 26 passed
uv run pytest tests/envs/test_manager_based_rl_env.py -q                                        # 324 passed
uv run pytest tests/tasks/test_g1_motion_fixed_shape.py -q -m slow                              # 1 passed (CUDA): blockers == [], graph capture, 40 steps under set_sync_debug_mode("error")
uv run pytest tests/config/test_g1_motion_tracking_owners.py tests/envs/locomotion/g1 -q        # 10 passed
uv run pytest tests/scripts/test_check_docs.py -q                                               # 20 passed
make check                                                                                      # ruff/mypy/pyright clean (1 pre-existing pyright warning on main)
make test-all                                                                                   # exit 0

Impact

  • Backend impact: none (backend-agnostic; works with any backend whose reset restores model-field defaults — the new doc note explains the replay obligation)
  • Platform impact: both
  • Training effect expected: yes — tasks with built-in model-field DR terms can now use fixed-shape autoreset + CUDA graph on capable backends; masked DR replay is sync-free

Artifacts

  • W&B: n/a
  • benchmark result: n/a
  • video / screenshot: n/a
  • ONNX / checkpoint: n/a

Checklist

  • Added or updated tests where needed (8 new focused tests; slow CUDA acceptance test now passes)
  • Updated docs if behavior or workflow changed (behavior note + bilingual changelog entries)
  • Linked the driving issue
  • Noted any follow-up work explicitly (3 remaining reset DR terms)

…2623)

Fixed-shape autoreset (env.autoreset_cuda_graph) negotiates ResetSelection
support with every reset-mode event term; the built-in model-field DR terms
(geom friction, joint armature, PD gains, rigid-body CoM, encoder bias)
previously had no declaration and blocked tasks such as G1 motion tracking.

Masked path: sample at full width from device-staged immutable tables
(sampling ranges, field defaults, gain defaults, CoM ranges, joint columns),
merge through the packed reset transaction via the new entity tensor-mask
gateways, and publish value validity through the env's deferred verdict
channel (env.require) instead of the eager host check. Sampling tables are
staged once on the cold path so captured resets stay sync-free.

ResetStateTransaction now caches the per-field full-width device default
table used by write_randomization_tensor_mask, clearing the cache when the
packed reset device is redeclared.

Remaining reset DR terms (randomize_rigid_body_mass,
randomize_body_mass_inertia, randomize_physics_scene_gravity) are follow-ups.
@TATP-233
TATP-233 merged commit 5749871 into main Nov 19, 2026
12 checks passed
@TATP-233
TATP-233 deleted the feat/issue-2623-masked-dr-reset-terms branch November 19, 2026 15:52
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