Repository navigation
Conversation
Confidence Score: 4/5
[Medium impact] The new behavior is limited to optional experimental MDP2 scene-contract tasks. Include the required scene and bank in the installed package before merging. Findings
SummaryAdds USD contract scenes to MDP2.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart LR
USD["USD scene and contract"] --> Solver["Offline solver"]
Solver --> Bank["Layout bank and row records"]
USD --> Scene["Scene entries"]
USD --> Draws["Startup mass draws"]
Bank --> Reset["Shared reset states"]
Scene --> Task["MDP2 task"]
Draws --> Task
Reset --> Task
Reviews (2) · Last reviewed commit: "Run USD randomization contracts in MDP2 ..." · Reviewed by Greptile |
| if prim.HasAPI(UsdPhysics.RigidBodyAPI): | ||
| path = prim.GetPath().pathString | ||
| relative = path[len(root.GetPath().pathString) :] | ||
| entries[_entity_name(stage, path)] = RigidObjectCfg(prim_path=prim_path + relative, spawn=None) |
There was a problem hiding this comment.
contract_scene turns both /Scene/A/B and /Scene/A_B into A_B, so the later body replaces the earlier scene entry. contract_task uses the same names for its outputs and stored states, losing one body's reset data too. Reject duplicate names before inserting them, or use names that keep these paths distinct.
| while len(seeds) < args.rows: | ||
| sample = solver.sample(rc.Request(seed=seed)) | ||
| if sample.status != "verified": | ||
| print(f"seed {seed}: {sample.status}, skipped") | ||
| seed += 1 | ||
| continue |
There was a problem hiding this comment.
Bank generation can run forever
contract_bank.py has no overall limit on failed samples. A valid contract whose conditions cannot all be met keeps returning unverified samples, so this loop retries forever without saving a bank. Add a configurable attempt limit and stop with the number of rows collected and a useful error.
There was a problem hiding this comment.
Isaac Lab Review Bot
Needs attention: Design and architecture (1), Scope and over-engineering (2), Compatibility and deprecation (4), Implementation (3), Style consistency (3), Test quality (3). Other reviewed categories look good.
- PR description: Full-diff scope exceeds the title/body: correct non-breaking and mass-bank reuse claims, trim repeated rationale, preserve template sections, and supply reset-cost baseline/candidate revisions, command/workload, hardware, backend, environment count, warmup, and latency.
- Design and architecture: prototype_groups bypasses the bound scene through the simulation singleton; pass resolved prototype layout from the scene owner to avoid global lifecycle coupling.
- Scope and over-engineering: Minimal implementation: extend core buffer/sampler and MDP2 lifecycle owners; keep reset_states.py for persistent reset contracts, contract.py for USD adaptation, both generation scripts for separate runtimes, and contract_tabletop/{init,author_scene,mdp,tabletop_env_cfg}.py for registration, regeneration, terms, and configuration; eliminate identity bank copies and unused mass-mode calculations. Suggested PR breakdown: (1) core serialization/reset APIs, validated by core tests; (2) MDP2 resets/Lift migration, validated by analytic/physical tests; (3) USD adapter, bank tool, tabletop task/docs, validated by contract tests.
- API: API changes look good.
- Compatibility and deprecation: Breaking changes: Lift imports, CANDIDATES, reset overrides, and defaults lose their transition paths; YAML tensor dumps lose values; preserve old behavior with targeted deprecation, migration/removal guidance, and transition coverage.
- Implementation: Bank generation retries indefinitely when no sample verifies; add a total attempt budget and fail with the verified-row count when exhausted.
- Style consistency: contract_task prints library status outside configured logging; emit handling summaries through a module logger at INFO level.
- Test quality: The default-reset test lacks an earlier reset writer and outcome tracking, so it cannot prove its claimed behavior; add those conditions or narrow the test.
Needs rework. Posted 16 inline findings.
Automated review; human maintainers own approval decisions.
|
|
||
| prims, poses, seeds = None, [], [] | ||
| seed, start = 0, time.perf_counter() | ||
| while len(seeds) < args.rows: |
There was a problem hiding this comment.
🔴 Critical · Implementation — Bound bank sampling attempts
An infeasible contract never produces a verified row, so this loop runs forever. Set a total attempt budget and fail with the verified-row count when it is exhausted.
|
|
||
| _Dumper.add_multi_representer( | ||
| torch.Tensor, | ||
| lambda dumper, tensor: dumper.represent_str(f"tensor(shape={list(tensor.shape)}, dtype={tensor.dtype})"), |
There was a problem hiding this comment.
🔴 Critical · Compatibility — Keep YAML tensor contents
dump_yaml now replaces every tensor’s values with a shape-and-dtype string, irreversibly changing existing serialized output. Preserve value-bearing dumps by default and make reporting summaries opt-in.
| ctx.state[f"bank_{name}"].copy_(value) | ||
|
|
||
|
|
||
| reset_from_bank = mdp2.Term( |
There was a problem hiding this comment.
🔴 Critical · Compatibility — Keep the Lift reset contract
Deleting reset_from_bank breaks existing imports and configured Lift reset uses. Keep the old module and term functional during a targeted, documented deprecation with old- and new-path tests.
| if prim.HasAPI(UsdPhysics.RigidBodyAPI): | ||
| path = prim.GetPath().pathString | ||
| relative = path[len(root.GetPath().pathString) :] | ||
| entries[_entity_name(stage, path)] = RigidObjectCfg(prim_path=prim_path + relative, spawn=None) |
There was a problem hiding this comment.
🟡 Warning · Implementation — Reject flattened-name collisions
A/B and A_B both become A_B; the later entry silently replaces the first and contract events can target the wrong entity. Reject duplicate generated names.
| # Layouts: the bank's rows are reset states that every world shares, in the frame of its origin. | ||
| if bank_file.exists(): | ||
| data = np.load(bank_file) | ||
| if str(data["contract_digest"]) != rc.contract_digest(contract): |
There was a problem hiding this comment.
🟡 Warning · Implementation — Separate layout and mass validity
The whole-contract digest rejects a layout bank after a mass-range edit, contradicting the documented no-resolve workflow. Validate against the layout’s dependencies instead.
|
|
||
| def test_default_resets_keep_the_earlier_events_and_are_not_credited(): | ||
| scene = Scene(num_worlds=4) | ||
| task_mdp, state = build( |
There was a problem hiding this comment.
🟡 Warning · Test Quality — Exercise the claimed default-reset behavior
This case has no earlier reset writer and omits the outcome-tracking sampler; its sentinel and zero count cannot prove either claimed behavior. Add those conditions or narrow the test.
| reset_states = mdp.get_reset_states(state) | ||
|
|
||
| stored = reset_states.states["goal"] | ||
| assert ((stored >= 1.0) & (stored < 2.0)).all() and len(stored.unique()) == 12 # sampled, not the initial 0 |
There was a problem hiding this comment.
🟡 Warning · Test Quality — Drop probabilistic uniqueness assertion
Twelve valid independent draws may repeat, so requiring twelve unique values makes this test fail without a regression. Retain the range and nonzero assertions instead.
|
|
||
| @configclass | ||
| class TabletopPhysicsCfg(PresetCfg): | ||
| """Newton MJWarp with Newton's collision pipeline, whose contacts with the props are reproducible run to run.""" |
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Remove the contact reproducibility claim
This docstring promises reproducible prop contacts, while test_contract disables reproducible physics for them. Describe the configured collision pipeline without that claim.
|
|
||
|
|
||
| CANDIDATES = mdp2.TaskCfg( | ||
| RESET_STATE_GENERATOR = mdp2.TaskCfg( |
There was a problem hiding this comment.
🟡 Warning · Compatibility — Retain the candidate task name
Renaming module-level CANDIDATES breaks imports used to customize Lift generation. Keep a functional deprecated alias with replacement guidance and transition coverage.
| "target_success_rate": 0.5, | ||
| "kappa": 1.0, | ||
| # A world per object, as in small test runs, needs a roll per state. | ||
| "source": mdp.FromTask(RESET_STATE_GENERATOR, num_states=1024, max_rolls=20000), |
There was a problem hiding this comment.
🟡 Warning · Compatibility — Preserve Lift reset configuration
bank_size, history_length, target_success_rate, and kappa overrides no longer configure this task; its default also changes from 16 per-world states to 1024 grouped states. Preserve the old configuration through deprecation.
6819cf5 to
07e2304
Compare
A USD scene can carry its randomization as a usd-randomizer contract. contract_scene spawns the file and its rigid bodies; contract_task makes the layouts that scripts/tools/contract_bank.py solves offline the shared reset states of a reset_to_states event, and draws the contract's per-environment masses at startup. Adds Isaac-Contract-Tabletop-Franka-MDP2.
07e2304 to
a8c40fa
Compare
| from ..reach.reach_env_cfg import joint_limits, joint_state, robot | ||
| from . import mdp as tabletop | ||
|
|
||
| SCENE_USD = str(Path(__file__).with_name("tabletop.usda")) |
There was a problem hiding this comment.
Installed task lacks required files
The task reads tabletop.usda and tabletop.bank/bank.npz beside this module, but the package only includes *.pyi as package data and has no MANIFEST.in. A non-editable wheel omits these files, so loading the task fails when contract_task opens the scene. Include the USD file, bank, and row records in the package data.
| events["contract_layout"] = Event( | ||
| mdp.reset_to_states, | ||
| inputs={"env_origins": Entity("scene").env_origins}, | ||
| outputs=outputs, | ||
| params={"source": mdp.FromTensors(states), "shared": True}, |
There was a problem hiding this comment.
A valid contract that only changes masses produces verified samples with no moved bodies. The bank tool still writes empty prims, and contract_task creates a contract_layout event with no outputs. At startup, reset_to_states rejects its empty states with ValueError, so a scene that could run startup mass draws now fails to load. Reject banks with no moved rigid bodies with a clear message, or skip the layout event when the bank is empty.
Description
Scenes that carry their randomization: an MDP2 task can take its scene and how that scene varies from one USD file, so teams can share an environment's layout and its randomization as a file, and each application samples it its own way.
The idea in one minute
A randomization contract stored in the USD declares distributions, the operators that write them to the scene, and the conditions every sample must keep, such as props on the table, apart, settled, and stable. MDP2 runs it with two executors:
reset_to_statesevent (#9112)attributewrites ofphysics:massigets exactly the value any other executor of the same file draws for environmentiBecause layouts are reset states, the resets from #9112 provide the rest at no extra cost:
mdp.get_reset_states(env.state, "events.contract_layout").pin(rows).success_rate,episode_countsandstarted_fromare available per layout.At load,
contract_taskprints how it handles each contract node:bank,startup draws,checked offline, orignored. Nothing is skipped silently.Usage
Solve the bank once, in the solver's own environment, then train:
tabletop.bank/bank.npz) stores the contract's digest. A bank solved for an earlier version of the layout is refused at load.Changes
isaaclab_experimental.mdp2.contract:contract_sceneandcontract_task.scripts/tools/contract_bank.py: samples verified layouts with the reference solver and writes the bank, with records and receipts.Isaac-Contract-Tabletop-Franka-MDP2: a Franka hovering above a red prop. The table, three props and their randomization come fromtabletop.usda; the robot and MDP come from Isaac Lab.author_scene.pyregenerates the file.Limits
physics:massare run. Asset swaps, variants and presence would need different objects per world.Validation
test_contract.py:verify_capture=20): each world's bodies sit at the bank row it drew, plus its origin, and its masses equal independent contract draws for its environment. Swapping the quaternion order in the bank's states turns it red.-k Contractpasses.params/env.yamlreads back withload_yaml. The bank's tensors are described, not pickled, through the dump fix in MDP2 Resets #9112.uv run isaaclab -fpasses.Type of change
Checklist
pre-commitchecks withuv run isaaclab --formatsource/<pkg>/changelog.d/for every touched packageCONTRIBUTORS.mdor my name already exists there