Repository navigation
[Fix] Randomize fixed tendons from their initial values and zero Shadow Hand restitution - #8320
Conversation
randomize_fixed_tendon_parameters scaled or offset the live tendon buffer, which it had itself written on the previous call, so every reset compounded the earlier samples. Capture each property the first time the term randomizes it, as the rigid-body mass, inertia and center-of-mass terms do, and randomize from that copy. Only randomized properties are read, since not every backend exposes every tendon property.
The material term samples absolute values, so the preset's restitution range of (1.0, 1.0) made the hand and the cube perfectly elastic on PhysX and OvPhysX, which slowed or stalled learning. Use 0.0, the value without randomization; Newton's MuJoCo solver does not use restitution.
|
run-ci |
The restitution of 1.0 does not cause the non-finite observations: with the tendon fix alone, training stays finite on Kit PhysX and OvPhysX and still learns, and a (0.0, 0.2) range did not train better. Leave the preset as it was.
|
run-ci |
The material term requires a restitution range and samples absolute values, so (1.0, 1.0) made the hand and the cube perfectly elastic on PhysX and OvPhysX, which slowed learning. Use 0.0, the value without randomization.
|
run-ci |
|
| stiffness_distribution_params=(0.5, 0.5), | ||
| damping_distribution_params=(0.25, 0.25), | ||
| operation="add", | ||
| ) |
There was a problem hiding this comment.
Scaling regression remains untested The new test repeats
operation="add", but the Shadow Hand preset that produced non-finite observations uses operation="scale". A future change could reintroduce multiplicative compounding and still pass this test. Please also check repeated scaling against the initial stiffness and damping values.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
Done in e035154: the test now covers add and scale from a known non-zero initial value. Both cases fail on develop (stiffness 2.5 vs 1.5, and 8.0 vs 2.0) and pass with this change.
There was a problem hiding this comment.
Isaac Lab Review Bot
Needs attention: API (1), Style consistency (1). Other reviewed categories look good.
- PR description: The body matches the six-file diff, but the “this PR” results used earlier revisions; relabel that column and distinguish the 300-iteration head replay from full training validation.
- Design and architecture: Architecture looks good.
- Scope and over-engineering: No over-engineering issues.
- API: The class docstring does not state that
addandscalenow use values captured before the term’s first write; document this changed baseline contract. - Compatibility and deprecation: No breaking changes identified.
- Implementation: Implementation looks good.
- Style consistency: The helper uses
getattrfor six statically known attributes, contrary to the direct-access rule; cache each property through explicit attribute access. - Test quality: Test quality looks good.
Minor fixes needed. Posted 2 inline findings.
Automated review; human maintainers own approval decisions.
| ): | ||
| _validate_randomization_params(cfg, name, allow_negative=True) | ||
|
|
||
| def _default(self, prop: str) -> torch.Tensor: |
There was a problem hiding this comment.
🟡 Warning · Api — Docstring omits new randomization base
add and scale now apply to the values captured before the term's first write, not the live tendon buffers. The class docstring still says the operation applies to "the tendon properties"; state the captured-baseline contract…
There was a problem hiding this comment.
Done in b7c501d: the class docstring now states that the operation applies to the tendon properties read when the term is created, so repeated calls do not compound and values written afterwards by other code are ignored.
| def _default(self, prop: str) -> torch.Tensor: | ||
| """Initial value of ``prop``, read on first use since not every backend exposes every tendon property.""" | ||
| if prop not in self._defaults: | ||
| self._defaults[prop] = getattr(self.asset.data, prop).torch.clone() |
There was a problem hiding this comment.
🟡 Warning · Style Consistency — getattr used for known attributes
All six call sites pass literal property names, so getattr hides them from renames and typo checks; the guide reserves it for names determined at runtime. Read each property directly in its branch and cache…
There was a problem hiding this comment.
Done in b7c501d: the term now caches explicit default_fixed_tendon_* attributes in __init__, as the joint randomization terms do, and no longer uses getattr.
The Shadow Hand preset scales its tendon parameters; check that repeated scaling, like repeated adding, starts from the initial values.
|
run-ci |
|
@AntoineRichard Could you help review? |
AntoineRichard
left a comment
There was a problem hiding this comment.
Thanks, the tendon fix looks correct and the evidence is convincing. Reading from the captured copy matches how randomize_rigid_body_mass handles default_mass, the per-call .clone() keeps the in-place limit edits off the cache, and reading only randomized properties avoids Newton's fixed_tendon_limit_stiffness raise. The new test fails on develop for the intended reason, and add/scale hit different branches, so both rows earn their place.
A few things before merge, mostly to keep this lean for review:
- Scope / title. The description says the restitution change "does not cause the non-finite observations", but the title is "Fix non-finite training…". I'd either split
shadow_hand_common.pyinto its own PR, or retitle to cover both fixes (e.g.[Core] Randomize fixed tendon parameters from their initial values) and keep the table as the justification for the preset change. getattr+ lazy capture (inline below). Explicitdefault_fixed_tendon_*attributes captured in__init__would be more in line with the joint terms in this file.- Changelog. The
isaaclabfragment could be two user-facing lines: what changed, and that values no longer drift across resets. It's worth stating that the term now ignores tendon values written by other code after its first call (same as the mass term). The Shadow Hand story can stay in the PR description. - PR body. Consider dropping the
## Summaryblock and the revision-history text ("earlier revisions … read the tendon values in the constructor", "so far"), and adding a## Validationsection with the exactuv run --frozen … pytestcommand and pass count.
None of these are blockers for the fix itself.
| def _default(self, prop: str) -> torch.Tensor: | ||
| """Initial value of ``prop``, read on first use since not every backend exposes every tendon property.""" | ||
| if prop not in self._defaults: | ||
| self._defaults[prop] = getattr(self.asset.data, prop).torch.clone() |
There was a problem hiding this comment.
Could we avoid getattr with string property names here? Since cfg.params is already known in __init__, the joint terms' pattern would work: capture self.default_fixed_tendon_stiffness = self.asset.data.fixed_tendon_stiffness.torch.clone() (etc.) eagerly, only for properties whose *_distribution_params is set. That still skips limit stiffness on Newton, makes the attributes discoverable, and removes the _defaults/_default near-identical names. If you prefer the first-call capture, a one-line pointer to randomize_rigid_body_mass doing the same would help.
There was a problem hiding this comment.
Switched to eager capture in b7c501d: __init__ now caches explicit default_fixed_tendon_* attributes, as the joint terms do. Stiffness, damping and position limits are always read; limit stiffness, rest length and offset only when randomized, since Newton raises NotImplementedError for those.
| "static_friction_range": (0.7, 1.3), | ||
| "dynamic_friction_range": (1.0, 1.0), | ||
| "restitution_range": (1.0, 1.0), | ||
| "restitution_range": (0.0, 0.0), |
There was a problem hiding this comment.
Nit: the comment is on the robot term but not this one. Either mirror it here or drop it from both (Allegro uses (0.0, 0.0) without a comment).
Read the tendon properties into explicit default_fixed_tendon_* attributes in __init__, as the joint randomization terms do, instead of through getattr on first use. Limit stiffness, rest length and offset are read only when randomized, since Newton raises NotImplementedError for them.
|
run-ci |
|
Thanks, all four addressed. 1. Retitled to cover both fixes; I kept them in one PR since without the restitution change the preset learns slower on PhysX (table). 2. Eager explicit attributes (inline). 3. The |
|
|
||
|
|
||
| @pytest.mark.parametrize(("operation", "value", "expected"), [("add", 0.5, 1.5), ("scale", 2.0, 2.0)]) | ||
| def test_fixed_tendon_parameters_do_not_compound( |
There was a problem hiding this comment.
Can we integrate into an existing test instead of creating a new one?
There was a problem hiding this comment.
Merged into test_fixed_tendon_parameters in 9e5d0ea. It now checks that repeated scale calls stay at 2× the initial value. On develop it reads 8.0, so it still catches the regression.
| self.default_fixed_tendon_pos_limits = self.asset.data.fixed_tendon_pos_limits.torch.clone() | ||
| # read only when randomized: Newton raises NotImplementedError for these | ||
| params = cfg.params | ||
| if params.get("limit_stiffness_distribution_params") is not None: |
There was a problem hiding this comment.
Why do we need to use get? Can we not access these values directly?
There was a problem hiding this comment.
We don't need it. ManagerTermBase.__init__ already fills cfg.params with every omitted keyword default before this runs. Switched to direct indexing in 9e5d0ea.
|
run-ci |
…ow Hand restitution (#8320) # Description Training the Shadow Hand reorientation tasks with `presets=randomized` hit non-finite observations on every Kit PhysX and OvPhysX seed (5/5 each), and on the camera variant on Newton. This fixes the tendon randomization that caused it and the preset's restitution. 1. **Tendon randomization compounded.** `randomize_fixed_tendon_parameters` read the live tendon buffers its previous call had written, so with `operation="scale"` per-env stiffness and damping random-walked (8192-env probes: stiffness up to 1.4e12 on Kit PhysX, damping up to 1.4e6 on Newton); on Kit PhysX the fingers of drifted envs then tangle and the articulation goes non-finite. #4472 moved the term off the `default_fixed_tendon_*` properties, which are now deprecated with "The default value will need to be managed manually.", without managing the default in the term. The term now caches the tendon properties when it is created, as the joint randomization terms do, and randomizes from that copy. Limit stiffness, rest length and offset are read only when randomized: Newton raises `NotImplementedError` for them. 2. **Restitution was fixed at 1.0.** `randomize_rigid_body_material` requires a restitution range and samples absolute values, so the preset's `(1.0, 1.0)` made every hand and cube shape perfectly elastic. It now uses `(0.0, 0.0)`, the value without randomization. This does not cause the non-finite observations but slows learning on PhysX (table); a `(0.0, 0.2)` range left one of three Kit PhysX seeds unable to learn. 3. **Also affects** `IsaacContrib-Reorient-Cube-Shadow-OpenAI-{FF,LSTM}-Direct`, which always apply this randomization. 4. **Evidence** (`Isaac-Reorient-Cube-Shadow presets=randomized`, rsl_rl, task defaults, 3000 iterations; L40 GPUs, Kit PhysX in the Isaac Lab develop container): | Backend | develop | tendon fix only | this PR | |---|---|---|---| | Kit PhysX | NaN on 5/5 seeds (iteration 1165-1358) | no NaN on 3/3, SR 0.76 / 0.81 / 0.83 | no NaN on 5/5, SR 0.86-0.89 | | OvPhysX | NaN on 5/5 seeds (iteration 1016-1401) | no NaN on 3/3, SR 0.01 / 0.76 / 0.77 | no NaN on 5/5, SR 0.84-0.89 | | Newton MJWarp | no NaN on 7/7 seeds; NaN at step 1444 of a stress probe | — | stress probe clean for 4000 steps; no NaN on 5/5, SR 0.88-0.92 | The stress probe applies every reset term on every reset with action noise std 6 on 8192 envs. `Isaac-Reorient-Cube-Shadow-Camera` (1225 envs, 5000 iterations) shares the preset. On develop, Newton (Warp renderer) goes non-finite for seeds 42 / 43 / 44 at iteration 955 / 1204 / 709 and Kit PhysX (RTX) for seeds 42 / 43 at 3112 / 761; with this change, all five reach 5000 iterations without. Training ran on develop 174812c with an equivalent version of this change (see Validation). ## Validation - `uv run --frozen python -m pytest source/isaaclab/test/envs/test_event_requirements.py`: 19 passed. - `source/isaaclab_physx/test/envs/test_events.py -k fixed_tendon` in the Isaac Lab develop container: 3 passed. `test_fixed_tendon_parameters_do_not_compound` (`add` and `scale`) fails on develop. - Kit PhysX seed-43 replay of the training tree with this branch's `events.py`: success rate and mean reward match the trained run at iterations 1, 10, 50, 100, 200 and 300, and every logged metric at iteration 300 is identical. ## Type of change - Bug fix (non-breaking change which fixes an issue) ## Release backport - [x] <!-- backport-active-release --> Backport this pull request to the active release branch after it merges into `develop` ## Screenshots Not applicable. ## Checklist - [x] I have read and understood the [contribution guidelines](https://isaac-sim.github.io/IsaacLab/develop/source/refs/contributing.html) - [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with `uv run isaaclab --format` - [x] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have validated the changed behavior with focused coverage and applied the [test-audit criteria](https://github.com/isaac-sim/IsaacLab/blob/develop/skills/developer/test-audit/SKILL.md) to any test changes - [x] I have added a changelog fragment under `source/<pkg>/changelog.d/` for every touched package - [x] My name already exists in `CONTRIBUTORS.md` (cherry picked from commit 0f50f21)
|
Backported to |
Description
Training the Shadow Hand reorientation tasks with
presets=randomizedhit non-finite observations on every Kit PhysXand OvPhysX seed (5/5 each), and on the camera variant on Newton. This fixes the tendon randomization that caused it and
the preset's restitution.
Tendon randomization compounded.
randomize_fixed_tendon_parametersread the live tendon buffers its previous callhad written, so with
operation="scale"per-env stiffness and damping random-walked (8192-env probes: stiffness up to1.4e12 on Kit PhysX, damping up to 1.4e6 on Newton); on Kit PhysX the fingers of drifted envs then tangle and the
articulation goes non-finite. Adds Initial Support for Multiple Simulation Backends #4472 moved the term off the
default_fixed_tendon_*properties, which are now deprecatedwith "The default value will need to be managed manually.", without managing the default in the term. The term now
caches the tendon properties when it is created, as the joint randomization terms do, and randomizes from that copy.
Limit stiffness, rest length and offset are read only when randomized: Newton raises
NotImplementedErrorfor them.Restitution was fixed at 1.0.
randomize_rigid_body_materialrequires a restitution range and samples absolutevalues, so the preset's
(1.0, 1.0)made every hand and cube shape perfectly elastic. It now uses(0.0, 0.0), thevalue without randomization. This does not cause the non-finite observations but slows learning on PhysX (table); a
(0.0, 0.2)range left one of three Kit PhysX seeds unable to learn.Also affects
IsaacContrib-Reorient-Cube-Shadow-OpenAI-{FF,LSTM}-Direct, which always apply this randomization.Evidence (
Isaac-Reorient-Cube-Shadow presets=randomized, rsl_rl, task defaults, 3000 iterations; L40 GPUs, KitPhysX in the Isaac Lab develop container):
The stress probe applies every reset term on every reset with action noise std 6 on 8192 envs.
Isaac-Reorient-Cube-Shadow-Camera(1225 envs, 5000 iterations) shares the preset. On develop, Newton (Warp renderer)goes non-finite for seeds 42 / 43 / 44 at iteration 955 / 1204 / 709 and Kit PhysX (RTX) for seeds 42 / 43 at
3112 / 761; with this change, all five reach 5000 iterations without.
Training ran on develop 174812c with an equivalent version of this change (see Validation).
Validation
uv run --frozen python -m pytest source/isaaclab/test/envs/test_event_requirements.py: 19 passed.source/isaaclab_physx/test/envs/test_events.py -k fixed_tendonin the Isaac Lab develop container: 1 passed.Its repeated-scale check fails on develop (stiffness 8.0 vs 2.0).
events.py: success rate and mean reward match thetrained run at iterations 1, 10, 50, 100, 200 and 300, and every logged metric at iteration 300 is identical.
Type of change
Release backport
developScreenshots
Not applicable.
Checklist
pre-commitchecks withuv run isaaclab --formatsource/<pkg>/changelog.d/for every touched packageCONTRIBUTORS.md