Skip to content

Decorrelate placement candidate seeds across placement seeds - #1523

Merged
alexmillane merged 5 commits into
mainfrom
lgulich/fix/decorrelate-placement-seeds
Nov 2, 2026
Merged

alexmillane merged 5 commits into
mainfrom
lgulich/fix/decorrelate-placement-seeds

Conversation

@lgulich

@lgulich lgulich commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

Fix placement_seed so consecutive seeds produce independent layouts.

Why this change?

PlacementCandidateGenerator seeded candidate i of environment e with placement_seed + e * candidates_per_env + i. With 50 candidates, placement_seed=42 used seeds 42–91 and placement_seed=43 used 43–92, so the two shared 49 of 50 candidates. ObjectPlacer keeps the best-ranked candidate, so consecutive seeds usually returned the same layout. Parallel environments overlapped the same way: environment 1 of seed 42 used the same seeds as environment 0 of seed 92. Pool refills had the same problem, because a refill offset placement_seed by the number of candidates already used.

In a cluttered syringe scene, seeds 42, 43 and 44 rendered identical layouts, while seeds 42, 142 and 242 differed.

What changes?

  • PlacementCandidateGenerator._seed_candidate seeds each candidate from a SHA-256 hash of (placement_seed, env_id, candidate_id). Both seeding sites, candidate sampling and clutter release, use it.
  • Pool refills derive their seed from (base seed, "pool_refill", solve index) instead of offsetting placement_seed.
  • utils.random.derive_seed holds the hash and is shared with VariationBase; variation values are unchanged.

The same seed still reproduces the same layout, but layouts for a given seed differ from those produced before this change.

Not in this PR: the set of scenes still depends on num_envs, because the pool keeps a queue per env and stores ceil(pool_size / num_envs) layouts in each. A follow-up PR will key layouts by run-wide episode. It needs a solver change first, so this PR leaves that part out.

Validation

  • New tests: consecutive seeds share no initial candidate; an env's initial candidates do not depend on num_envs or the candidate count. The different-seeds test covers seeds 43 and 123 and failed before this change for 43.
  • The simulator-free placement suites pass on this branch (204 tests): test_object_placer_reproducibility, test_placement_events, test_placement_sampler, test_heterogeneous_placement, test_relation_solver_interface, test_clutter_placement, test_object_placer_init, test_placement_result, test_placement_layouts, test_validate_placement and test_variation_base. They ran against the pinned Isaac Lab (e3f7d9f) with warp 1.17, outside the container.
  • Not run: simulator tests.
  • pre-commit passes on the changed files.

Candidate i of environment e was seeded with placement_seed + e * candidates_per_env + i,
so consecutive placement seeds shared all but one candidate and usually selected the same
layout. Derive each candidate's seed from a hash of (placement_seed, env, candidate).

Signed-off-by: Lionel Gulich <[email protected]>
@greptile-apps

greptile-apps Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

The PR derives each candidate seed from a SHA-256 hash of placement_seed, env_id, and candidate_id, replacing overlapping seed ranges.

  • Each placement candidate gets a repeatable seed tied to its placement seed and identity.

Reviews (1) · Last reviewed commit: "Decorrelate placement candidate seeds ac..." · Reviewed by Greptile

@arena-review-bot

Copy link
Copy Markdown
Contributor

🤖 Isaac Lab-Arena Review Bot

Summary

This PR changes how each placement candidate is seeded. Instead of placement_seed + flat index, it uses a SHA-256 hash of (placement_seed, env_id, candidate_id), so consecutive seeds no longer share most of their candidates. The fix is small and in the right place, and the new test does catch the old overlap. Two things need attention before merge. First, an existing test in PR CI will most likely fail because the clutter release order changes. Second, pooled refills still add an offset to placement_seed, so a refill for one seed reuses the first batch of another seed.

Findings

🟡 Warning: isaaclab_arena/relations/placement_candidate_generator.py:69 — The new seed also changes the clutter release order. test_mesh_collision.py::test_tilted_clutter_requires_bbox_collision (line 1375) expects one specific order, and seed 42 now gives the other one. The test has no markers, so it runs in PR CI. It should accept either order.

🟡 Warning: isaaclab_arena/relations/placement_candidate_generator.py:76 — PooledObjectPlacer._prepare_seeded_solve still shifts placement_seed by 50 * num_envs per refill with default settings. So seed 42's first refill builds the same candidates as seed 92's first batch. This was already true before the PR, but it is the same overlap the PR is meant to remove. The comment at pooled_object_placer.py:173 also still describes the old placement_seed + candidate_idx scheme.

🔵 Improvement: isaaclab_arena/relations/placement_candidate_generator.py:77 — variation_base.py:124-126 already derives torch seeds with the same SHA-256 method, but reads the bytes big-endian. A shared helper in utils/random.py would keep the two consistent. It could also replace placement_seed + variant_set_idx in assign_variants_for_envs (bounding_box_helpers.py:44). That line has the same problem: with two or more random_choice=True object sets, set 1 at seed s gets the same variant seed as set 0 at seed s+1. That part can be a follow-up.

🔵 Improvement: isaaclab_arena/tests/test_object_placer_reproducibility.py:145 — The new test could be a second parameter case of test_object_placer_different_seeds_produce_different_results, instead of a near-copy.

Test Coverage and CI Cost

  • I didn't run any tests. When I reviewed, the CI test jobs on f5697c21 were still building the image.
  • The tilted-clutter finding comes from my own emulation of torch's CPU generator, checked against the known torch.manual_seed(42); torch.rand(5) output. Please confirm it in CI.
  • The author's run on 34bb35a8 released clutter in the order the assets were listed, without the shuffle. That run could not have caught this.
  • Some seeded tests outside the author's list expect seed 17 or 42 to give enough valid or settled layouts with fallbacks off: test_clutter_placement.py and clutter/test_clutter_collection.py. I couldn't predict those results, so watch them in CI.

Verdict

Minor fixes needed

@lgulich

lgulich commented Oct 25, 2026

Copy link
Copy Markdown
Collaborator Author

CI note: the "Run tests" job failed twice (59 min, then 34 min on rerun). Both logs stop in test_asset_registry.py::test_all_assets_in_registry[physx] while assets are still downloading from the staging S3 bucket, with no test failure or assertion before the log ends. That test does not use placement seeding, which is the only thing this PR changes. The same job passes on main (48 min). Could a maintainer check whether this is a runner timeout or resource issue?

Move the SHA-256 seed derivation into utils.random.derive_seed and use it for
placement candidates, build-time variations (unchanged values), and pooled
refills. A refill used to offset placement_seed by the previous candidate
count, so seed s's refill replayed seed s + N's first batch; it now derives its
seed from (base seed, solve index).

Test the fix where it happens: consecutive seeds share no initial candidate, and
an env's candidates do not depend on num_envs or the candidate count. Fold the
consecutive-seed placer test into the different-seeds test, and let the tilted
clutter test accept rods released side by side as well as stacked.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Lionel Gulich <[email protected]>

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

LGTM.

Let's make a decision on Ben's question.

With the same objects in every env, the pool now indexes layouts by run-wide
episode instead of keeping a queue per env. Arena numbers episode starts across
envs, and the reset event gives the episode it starts layout j. Layout j is the
best of max_placement_attempts candidates seeded from (placement_seed, j,
candidate), solved in the fixed group j // layouts_per_solve. Fixed groups
matter because the solver stops on its batch's mean loss. A run of N episodes
therefore uses the same N layouts on 16 or 128 envs.

Scenes with a RigidObjectSet keep the per-env queues, because each env's
objects, and so its layouts, depend on num_envs. Per-env pool methods still
work in episode mode; they fill the queues on first use, and layouts_per_env()
lists the episode layouts so offline validation checks the layouts resets use.

Signed-off-by: Lionel Gulich <[email protected]>
This reverts commit 7343afe.

Episode-keyed layouts need the relation solver to stop each row on its own
convergence; until then, solving layouts in fixed groups is serial and slow at
high env counts. It moves to a follow-up PR together with a solver change, so
this PR stays the placement seed fix.

Signed-off-by: Lionel Gulich <[email protected]>
Resolve conflicts from the move of placement_candidate_generator.py to relations/optimization/: keep main's oriented-bounds sampling and alignment check, and seed both candidate sites with _seed_candidate. Point the reproducibility test's imports at the moved modules.

Signed-off-by: Lionel Gulich <[email protected]>
@alexmillane
alexmillane merged commit 3b0f10c into main Nov 2, 2026
10 checks passed
@alexmillane
alexmillane deleted the lgulich/fix/decorrelate-placement-seeds branch November 2, 2026 18:58
zhx06 added a commit that referenced this pull request Nov 4, 2026
Write each Run's placement diagnostics to its output directory, and add
RoboLab and KitchenBench Experiments that measure placement success with
the normal experiment runner. This replaces the standalone benchmark
runner from the first revision of this PR.

## Why this change?

A placement change can help one scene and hurt another, and a few
hand-picked scenes don't show that. #1556 made each environment build
record per-check validation counts, but the experiment runner dropped
them after the build. This PR keeps them, so placement success can be
measured across all the maintained specs.

## What changes?

- `_build_environment_from_cfg()` in `run_execution.py` writes
`placement_diagnostics_rebuild<i>.json` to the Run directory for every
rebuild that solves relation placement. This applies to every
Experiment, including policy evaluations.
- `PlacementDiagnostics` gets `num_envs` and `save()` / `load()`.
- `robolab_placement_experiment.yaml` and
`kitchen_bench_placement_experiment.yaml` in
`isaaclab_arena_benchmarking/experiment_configs/` have one Run per spec,
each with 30 environments, a zero-action policy and one step.
- Each Run has its own placement seed, 100000 apart, so tasks that share
a scene solve different candidates.
- Tests check that each experiment lists every spec in its folder and
that no two Runs share candidate seeds.
- `placement_success.py` reads an Experiment output directory into one
`RunPlacementRecord` per Run and a `PlacementSuccessSummary`. It
reports:
- `valid_candidate_rate_first_batch`: the share of the first batch that
passes every required check.
- `valid_env_rate_after_retries`: the share of environments that need no
best-loss fallback.
  - `batches_per_build`.
- The docs page explains what is measured and how to run it.
- `ci.yml` runs
`isaaclab_arena_benchmarking/tests/test_placement_success.py`.

Each Run builds its spec once. On `main`, the rebuilds of a Run get the
same placement seed, so more rebuilds would repeat the same candidates.
Once rebuilds get their own seeds (after #1523), the Experiments can use
more rebuilds.

The experiments are not in `tracked_benchmarks.yaml` yet. They can be
added together with placement KPI fields, which David plans to wire up.

## Validation

- The new tests, `test_placement_diagnostics.py`,
`test_run_execution.py`, `test_experiment_runner.py` and
`test_arena_experiment_result.py` pass locally, with the camera test run
in its own process as in CI. That includes one test that runs a one-Run
placement Experiment and reads its diagnostics back.
- Three real Runs (`banana_on_plate` and two KitchenBench specs, 30
environments) took 81 s through `experiment_runner.py` on one GPU, from
app start to the result file. The KitchenBench pick spec took the
longest, about 50 s.
- My local image has no cuRobo v2, so these ran on the core from before
#1550 with this PR's changes applied. CI covers the current image.
- The full 80-spec Experiments have not been run yet.

---------

Signed-off-by: zhx06 <[email protected]>
zhx06 added a commit that referenced this pull request Nov 4, 2026
Fix the placement pool fallback so it fills an environment's remaining
slots when the last batch finds too few valid layouts. Native uv CI has
failed on `main` since #1523 because of this. Also run
`test_placement_success.py` in native uv CI, as Docker CI does.

## Why this change?

With `allow_best_loss_fallbacks`, which is on by default,
`PooledObjectPlacer` fell back only when its last batch had no valid
layout. If the last batch had some valid layouts but too few, the build
raised `Placement pool could not fill ...`. So finding one more valid
layout could turn a passing build into a failing one.

#1523 changed the candidate seeds, and the farmhouse2 banana spec now
hits this in native uv CI. It finds 3 of 5 valid layouts, but its last
batch has 1, so the build fails. Before #1523 it found 1, its last batch
had none, and fallback filled the rest.

## What changes?

- On the last batch, `PooledObjectPlacer` stores an environment's valid
layouts first, then fills its remaining slots with best-loss layouts.
With `allow_best_loss_fallbacks=False`, an environment that is still
short still fails the build. The docs described the old rule and now
describe the new one.
- `uv-ci.yml` runs
`isaaclab_arena_benchmarking/tests/test_placement_success.py`, as
`ci.yml` has since #1560.

## Validation

- A new test in `test_heterogeneous_placement.py` covers a last batch
with too few valid layouts, with fallback on and off. Its fallback-on
case fails on `main` and passes here. The placement test files pass in
the Isaac Sim 6.2 container.
- With the farmhouse2 spec limited to 3 placement attempts, seeds 0 and
7 fail on `main` and build with this change.

This PR's native uv job runs the farmhouse2 test on the stack where it
fails. `main`'s latest uv run also failed
`test_droid_deformable_environment[physx]`, which this PR doesn't
address.

---------

Signed-off-by: zhx06 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants