Skip to content

[Fix] Randomize fixed tendons from their initial values and zero Shadow Hand restitution - #8320

Merged
AntoineRichard merged 12 commits into
isaac-sim:developfrom
hujc7:jichuanh/shadow-randomized-nan
Oct 9, 2026
Merged

AntoineRichard merged 12 commits into
isaac-sim:developfrom
hujc7:jichuanh/shadow-randomized-nan

Conversation

@hujc7

@hujc7 hujc7 commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator

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. Adds Initial Support for Multiple Simulation Backends #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: 1 passed.
    Its repeated-scale check fails on develop (stiffness 8.0 vs 2.0).
  • 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

  • Backport this pull request to the active release branch after it merges into develop

Screenshots

Not applicable.

Checklist

  • I have read and understood the contribution guidelines
  • I have run the pre-commit checks with uv run isaaclab --format
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have validated the changed behavior with focused coverage and applied the test-audit criteria to any test changes
  • I have added a changelog fragment under source/<pkg>/changelog.d/ for every touched package
  • My name already exists in CONTRIBUTORS.md

hujc7 added 2 commits October 5, 2026 22:19
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.
@hujc7

hujc7 commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator Author

run-ci

@github-actions github-actions Bot added the isaac-lab Related to Isaac Lab team label Oct 6, 2026
@isaaclab-bot isaaclab-bot Bot added ci:run-docker Trigger the on-demand Docker and GPU CI workflow and removed ci:run-docker Trigger the on-demand Docker and GPU CI workflow labels Oct 6, 2026
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.
@hujc7

hujc7 commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator Author

run-ci

@isaaclab-bot isaaclab-bot Bot added ci:run-docker Trigger the on-demand Docker and GPU CI workflow and removed ci:run-docker Trigger the on-demand Docker and GPU CI workflow labels Oct 6, 2026
hujc7 added 3 commits October 5, 2026 22:53
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.
@hujc7

hujc7 commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator Author

run-ci

@hujc7
hujc7 marked this pull request as ready for review October 6, 2026 05:54
@hujc7
hujc7 requested a review from a team October 6, 2026 05:54
@isaaclab-bot isaaclab-bot Bot added ci:run-docker Trigger the on-demand Docker and GPU CI workflow and removed ci:run-docker Trigger the on-demand Docker and GPU CI workflow labels Oct 6, 2026
@greptile-apps

greptile-apps Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

[Medium risk] Fixes numerical instability in Shadow Hand training randomization.

The PR appears safe to merge, with a non-blocking gap in regression coverage for the affected scaling behavior.

Findings

  1. P2 Scaling regression remains untested ▶

Summary

The PR anchors fixed-tendon randomization to values captured before the term’s first write and changes the Shadow Hand randomized preset’s hand and cube restitution from 1.0 to 0.0.

  • The new regression test checks repeated additive randomization, but not the multiplicative operation used by the affected preset.

Reviews (1) · Last reviewed commit: "Merge remote-tracking branch 'upstream/d..."

stiffness_distribution_params=(0.5, 0.5),
damping_distribution_params=(0.25, 0.25),
operation="add",
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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!

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@isaaclab-review-bot isaaclab-review-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 add and scale now 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 getattr for 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:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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…

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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…

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@hujc7

hujc7 commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator Author

run-ci

@isaaclab-bot isaaclab-bot Bot added the ci:run-docker Trigger the on-demand Docker and GPU CI workflow label Oct 6, 2026
@isaaclab-bot isaaclab-bot Bot removed the ci:run-docker Trigger the on-demand Docker and GPU CI workflow label Oct 6, 2026
@hujc7

hujc7 commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator Author

@AntoineRichard Could you help review?

@AntoineRichard AntoineRichard left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. 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.py into 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.
  2. getattr + lazy capture (inline below). Explicit default_fixed_tendon_* attributes captured in __init__ would be more in line with the joint terms in this file.
  3. Changelog. The isaaclab fragment 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.
  4. PR body. Consider dropping the ## Summary block and the revision-history text ("earlier revisions … read the tendon values in the constructor", "so far"), and adding a ## Validation section with the exact uv run --frozen … pytest command 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()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dropped in 216f11c, matching Allegro.

hujc7 added 3 commits October 6, 2026 10:32
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.
@hujc7 hujc7 changed the title Fix non-finite training with the Shadow Hand randomized preset [Fix] Randomize fixed tendons from their initial values and zero Shadow Hand restitution Oct 6, 2026
@hujc7

hujc7 commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator Author

run-ci

@isaaclab-bot isaaclab-bot Bot added ci:run-docker Trigger the on-demand Docker and GPU CI workflow and removed ci:run-docker Trigger the on-demand Docker and GPU CI workflow labels Oct 6, 2026
@hujc7

hujc7 commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator Author

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 isaaclab fragment is now two lines, and the class docstring states the term ignores values written after it is created. 4. The body drops the Summary and revision history and adds a Validation section.



@pytest.mark.parametrize(("operation", "value", "expected"), [("add", 0.5, 1.5), ("scale", 2.0, 2.0)])
def test_fixed_tendon_parameters_do_not_compound(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we integrate into an existing test instead of creating a new one?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to use get? Can we not access these values directly?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@hujc7

hujc7 commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator Author

run-ci

@isaaclab-bot isaaclab-bot Bot added ci:run-docker Trigger the on-demand Docker and GPU CI workflow and removed ci:run-docker Trigger the on-demand Docker and GPU CI workflow labels Oct 8, 2026
@hujc7
hujc7 requested a review from StafaH October 9, 2026 00:36
@AntoineRichard
AntoineRichard merged commit 0f50f21 into isaac-sim:develop Oct 9, 2026
59 checks passed
isaaclab-bot Bot pushed a commit that referenced this pull request Oct 9, 2026
…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)
@isaaclab-bot

isaaclab-bot Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Backported to release/3.0.0 as 12739f3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants