Skip to content

Use shared reset sampler and rename NIST assembly task - #9141

Merged
ooctipus merged 4 commits into
isaac-sim:mainfrom
ooctipus:codex/nist-variant-native-sampler
Nov 23, 2026
Merged

ooctipus merged 4 commits into
isaac-sim:mainfrom
ooctipus:codex/nist-variant-native-sampler

Conversation

@ooctipus

@ooctipus ooctipus commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Use Isaac Lab's shared ResetStateSampler for the NIST assembly reset bank. The NIST-owned BalancedVariantScore preserves the previous Beta weights and four row/column balancing passes; the shared SuccessMonitor still supplies each reset slot's success rate.

Register the retained, reset-selectable task as IsaacContrib-NIST-Franka. Its composition root is nist_env_cfg.py:NISTEnvCfg, with nist_env.py:NISTEnv, nist_scene_cfg.py:NISTSceneCfg, and NISTPPORunnerCfg. 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 /Factory path.

Migration

Use --task IsaacContrib-NIST-Franka for training and playback. Both IsaacContrib-Factory-Franka and IsaacContrib-Factory-Variant-Franka are retired. The PPO experiment name is now nist, and reset diagnostic keys use the nist_ 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

  • NIST sampler tests: 4 passed on CPU/GPU, including a per-slot probability comparison with the previous formula.
  • Kitless canonical registration and old-ID/module absence test: passed after rebase.
  • NIST configuration check: shared solver-fault reset event precedes state reset; reward and termination use the shared Newton functions.
  • Environment documentation tests: 34 passed; the generated browser lists IsaacContrib-NIST-Franka.
  • Conflict-resolution format and lint hooks, changelog check against upstream/main, and generated-browser check: passed after rebase.
  • Before this rebase, the GPU environment smoke test passed; it has not been rerun on the rebased branch.

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 main at 6014f5416, including the shared Newton solver-fault fix in #8917 and the G1 preview-link fix in #9169. No unmerged PR dependency remains.

@ooctipus
ooctipus requested a review from a team November 21, 2026 04:57
@github-actions github-actions Bot added the isaac-lab Related to Isaac Lab team label Nov 21, 2026
@greptile-apps

greptile-apps Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[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

  1. P2 Reset seeds no longer work ▶

Summary

Moves NIST reset selection to the shared ResetStateSampler and renames the retained task to IsaacContrib-NIST-Franka.

  • Assembly resets use the shared sampler and keep balanced slot weights.
  • The reset-selectable assembly task now appears under its NIST name.
  • The standalone Factory assembly task is no longer available.

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]
Loading

Reviews (2) · Last reviewed commit: "Rename NIST assembly task and modules" · Reviewed by Greptile

Comment on lines +127 to +137
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)

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 Reset seeds no longer work

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.

@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: 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)

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

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 · 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)]

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 · 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

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 · 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):

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 — 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."""

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 — 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

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 — 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"))],

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

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

@ooctipus
ooctipus force-pushed the codex/nist-variant-native-sampler branch from a4f0b6e to 4077fd4 Compare November 21, 2026 07:19
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Nov 21, 2026
@ooctipus ooctipus changed the title Use shared reset sampler for NIST assembly variants Promote NIST assembly variants to Factory task and use shared reset sampler Nov 21, 2026
@ooctipus ooctipus changed the title Promote NIST assembly variants to Factory task and use shared reset sampler Use shared reset sampler and rename NIST assembly task Nov 21, 2026
@greptile-apps

greptile-apps Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Comments Outside Diff

These findings could not be posted inline.

  • P1 Curriculum tests cannot load source/isaaclab_tasks/isaaclab_tasks/contrib/nist/mdp/curriculums.py:47 ▶

    Deleting curriculums.py leaves test_curriculum.py:14 importing DifficultyScheduler from that module. Collecting the kitless tests now raises ModuleNotFoundError before either curriculum test can run. Remove the retired tests along with the module, or update them to test a supported replacement.

@ooctipus
ooctipus force-pushed the codex/nist-variant-native-sampler branch from 8e58570 to 1914d1c Compare November 23, 2026 11:52
@ooctipus

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 Nov 23, 2026
@maxkra15
maxkra15 self-requested a review November 23, 2026 13:40
@ooctipus
ooctipus force-pushed the codex/nist-variant-native-sampler branch from 1914d1c to 74aa29e Compare November 23, 2026 21:10
@ooctipus
ooctipus merged commit 2d40e56 into isaac-sim:main Nov 23, 2026
63 of 64 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation infrastructure isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants