Repository navigation
Seed variations with --seed - #1467
Conversation
Build-time variations drew from torch's global random state before Isaac Lab seeds it, so their values did not follow --seed and changed with every earlier draw in the process. ArenaEnvBuilder now passes ArenaEnvBuilderCfg.seed and the variation key "<asset_name>.<variation_name>" to configure_at_build_time, which seeds build_time_generator from both with a SHA-256 digest. HDRImageVariation and the light intensity, color, color temperature and direction variations draw from it through a new keyword-only generator argument on ChoiceSampler.sample and ContinuousSampler.sample. The same seed now draws the same build-time values. A drawn value does not depend on the other variations or on the order they are applied in, and torch's global random state is neither read nor advanced. Recorded replay still returns the recorded value without drawing. Signed-off-by: Clemens Volk <cvolk@nvidia.com>
Update the seed table and the variation-seed paragraph in env_builder.rst, and note that changing env_cfg.seed after the builder composes the environment, as Isaac Lab's RL scripts do, changes only the simulation RNG. Say in variations.rst that several build-time values need rebuilds with different seeds. Signed-off-by: Clemens Volk <cvolk@nvidia.com>
Say that a build-time value depends on --seed, the asset name and the variation name, and describe --seed in the CLI runner table as seeding the simulation and build-time variations. Signed-off-by: Clemens Volk <cvolk@nvidia.com>
Drop the seed_material variable, call the derived value variation_seed, and say in the comment that it is one seed per variation before giving the reasons for sha256 and the 8-byte cut. Signed-off-by: Clemens Volk <cvolk@nvidia.com>
[Medium impact] The PR appears safe to merge. SummaryBuild-time HDR and light variations now draw from separate generators seeded by the build seed and variation key.
No actionable issues were found. This assessment does not depend on a fix in PR #1458. Diagram%%{init: {'theme': 'neutral'}}%%
flowchart LR
A["Builder seed + variation key"] --> B["SHA-256"]
B --> C["Fresh CPU generator per variation"]
C --> D["HDR or light sampler"]
R["Recorded replay values"] --> E["Record and apply value"]
D --> E
Reviews (1) · Last reviewed commit: "Name what the build-time seed depends on..." · Reviewed by Greptile |
Signed-off-by: Clemens Volk <cvolk@nvidia.com>
Keep only what a reader of the builder page needs: --seed now also fixes build-time variation values. The per-variation generator is described in variations.rst and in the code. Signed-off-by: Clemens Volk <cvolk@nvidia.com>
Say only that several build-time values need rebuilds with different seeds, which the Experiment Runner provides. What a value depends on is in configure_at_build_time's docstring. Signed-off-by: Clemens Volk <cvolk@nvidia.com>
🤖 Isaac Lab-Arena Review BotSummaryThis PR gives each build-time variation (the HDR image and the four light variations) its own CPU Design, Boundaries & Scope
Findings🟡 Warning: isaaclab_arena/variations/variation_base.py:59: pass the generator to VerdictMinor fixes needed |
configure_at_build_time now builds the per-variation generator locally and passes it to _realize_at_build_time, instead of storing it on the variation as build_time_generator. The generator only matters during the build, so it no longer outlives it as variation state. The HDR image and light variations, and the test variations, draw with generator=generator. The seed test reads the generator a build-time test variation receives. Signed-off-by: Clemens Volk <cvolk@nvidia.com>
ArenaEnvBuilder._apply_build_time_variations, VariationRecorder.attach and recorded variation replay each built the "<asset_name>.<variation_name>" key of every enabled variation themselves. They now share get_enabled_variations_by_key, next to VariationBase, which skips disabled variations and asserts on a duplicate key. The recorder still asserts when a key is already attached from an earlier attach call. Signed-off-by: Clemens Volk <cvolk@nvidia.com>
Run-time variations (object mass, object disappear, camera extrinsics and intrinsics) drew in their reset events from torch's global random state, so any other code that used that state, a policy for example, changed the values they drew. SamplerBase now holds a generator, set with set_generator. ChoiceSampler, UniformSampler and BernoulliSampler draw from it, and from torch's global random state while none is set. VariationBase.configure_at_build_time builds the generator from the same SHA-256 digest of the seed and the variation key as before and gives it to the variation's sampler, for build-time and run-time variations alike. apply_cfg passes it to the rebuilt sampler, as it does the replay sampler and the sample listeners. Replayed rows still take precedence over the generator. The generator argument is gone from ChoiceSampler.sample, ContinuousSampler.sample and _sample, and from _realize_at_build_time, so the five build-time variations call sampler.sample() as on main. Build-time values do not change. Run-time values for a given --seed differ from main, because they no longer come from the global state. Signed-off-by: Clemens Volk <cvolk@nvidia.com>
env_builder.rst and variations.rst now say that each variation draws from its own generator, seeded from --seed and the variation's key, and that run-time draws still depend on the order in which environments reset. The agentic CLI table now says --seed seeds the simulation and variations, since run-time variations no longer draw from the simulation's random state. Signed-off-by: Clemens Volk <cvolk@nvidia.com>
Signed-off-by: Clemens Volk <cvolk@nvidia.com>
Signed-off-by: Clemens Volk <cvolk@nvidia.com>
Signed-off-by: Clemens Volk <cvolk@nvidia.com>
Signed-off-by: Clemens Volk <cvolk@nvidia.com>
|
/review |
Check same-seed repeatability and variation-order independence in one build-time test. Pin the seed to literal sampler values instead of recomputing the digest in the test. Drop the mass variation seeding test, and draw once per variation in the disappear test. Signed-off-by: Clemens Volk <cvolk@nvidia.com>
Restore main's SamplerBase class docstring and say on set_generator that None draws from torch's global random state. Shorten the configure_at_build_time args and seed comment, and point the per-episode seeding TODO at IsaacLabArenaManagerBasedEnv._started_episode_count. Drop the seeding sentence from the _apply_build_time_variations docstring. Signed-off-by: Clemens Volk <cvolk@nvidia.com>
The key in VariationRecorder.attach's duplicate check is a variation key, not an asset name. Also drop a comment that repeats the next line. Signed-off-by: Clemens Volk <cvolk@nvidia.com>
The seed section said run-time draws depend on reset order. State the effect instead: which environment and episode gets which run-time value depends on num_envs and on when environments reset. Say "variation values" in the intro, since build-time values follow --seed too. Signed-off-by: Clemens Volk <cvolk@nvidia.com>
Name the value the follow-up needs: the episode counter before the reset plus the environment's position among the sorted env ids, since _reset_idx counts the whole batch before the reset events run. Call the seed "the seed", as the Args do. Signed-off-by: Clemens Volk <cvolk@nvidia.com>
The per-episode seeding TODO in VariationBase.configure_at_build_time pointed at IsaacLabArenaManagerBasedEnv._started_episode_count, but no class by that name exists. The counter lives on IsaacLabArenaManagerBasedRLEnv, so use that name. Signed-off-by: Clemens Volk <cvolk@nvidia.com>
With the seed alone, every variation's generator would start from the same state, so variations with equal sampler cfgs would draw equal values. One shared generator would instead make a variation's values depend on which other variations are enabled. Move the 64-bit comment next to the digest[:8] line it explains. Signed-off-by: Clemens Volk <cvolk@nvidia.com>
Each variation draws from its own CPU generator, and the reset events draw one value per starting environment in episode-start order. On CPU, torch.rand and torch.randint give the same values however the draws are split across resets, so the k-th episode to start already gets the same run-time values for any num_envs. Replace the TODO with a comment on why the generator stays on CPU, and correct the env_builder.rst sentence that said the values depend on num_envs. Signed-off-by: Clemens Volk <cvolk@nvidia.com>
test_disappear_draws_ignore_global_random_state only checked that BernoulliSampler draws from its generator. It needed a SimulationApp because importing ObjectDisappearVariation loads pxr. Check the sampler directly in test_variation_base.py instead: no build-time variation uses BernoulliSampler, so the build-time seeding tests do not cover it. test_object_disappear_variation.py matches main again. Signed-off-by: Clemens Volk <cvolk@nvidia.com>
test_recorder_rebinding_starts_fresh_runtime_records came in with #1435 and still called configure_at_build_time() without arguments, which this branch made required. Pass seed 0 and the asset.recorder_test key the test already reads back, as the other recorder tests do. Signed-off-by: Clemens Volk <cvolk@nvidia.com>
Call `ArenaEnvBuilder.build_env_cfg()` in `test_build_time_variation_seeding.py`, so its three tests run on main again. ## Why this change? [#1474](#1474) renamed `ArenaEnvBuilder.compose_manager_cfg()` to `build_env_cfg()`. [#1467](#1467) added `test_build_time_variation_seeding.py`, which still calls `compose_manager_cfg()`, and the two merged within hours of each other. On main, all three tests in the file fail with `AttributeError`. ## What changes? The test helper `get_build_time_values()` calls `build_env_cfg()`. No other code on main uses the old name. ## Validation - `pre-commit` passes on the changed file. - `test_build_time_variation_seeding.py`: 3 passed on this branch. Signed-off-by: Clemens Volk <cvolk@nvidia.com>
Since #1467 the environment seed also fixes build-time and run-time variation values. The comment in the seeds Experiment still said it covers simulation randomness and run-time variation draws only, and the variations page still named the --seed flag. Match the comment to the env_builder page, name environment_builder.seed on the variations page, and describe the placement seed by the layouts it fixes. Signed-off-by: Clemens Volk <cvolk@nvidia.com>
Since #1467 the environment seed also fixes build-time and run-time variation values. The comment in the seeds Experiment still said it covers simulation randomness and run-time variation draws only, and the variations page still named the --seed flag. Match the comment to the env_builder page, name environment_builder.seed on the variations page, and describe the placement seed by the layouts it fixes. Signed-off-by: Clemens Volk <cvolk@nvidia.com>
Run the concept-page examples with `experiment_runner.py` and checked-in Experiment YAMLs instead of `policy_runner.py`. Where these pages named runner flags, name the matching `environment_builder` and `policy` fields of a Run instead. ## Why this change? Evaluation is moving from `policy_runner.py` to `experiment_runner.py`, which reads each evaluation from an Experiment YAML file. The concept pages still showed `policy_runner.py` commands with flags such as `--num_envs`, `--placement_seed`, `--presets`, and `--additional_table_objects`. `experiment_runner.py` accepts the shared builder flags because it uses the Arena argument parser, but it ignores them: each Run reads these values from its `environment_builder` section. A reader who passes them to the Experiment Runner gets no error and no effect. Each page now includes the YAML file it runs with `literalinclude`, so the page and the file cannot drift apart. ## What changes? New Experiments under `isaaclab_arena_environments/experiment_configs/concepts/`: - `maple_table_additional_objects_experiment.yaml` (`concept_object_and_robot_placement.rst`). The page shows a `runs.additional_objects.environment.additional_table_objects=[...]` override to try other objects. - `maple_table_seeds_experiment.yaml` (`env_builder.rst` and `pooled_placement.rst`). Its comments describe the seeds as main now uses them: since #1467 the environment seed also fixes build-time and run-time variation values. `pooled_placement.rst` now uses placement seed 7 instead of 42; the value is arbitrary on that page. - `droid_table_multi_object_placement_experiment.yaml` (`homogeneous_and_heterogeneous_placement.rst`). The heterogeneous example is the override `runs.multi_object_placement.environment.mode=heterogeneous`. - `kitchen_bench_robot_placement_experiment.yaml` (`solver.rst`), which selects the graph spec `kitchen_bench/kitchen_bench_lightwheel_pick_and_place.yaml` by its path in `environment.type`. `variations.rst` now lists, enables, and tunes variations with `droid_pnp_variations_experiment.yaml`, which the variations quickstart already uses. The separate "Configuring variations in an experiment config" section goes away. Tuned control parameters are added with `+runs.variations_demo.variations.<path>=<value>` overrides. The page also says that a command-line override can't change an entry the YAML writes as a dotted key, such as `light.hdr_image.enabled`: the plain override fails with "Could not override", and the `+` form loses to the YAML's dotted key in `overrides_from_dict`. The `--list_variations` sample keeps main's `pick_up_object` listing and adds the per-Run header that `experiment_runner.py` prints. Other pages: - `env_builder.rst`, `pooled_placement.rst`, and `variations.rst` name `environment_builder.seed`, `placement_seed`, `solve_relations`, and `resolve_on_reset` instead of the runner flags. - The physics pages name `environment_builder.presets` (`PHYSX` or `NEWTON`). `physics_backend_selection.rst` says the Environment Runner supports only PhysX, because `environment_runner.py` rejects `--presets newton` and Newton environments. - The Camera renderer section that #1707 added to `physics_backend_selection.rst` names `ArenaEnvBuilderCfg.camera_renderer` and keeps its Experiment YAML, without the `policy_runner.py` command. - `policy/index.rst` describes how `policy.type` selects a policy by registered name or class path. It still says that `policy_runner.py` turns each configuration field into a flag, and that `device` and `num_envs` defaults must match its shared flags. That rule does not apply to `experiment_runner.py`, which does not pass those flags to the policy config. - `in_process_policies.rst` shows the `replay` policy as a Run's `policy` section. A Run with `replay` can leave out `rollout_limit`, because the Experiment Runner uses the policy's episode length. A Run with `zero_action` must set it. `isaaclab_arena/tests/test_concept_experiment_configs.py` loads every Experiment under `experiment_configs/concepts/`, and loads each one again with the override its page documents. It also loads `droid_pnp_variations_experiment.yaml` with the tuned variation overrides, and checks that the YAML enables the HDR image and wrist-camera variations that those overrides tune. It runs without Isaac Sim. It does not check variation paths, registered object names, or whether the graph spec builds, because those are resolved only when the environment is built. ## Validation Rebased onto main at `9226352302` (2026-11-26): `test_concept_experiment_configs.py` passes (9 tests) in the Arena Docker container, and the docs build with `-W` passes. Earlier rounds: In the Arena Docker container, with the branch rebased onto main at `c36daa6bb2`: - Every Experiment the changed pages show composes with `load_arena_experiment_from_config_file`, with and without each documented override. So does a Run with the `replay` policy section from `in_process_policies.rst` and no `rollout_limit`. - `runs.variations_demo.variations.light.hdr_image.enabled=false` fails with "Could not override", and the `+` form of it leaves `light.hdr_image.enabled=true` as the last variation override. Before the rebase, on base `7050ecbc9b`, every Experiment ran end to end with `experiment_runner.py` and a 2-step limit, including heterogeneous mode, `placement_seed=null`, and tuned variations on the earlier variations YAML. The Lightwheel kitchen Experiment downloaded its background through the Lightwheel SDK. I did not rerun them after the rebase, and the tuned overrides on `droid_pnp_variations_experiment.yaml` have not run end to end. --------- Signed-off-by: Clemens Volk <cvolk@nvidia.com>
Give each variation's sampler its own generator, seeded from
--seedand the variation key, so build-time and run-time variation values repeat for the same seed.Why this change?
Build-time variation values cannot be reproduced today.
ArenaEnvBuilder.compose_manager_cfg()applies build-time variations while it composes the environment configuration, and Isaac Lab seeds torch withenv_cfg.seedonly later, whenManagerBasedEnv.__init__creates the environment. SoHDRImageVariationand the light variations draw from torch's global random state as it happens to be.Run-time variations (
ObjectMassVariation,ObjectDisappearVariation,CameraExtrinsicsVariation,CameraIntrinsicsVariation) draw in their reset events from the same global random state, so a policy or another event term that draws random numbers changes their values.What changes?
VariationBase.configure_at_build_time(seed, variation_key)gives each enabled variation's sampler a generator seeded from--seedand the key<asset_name>.<variation_name>. The samplers draw from it.get_enabled_variations_by_keybuilds the variation keys in one place, for the builder, the recorder and recorded replay.Behavior changes
--seedgives the same variation values, build-time and run-time. With the default seed 42 every run gets the same values; pass another--seedfor others. Experiment Runner rebuilds still get new values, because each rebuild adds its index to the seed.--seed, the k-th episode to start gets the same values for anynum_envs. Which environment runs it still depends onnum_envsand on when environments reset.configure_at_build_timerequiresseedandvariation_key.Validation
pre-commitpasses on the changed files.apply_cfgkeeps the generator.get_enabled_variations_by_keyskips disabled variations and rejects duplicate keys.BernoulliSamplerdraws from its generator and leaves torch's global random state unchanged.--seed 7and 100 episodes, runs withnum_envs1, 3, 5 and 8 gave the k-th episode to start the same values for all 100 episodes.