Repository navigation
Use shared reset sampler and rename NIST assembly task - #9141
Conversation
[Medium impact] The changes affect the contributed NIST assembly task and its users. Fix the retained tests' import of the deleted curriculum module before merging. Findings
SummaryMoves NIST reset selection to the shared
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[Completed episode] --> B[SuccessMonitor]
B --> C[BalancedVariantScore]
C --> D[ResetStateSampler]
D --> E[Stored reset slot]
E --> F[Restore environment]
Reviews (2) · Last reviewed commit: "Rename NIST assembly task and modules" · Reviewed by Greptile |
| self._sampler = ResetStateSampler( | ||
| self._sampling_cfg.replace(seed=(self._sampling_cfg.seed + (env.cfg.seed or 0)) % 2**32), | ||
| env.num_envs, | ||
| self.state_data.shape[0], | ||
| env.device, | ||
| metrics={ | ||
| "monitor_success_rate": self.monitor_success_rate, | ||
| "cell_indices": self.state_cell_indices, | ||
| }, | ||
| ) | ||
| self._sampler.reset(env_ids=env_ids) |
There was a problem hiding this comment.
reset(seed=...) no longer restarts variant reset draws. The new sampler starts from env.cfg.seed and then advances its own random state. The inherited reset method only seeds the global generators; it never calls the sampler's reseed(). After the bank is collected, repeating an explicit seed can therefore produce different starting states, unlike the previous Torch path.
Forward explicit reset seeds to the sampler and add a repeat-seed test.
There was a problem hiding this comment.
Isaac Lab Review Bot
Needs attention: Scope and over-engineering (1), Compatibility and deprecation (2), Implementation (1), Style consistency (3), Test quality (2). Other reviewed categories look good.
- PR description: Scope matches; smoke validation is baseline-only, and selection timings include batch sizes and 50 iterations but need baseline/candidate revisions, command, hardware, backend, software versions, and warmup count for reproducibility.
- Design and architecture: Architecture looks good.
- Scope and over-engineering: Minimal implementation: Extend variant_reset_accumulator and the existing NIST reset configs, keep stateful balancing in variant_sampling, separate its declarative configuration, and delete the full-environment assignment copy in favor of selected-slot updates; collection, monitoring, balancing, and shared selection remain essential. No source modules were added, and no parallel subsystem needs retention. Scope is cohesive; no split recommended.
- API: API changes look good.
- Compatibility and deprecation: Breaking changes: legacy sampler imports, strategy configurations, and cell_probabilities disappear without functional bridges; retain them through targeted warnings, migration documentation, announced removal guidance, and transition coverage.
- Implementation: Precollection silently discards additional configured scores; preserve them when replacing the balancing score or explicitly reject unsupported combinations.
- Style consistency: BalancedVariantScoreCfg shares a module with Warp runtime implementation, violating the required configuration boundary; move the declarative config into a lightweight module.
- Test quality: The expected probabilities repeat production's weighting and balancing transformation, weakening independent proof; replace that oracle with established legacy vectors or analytic fixtures.
Significant concerns. Posted 9 inline findings.
Automated review; human maintainers own approval decisions.
| self._num_cells = 1 | ||
| self._num_variants = 1 | ||
| self._variant_ids = torch.zeros(env.num_envs, dtype=torch.int32, device=env.device) | ||
| self.cell_probabilities = torch.full((1, 1), torch.nan, device=env.device) |
There was a problem hiding this comment.
🟡 Warning · Compatibility — Retain cell probability diagnostics
Callers lose the accumulator's initialized, updated label-by-variant cell_probabilities tensor. Preserve that attribute through a documented, warning-backed deprecation transition and validate its old and replacement paths.
| }, | ||
| ) | ||
| self._sampler.reset(env_ids=env_ids) | ||
| self.sampled_slots.copy_(self._sampler.state_ids.torch) |
There was a problem hiding this comment.
🟡 Warning · Scope Complexity — Copy only selected slot assignments
Each partial reset now copies assignments for all environments, where the previous path updated only env_ids. Assign only the sampler's selected IDs to sampled_slots[env_ids].
| if not isinstance(score_cfg, BalancedVariantScoreCfg): | ||
| raise TypeError("Variant reset sampling requires BalancedVariantScoreCfg.") | ||
| self._sampling_cfg = self._sampling_cfg.replace( | ||
| scores=[score_cfg.replace(num_labels=len(self.state_tag_names), num_variants=self._num_variants)] |
There was a problem hiding this comment.
🟡 Warning · Implementation — Do not discard configured scores
Replacing scores with scores[0] silently removes every additional score accepted by ResetStateSamplerCfg. Retain those scores or reject unsupported combinations explicitly before sampling.
| floor: float = 1e-4 | ||
|
|
||
|
|
||
| @configclass |
There was a problem hiding this comment.
🟡 Warning · Compatibility — Preserve legacy sampling contracts
Removing Sampler, SamplerCfg, and both strategy configs breaks imports and existing sampling configurations. Keep them functional through a targeted-warning deprecation bridge, document migration and removal, and validate both paths.
| @configclass | ||
| class BetaSamplingStrategyCfg: | ||
| """Weight states near the target success rate.""" | ||
| class BalancedVariantScoreCfg(SamplingScoreCfg): |
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Separate score config from runtime
Importing the declarative score config now imports Warp kernels and the runtime score. Put the config in a lightweight module and resolve the implementation separately, as required for configured components.
| self._balanced_cells: wp.array | None = None | ||
|
|
||
| def score(self, metrics: Mapping[str, wp.array], out: wp.array) -> None: | ||
| """Apply the original four row/column normalization passes to the Beta weights.""" |
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Document the current score contract
“Original” describes refactoring history rather than the current API. Document the required metric keys, cell layout, in-place output, and four-pass rule without referring to the previous implementation.
| ) | ||
|
|
||
|
|
||
| @wp.kernel |
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Isolate custom Warp kernels
The three custom kernels use module-level declarations instead of the required cached factories with module="unique". Use that pattern so their compilation and specializations remain isolated.
| @pytest.mark.parametrize("beta_weight,floor", [(1.0, 1e-4), (0.0, 1.0)]) | ||
| @pytest.mark.parametrize( | ||
| "device", | ||
| ["cpu", pytest.param("cuda:0", marks=pytest.mark.skipif(not torch.cuda.is_available(), reason="CUDA unavailable"))], |
There was a problem hiding this comment.
🟡 Warning · Test Quality — Respect selected CUDA devices
The hard-coded cuda:0 row ignores the test runtime's multi-GPU device mask. Keep CPU and CUDA coverage, but select CUDA devices with test_devices(DeviceScope.CUDA).
| ) | ||
|
|
||
| # Compare against the original Torch balancing rule, including uneven cell occupancy. | ||
| expected = floor + beta_weight * rates.pow(0.66) * (1.0 - rates).pow(0.34) |
There was a problem hiding this comment.
🟡 Warning · Test Quality — Use independent expected probabilities
The expected vector reconstructs the same Beta weighting and four-pass transformation as production, allowing a shared mathematical error to pass. Use independently established legacy vectors or analytic fixtures.
a4f0b6e to
4077fd4
Compare
Comments Outside DiffThese findings could not be posted inline.
|
8e58570 to
1914d1c
Compare
|
run-ci |
1914d1c to
74aa29e
Compare
Summary
Use Isaac Lab's shared
ResetStateSamplerfor the NIST assembly reset bank. The NIST-ownedBalancedVariantScorepreserves the previous Beta weights and four row/column balancing passes; the sharedSuccessMonitorstill supplies each reset slot's success rate.Register the retained, reset-selectable task as
IsaacContrib-NIST-Franka. Its composition root isnist_env_cfg.py:NISTEnvCfg, withnist_env.py:NISTEnv,nist_scene_cfg.py:NISTSceneCfg, andNISTPPORunnerCfg. Remove the former static Factory implementation and its aliases. The rename preserves the retained task's assembly logic, physics, actions, observations, and reset configuration. Following upstream #8917, solver-fault detection, reward clearing, and final-observation masking use the shared Newton terms; the task-local solver-reset helper is removed. The test for the retired Factory curriculum is removed with its implementation. The external USD assets remain at their existing/Factorypath.Migration
Use
--task IsaacContrib-NIST-Frankafor training and playback. BothIsaacContrib-Factory-FrankaandIsaacContrib-Factory-Variant-Frankaare retired. The PPO experiment name is nownist, and reset diagnostic keys use thenist_prefix. The former static task's checkpoints need their saved environment and agent configuration; its policy and observations are not automatically compatible with the retained task.Validation
IsaacContrib-NIST-Franka.upstream/main, and generated-browser check: passed after rebase.The shared sampler uses independent per-environment random streams, so a fixed seed can select different exact reset slots while preserving the sampling probabilities. The bank still uses the 0.66 target, 50-outcome monitor, 1e-4 floor, four balancing passes, and uniform playback mode.
Prior local GPU selection timing for 8,192 reset states and 4,096 environments: 0.146 ms for the shared sampler versus 0.205 ms for the previous Torch path (50 measured iterations after warmup, device synchronized after each batch).
Base
Rebased on upstream
mainat6014f5416, including the shared Newton solver-fault fix in #8917 and the G1 preview-link fix in #9169. No unmerged PR dependency remains.