Skip to content

Mesh non-collision loss optimization - #998

Open
qianl-nv wants to merge 2 commits into
mainfrom
qianl/feature/mesh-optimization
Open

Mesh non-collision loss optimization#998
qianl-nv wants to merge 2 commits into
mainfrom
qianl/feature/mesh-optimization

Conversation

@qianl-nv

@qianl-nv qianl-nv commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Summary

Batch mesh collision SDF queries to reduce solver time from 55s to 4s for the droid kitchen scene.

Detailed description

  • The baseline runs sphere to SDF serial per-candidate in compute_no_overlap_loss_mesh resulting in one warp launch per candidate. While the SDF kernel itself runs fast (0.75ms), the serial multi launch results in NoOverlapMESH taking 55ms per iteration (97% of each interation time).
  • Replace per-candidate mesh queries with one batched Warp launch. compute_no_overlap_loss_mesh rewritten as a fully tensorized (B, P) / (B, S) pipeline (batch × pairs × spheres).
  • Remove unnecessary host sync points — .item() when building yaw tensors from Python lists; if not active_pair.any(): continue forcing GPU→CPU sync every iteration.

Tests

  • B=4, mixed overlap/yaw; loss and ∇positions match baseline serial implementation
  • For existing droid kitchen scene, validation pass rate for serial vs batched implementation is identical.
  • Manual run droid_pick_and_place_lightwheel_kitchen.yaml and layout looks correct over 20 resets.

Command to run:
/isaac-sim/python.sh isaaclab_arena/evaluation/policy_runner.py --viz kit --policy_type zero_action --num_episodes 20 --disable_fabric --device cpu --env_graph_spec_yaml isaaclab_arena_environments/kitchen_bench/droid_pick_and_place_lightwheel_kitchen.yaml

with solver logging enabled should see
[RelationSolver] solve: 3715.2 ms | batch=50 | objects=3 optimizable + 3 anchors | no-overlap pairs=12 | iters=600 (6.19 ms/iter)
vs baseline
[RelationSolver] solve: 56006.8 ms | batch=50 | objects=3 optimizable + 3 anchors | no-overlap pairs=12 | iters=600 (93.34 ms/iter)

@qianl-nv
qianl-nv force-pushed the qianl/feature/mesh-optimization branch from 0aa5c17 to fc939b4 Compare August 3, 2026 03:55
@qianl-nv qianl-nv changed the title WIP: Mesh solver benchmark and optimization Mesh non-collision loss optimization Aug 3, 2026
@qianl-nv
qianl-nv marked this pull request as ready for review August 3, 2026 05:44
Comment thread isaaclab_arena/relations/relation_solver_params.py Outdated
Comment thread isaaclab_arena/environments/arena_env_builder.py Outdated
@arena-review-bot

Copy link
Copy Markdown
Contributor

🤖 Isaac Lab-Arena Review Bot

Summary

This PR rewrites compute_no_overlap_loss_mesh from a per-env / per-candidate serial loop into a fully tensorized (B, P) / (B, S) pipeline with a single Warp SDF launch, and removes host-sync points — a solid, well-motivated optimization (55s → 4s). The dense-query-then-mask trade-off is documented, and the added regression test checks both loss and position-gradient equivalence against a serial oracle across a mixed overlap/yaw batch, which is exactly the right coverage. My only concern is a pair of profiling toggles that look like benchmarking leftovers.

Findings

🟡 Warning: relation_solver_params.py:58profile default flipped FalseTrue, so every solve() now prints a timing summary for all users. Unrelated to the batching work; likely a benchmarking leftover to revert.

🟡 Warning: arena_env_builder.py:101 — the default builder path (placer_params is None) now hard-codes profile=True, enabling timing prints for every environment built through the builder. Same question — intended or leftover?

Test Coverage

Good. test_batched_mesh_loss_matches_test_only_serial_oracle compares the batched implementation against the retired serial oracle (kept in the test file) for both loss values and optimizable_positions gradients, over a B=4 batch mixing overlap and yaw. Consistent with the file's existing warp/torch test style — no SimulationApp, so the inner/outer sim pattern isn't required.

Verdict

Minor fixes needed — confirm/revert the two profile=True toggles; the core optimization looks correct and well-tested.

@greptile-apps

greptile-apps Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR batches mesh collision SDF work across candidates to replace many serial Warp launches with one dense query and adds a serial-reference equivalence test.

  • Tensorizes pair positions, yaw transforms, broad-phase masks, sphere queries, and pair aggregation.
  • Adds device-resident fixed-pose, fixed-yaw, and bbox-yaw metadata to the mesh-pair cache.
  • Verifies batched losses and position gradients against the former serial implementation.
  • Also enables solver profiling globally and in the environment builder's fallback configuration.

Confidence Score: 4/5

The PR appears safe to merge, with the non-blocking caveat that solver profiling should remain opt-in to avoid unsolicited timing output in normal runs.

The batched mesh-collision path preserves the investigated loss, gradient, cache, and yaw behavior, but the configuration changes enable profiling diagnostics for routine relation solves.

Files Needing Attention: isaaclab_arena/relations/relation_solver_params.py, isaaclab_arena/environments/arena_env_builder.py

Important Files Changed

Filename Overview
isaaclab_arena/relations/no_overlap_mesh.py Replaces per-candidate mesh queries with a batched tensor pipeline while preserving the checked position, yaw, broad-phase, loss, and gradient semantics.
isaaclab_arena/relations/mesh_pair_cache.py Adds validated device-tensor cache fields for fixed poses, fixed yaws, and bbox yaw metadata.
isaaclab_arena/tests/test_mesh_collision.py Adds a serial reference implementation and checks batched loss and gradient equivalence across mixed overlap, yaw, and fixed-obstacle cases.
isaaclab_arena/relations/relation_solver_params.py Enables profiling by default, causing ordinary solver runs to emit timing diagnostics.
isaaclab_arena/environments/arena_env_builder.py Explicitly enables profiling for fallback relation-solver parameters used during environment construction.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Batch candidate positions and pair metadata] --> B[Compute batched yaw-aware AABB overlap]
  B --> C[Transform all sphere centers into obstacle frames]
  C --> D[Single dense multi-mesh SDF launch]
  D --> E[Mask inactive pairs]
  E --> F[Scatter sphere penetration by pair]
  F --> G[Per-candidate no-overlap loss]
Loading

Reviews (1): Last reviewed commit: "Cleanup unused MeshPairCache data" | Re-trigger Greptile

Comment thread isaaclab_arena/relations/relation_solver_params.py Outdated

@qianl-nv qianl-nv left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self review 1

Comment thread isaaclab_arena/relations/mesh_pair_cache.py Outdated
Comment thread isaaclab_arena/relations/no_overlap_mesh.py
Comment thread isaaclab_arena/relations/no_overlap_mesh.py
Comment thread isaaclab_arena/environments/arena_env_builder.py Outdated
@qianl-nv
qianl-nv force-pushed the qianl/feature/mesh-optimization branch from 5c81e90 to 993e7a3 Compare August 3, 2026 06:13
Base automatically changed from qianl/feature/lw-kitchen-mesh to main August 3, 2026 07:09
Retire the obsolete serial no-overlap reference and its profiling controls now that the batched implementation is the only supported path.

Move serial oracle to unit test and add regression testing

Cleanup unused MeshPairCache data
@qianl-nv
qianl-nv force-pushed the qianl/feature/mesh-optimization branch from 993e7a3 to 7c8ede9 Compare August 3, 2026 07:18
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.

1 participant