Skip to content

Reduce grasp retries and CPU link reads during trajectory expansion - #1251

Open
matafela wants to merge 1 commit into
mainfrom
codex/outcome-guided-expansion
Open

matafela wants to merge 1 commit into
mainfrom
codex/outcome-guided-expansion

Conversation

@matafela

@matafela matafela commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Eight-environment trajectory collection can spend most of its time finishing grasp candidates that fail late. This follow-up to #1244 uses the physical outcomes already available to the collector to schedule subsequent attempts.

  • Set trajectory.affordance.branch_selection to outcome_guided to try every non-nominal branch, then use accepted trajectories and verified task segments to select further attempts. The downstream recipes reserve 25% of post-bootstrap assignments for exploration. Existing recipes continue to use round-robin selection by default.
  • A successful attempt records its object-relative grasp. In a new layout, the sampler can match that grasp among the current valid candidates. It plans and executes a fresh trajectory and applies the usual collision, contact, segment and terminal checks. The recipe and attempt record retain the source ordinal, branch and match result.
  • During Default CPU control, reading selected environments and one named link avoids materializing the full robot link-pose tensor. The scoped lookup uses the normal per-tick invalidation and the same arena transform.

How one retry works

flowchart TD
    A["Try every non-nominal branch"] --> B["Choose the next branch from physical outcomes and exploration"]
    B --> C["Generate valid grasps in the current layout"]
    C --> D{"Does a current candidate match the selected successful grasp in object coordinates?"}
    D -->|Yes| E["Use the matched candidate in the new layout"]
    D -->|No or exploring| F["Use the current branch ranking"]
    E --> G["Plan, execute and validate the full attempt"]
    F --> G
    G --> B
Loading

In the measured Tianji run, the third attempt successfully grasped the marker. In the marker's own frame the grasp translation was approximately (+20.7, −36.3, +50.3) mm. Attempts five and six found the same relative position and orientation in new candidate sets. Both executed a newly planned trajectory and passed. For CPU link reads, the corresponding scale is 8 environments × 30 links in a full read and 3 active environments × 2 requested arm roots in the measured selected read.

Before and after

Each task ran on the same host, serially, with Python 3.12, DexSim 0.6.0, one World, eight CPU physics environments and identical seeds, attempt budgets and acceptance criteria. Both timing arms included the same pre-existing local grasp-scoring edit. For each arm, all three operators produced three accepted episodes each, and all nine were exported to LeRobot and read back. Collection includes World initialization. The measured headless workflow also includes scene construction, export, readback and artifact registration.

Task Collection, before → after (s) Workflow, before → after (s) Workflow time saved Grasp attempts for 3 accepted
CobotMagic bottle relay 210.1 → 187.2 246.3 → 223.2 23.1 s (9.4%) 7 → 5
Piper X book pickup 184.5 → 149.9 213.8 → 177.4 36.3 s (17.0%) 11 → 9
Tianji bimanual marker insertion 1025.8 → 484.3 1086.8 → 541.9 544.9 s (50.1%) 15 → 6

For Tianji, failed grasp attempts consumed 31,964 → 7,384 environment action steps. Its grasp operator took approximately 721.0 → 216.0 s. Two later accepted episodes matched an earlier successful object-relative grasp in newly generated candidate sets.

In a second bottle-relay pair run in reverse order, the workflow took 306.4 → 281.3 s, with 8 → 6 grasp attempts. The two-pair mean was 276.3 → 252.3 s (8.7% less time). Contact outcomes varied between runs at the same seed.

The eight-environment Tianji microbenchmark compared 720 link matrices across three physics states with zero maximum element difference. Looking up three rows and both arm roots took 9.26 → 0.61 ms per control tick (15.2×). This times the read operation alone.

The comparison used the WebRTC-era revision 76ad5aa95 and the measured implementation 687d0fcae. The 14 changed files are byte-identical in this PR, based on 22946b0d3. Six real Chrome replays verified a decoded video, independent ghost selection, Space playback and zero physics steps.

All three commands below also ran with the clean package built from 7a7ad9db2 and its shipped grasp scoring. Each command collected and read back nine trajectories. Chrome decoded each video and exercised the normal controls.

Task Clean package, command start through WebRTC service ready (s) Grasp attempts for 3 accepted
CobotMagic bottle relay 251.2 10
Piper X book pickup 237.8 9
Tianji bimanual marker insertion 688.9 12

Run the downstream examples

From the DexEChain checkout with the matching sim2real extension installed, activate the Python 3.12 environment and run the following commands. The extension supplies the pinned EmbodiChain revision. The example names select the task deployments. The YAML files select the eight-environment scene-first recipes.

conda activate py312
unset DEXECHAIN_SIM2REAL_EMBODICHAIN_REVISION
tasks=extensions/dexechain_sim2real/src/dexechain_sim2real/configs/tasks

dexechain-sim2real expand --example bottle-relay-coverage-expansion \
  --expansion-config "$tasks/cobotmagic_bottle_relay/expansion.scene_first.yaml" \
  --output outputs/scene_first/bottle-relay --timeout-s 7200 --no-headless

dexechain-sim2real expand --example piper-coverage-expansion \
  --expansion-config "$tasks/piper_x_take_book/expansion.scene_first.yaml" \
  --output outputs/scene_first/piper --timeout-s 7200 --no-headless

dexechain-sim2real expand --example tianji-bimanual-coverage-expansion \
  --expansion-config "$tasks/tianji_bimanual_marker_in_holder/expansion.scene_first.yaml" \
  --output outputs/scene_first/tianji-bimanual --timeout-s 7200 --no-headless

The browser pins the original recording as the solid trajectory. Clicking an augmented candidate toggles only that ghost. Space plays or pauses the recording. For the single-repository UR5 tutorial, follow the tutorial instructions.

Screenshots

The public UR5 tutorial capture from #1244 illustrates the reference and augmented ghost controls.

UR5 replay with the original recording and selectable ghosts

Type of change

  • Enhancement improving expansion performance and retry scheduling.

Validation

The focused upstream suite passed all 212 tests, including GPU coverage, and the public API check covered 5,165/5,165 exports. The suite covers branch fallback, geometry matching, per-row feedback, scoped link reads, invalidation and replay. Both focused downstream tests passed, covering the generated CobotMagic deployment and the real Piper five-operator CLI with WebRTC playback and unchanged dataset contents. Existing tests cover the collection and persistence contracts. Focused new cases cover the scheduling and observation behaviors introduced here.

Checklist

  • Ran black ..
  • Updated expansion and affordance-sampling agent context.
  • Passed the public API documentation coverage check.
  • Reviewed the necessity of behavioral tests and ran the targeted suites.
  • Verified the pinned downstream wheel includes all three recipes.

@matafela matafela added motion gen Robot motion planning, MotionGenerator, trajectory generation, retiming and expansion. performance Performance, memory, throughput and synchronization-cost improvements. sim-object Simulation entity configuration, state, creation, destruction and lifecycle. task-program Task Program language, semantics, compiler, runtime and integration contracts. labels Nov 19, 2026
@greptile-apps

greptile-apps Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

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

Summary

Adds optional outcome-guided grasp retries and faster selected-link reads during CPU planning.

  • Later grasp attempts can favor successful branches and matching grasp poses.
  • CPU control reads named link poses from selected environments.

No actionable issues found.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Choose branch] --> B[Freeze recipe]
  B --> C[Generate current valid grasps]
  C --> D[Match saved grasp or use rank]
  D --> E[Plan and execute fresh motion]
  E --> F[Check measured outcome]
  F --> G[Update branch history once]
  G --> A
  E --> H[Normal episode acceptance and storage]
Loading

Reviews (1) · Last reviewed commit: "perf(expansion): guide retries with meas..." · Reviewed by Greptile

@matafela
matafela requested a review from yuecideng November 19, 2026 14:45

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

motion gen Robot motion planning, MotionGenerator, trajectory generation, retiming and expansion. performance Performance, memory, throughput and synchronization-cost improvements. sim-object Simulation entity configuration, state, creation, destruction and lifecycle. task-program Task Program language, semantics, compiler, runtime and integration contracts.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant