Skip to content

Update G1 trocar assets and policy weights for sim-to-real RL training - #9148

Draft
KumoLiu wants to merge 163 commits into
isaac-sim:mainfrom
KumoLiu:yunl/feat/assemble-trocar-transfer
Draft

KumoLiu wants to merge 163 commits into
isaac-sim:mainfrom
KumoLiu:yunl/feat/assemble-trocar-transfer

Conversation

@KumoLiu

@KumoLiu KumoLiu commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Update the existing G1/Dex3 assemble-trocar task for the revised robot, scene and instrument assets and the matching GR00T N1.5 100k SFT policy.

  • Update task cameras and control settings in place: 320 x 240 RGB, 30 Hz control, 25-second episodes and native absolute joint-position actions.
  • Use install trocar from tray for training and evaluation. Set the lift threshold to 0.08 m above the table, measuring trocar 1 at its center of mass and trocar 2 at its root.
  • Preserve task-specific transparency, DLAA and RTX settings when selecting renderer=rtx explicitly. Add one configuration-only regression covering all three cameras.
  • Configure policy image augmentation through task observation tensor_processors, keeping 5% random training crops and center evaluation crops on the GPU. The task exposes policy_crop_scale and policy_crop_random; previews keep cropping disabled by default.
  • Document the revised asset layout, checkpoint selection and compatibility with earlier task/policy versions.

Scope and dependencies

All shared RLinf implementation changes, tests, documentation and changelog fragments have moved to #9217. This includes explicit success observations, runner contexts, external task registration, split overrides, camera preprocessing and padded reset actions. This PR contains Trocar task/assets updates, task-owned policy augmentation and the renderer fix. Generic resizing, metadata adaptation and startup validation remain in #9217. The updated RLinf recipe requires #9217; merge that shared support before using the recipe on main.

Task-specific Cosmos Transfer integration lives in isaaclab_demos#13, which requires both Lab PRs.

Assets and checkpoint availability

The robot, scene and instrument assets were updated to align the simulation with the real setup. The existing task is updated in place; older policies should retain their earlier Lab revision, assets and recipe.

The matching downloads are now linked in the documentation:

Both are currently shared privately and awaiting public release. Ruchik is helping with checkpoint publication. These are the matching updated files; the older checkpoint link was not a verified source for this export.

Validation

  • The explicit-RTX configuration regression reproduced the missing settings before the fix and passes after it; no GPU is needed for this check.
  • Shared RLinf coverage is reported in Support external RLinf tasks and explicit episode success #9217: 99 RLinf adapter/entrypoint tests, 54 image utility tests and 17 medical-pad tests passed on its standalone branch.
  • The explicit-RTX regression and 11 Trocar demo tests also passed against the updated combined task/RLinf snapshot.
  • Earlier validation of the task update: 11 Trocar demo CPU integration tests and headless PhysX/RTX camera smoke.
  • Earlier matched raw-RGB evaluation with the fine-tuned checkpoints-93 policy: 16/32 insertions before the update and 17/32 after it; 32 environments, 512 steps, fixed seeds, and 0/32 stage-4 completions in both runs.
  • Targeted Ruff checks, diff checks and package changelog validation passed.

Policy image processing validation

  • Task rendering/crop/configuration checks: 3 passed.
  • Cosmos demo integration against combined snapshot 806b6f1fa: 11 passed.
  • PhysX/RTX smoke with env.policy_crop_scale=0.05 and random crops enabled passed; raw camera output remains 320×240.
  • GPU preprocessing timings and reproducible command are recorded in Support external RLinf tasks and explicit episode success #9217.

temiroff and others added 30 commits October 28, 2026 16:21
Add CameraCfg.tensor_processors: processors that compute camera outputs from
render outputs and earlier processor outputs after each published capture. The
renderer produces only the inputs no earlier processor produces, processors
reset and close with the camera, and the reserved env_mask input marks the
environments with a new capture so stateful processors skip stale rows.

BaseRenderer.read_output and the render context now return whether a capture
was published, so processors run once per new capture.

This is the camera part of isaac-sim#8834, split out so it can merge independently of
the PPISP move; isp_cfg keeps its current behavior.

Co-authored-by: Matthew Taylor <[email protected]>
A processor whose close raises no longer skips the other processors, the renderer cleanup, or the frame view. Processors reading env_mask now require synchronous rendering: the mask marks the current capture request, while asynchronous rendering publishes the previous request's image.
Keep each request's data in its renderer group instead of re-indexing
the request list, build the processor buffers once with the capture mask,
and validate the reserved env_mask output name in CameraCfg.validate_config
so the data-type helper only computes.

Test the reserved name and processor-input validation through
validate(CameraCfg) instead of the private helper, and assert the mask
values and call count rather than only their length.

Renderers draw every environment on each capture, so describe env_mask as
the environments due for the capture rather than rows that still hold the
previous one. Merge the two added changelog bullets for the feature.
Renderers written before read_output returned a flag return None. Treating
that as unpublished silently skipped every tensor processor on those
renderers, leaving processor outputs missing from CameraData.output. Only
renderers that hold back a capture need to return False.
The ruff target does not allow ExceptionGroup yet; follow the render context, which logs each failure and raises a RuntimeError from the first.
Processor outputs enter CameraData.info when they are first published, together with CameraData.output, so the two key sets stay mirrored before the first capture. render_into_cameras returns booleans for renderers that still return None from read_output. CAPTURE_MASK_NAME moves to the module's constants.
The camera guide and changelog now say that processors reading env_mask need synchronous rendering, and that processor outputs appear from the first published capture on. The example produces rgb from depth, the pattern the tests cover.
Unchanged experimental Cosmos and image transfer packages, Shadow Hand presets, CLI entry, docs, and tests from exp/cosmos. They still use the camera modifier API from exp/cosmos; the next commit moves them to camera tensor processors.
Image transfer, the Cosmos transfer step, depth controls, and the canvas resize become TensorProcessor classes configured in CameraCfg.tensor_processors. The image transfer processor queues controls for the views in the camera's env_mask input instead of reading the sensor through bind_sensor, and cameras sharing a Cosmos session join it by the camera name apply_cosmos sets.
PpispProcessorCfg is not on main yet, so the PPISP chain test, its documentation section and srgb_to_linear, which only that chain uses, return with the PPISP processor.
Rejecting overrides of fields a configuration does not have affects every task, so it moves to its own pull request against main.
test_hydra runs Hydra with hydra/job_logging=disabled, which disables every logger that exists then, so the Direct-task warning test captured nothing when it ran later in the same session.
…Cosmos docs

The override check is its own pull request. The Isaac Lab environment pins Torch 2.11, and the image
transfer guide no longer covers PPISP.
depth_processor defaulted to 1.2-3.5 m while cosmos_camera and apply_cosmos used 0.1-2.0 m; all three now
share one default. The Cosmos processor no longer overrides the image transfer seed default.
The command is no longer special-cased before the other commands; it imports the experimental package only
when run.
The walkthrough in the Cosmos docs keeps the commands and now points to per-environment prompts.
The fragments described the branch's history, including controls added and removed again and fixes for
code main never had.
Signed-off-by: Alexander Temirov <[email protected]>

# Conflicts:
#	docs/source/concepts/sensors/camera.rst
#	source/isaaclab/changelog.d/camera-tensor-processors.added.rst
#	source/isaaclab/isaaclab/renderers/render_context.py
#	source/isaaclab/isaaclab/sensors/camera/camera_cfg.py
#	source/isaaclab/test/renderers/test_camera_output_contract.py
Renderers fill only existing info keys, so with delayed OVRTX captures the first image of a processor output
had info None and no capture metadata; later captures filled it.

Signed-off-by: Alexander Temirov <[email protected]>
The client model kept the closed camera group, which still held the cameras' old streams, so rebuilt cameras
failed with 'already joined its Cosmos session'.

Signed-off-by: Alexander Temirov <[email protected]>
A full view that a staggered capture skipped raised 'queue is full', although the capture would have completed
the other view's chunk.

Signed-off-by: Alexander Temirov <[email protected]>
The ISP processes the rendered image, which a Cosmos camera no longer renders; keeping it made the renderer fail
to initialize without an RGBA output.

Signed-off-by: Alexander Temirov <[email protected]>
read_output now returns a CaptureInfo for a new capture, or None when nothing new was published. prepare_capture
receives the capture's env_mask, and OVRTX keeps it with the pending asynchronous frame, so processors receive the
mask of the image they process. Processors reading env_mask therefore no longer need synchronous rendering.

Signed-off-by: Alexander Temirov <[email protected]>
@KumoLiu KumoLiu changed the title Add Cosmos Transfer to the G1 assemble-trocar task Update G1 trocar assets and policy setup for sim-to-real RL training Nov 24, 2026
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Nov 24, 2026
@KumoLiu KumoLiu changed the title Update G1 trocar assets and policy setup for sim-to-real RL training Update G1 trocar assets and policy weights for sim-to-real RL training Nov 25, 2026

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

There are a lot of changes around the configs of the tasks. Are the new checkpoints already uploaded? There are also a bunch of asset name changes? We also lost the link to where users can find the checkpoints?

Explicit renderer=rtx loses the task’s rendering settings. The new preset wrapper exposes an rtx alternative, but the settings helper updates only default and isaacsim_rtx. Note that we will deprecate isaacsim, so this will be gone.

The tests can also be reduced:

  • Move success_observation and rlinf_runner_context to a separate RLinf PR. Neither has an in-repository task consumer in this change. Trocar already distinguishes success terminations from drops/timeouts. This also removes the two new success-metric test cases and their documentation/changelog additions.
  • Merge the padded-action case into the existing mid-chunk reset test. Preserve its padding assertions, but avoid a second test that manually seeds private state and duplicates the reset-world selection check.
  • Keep both camera tests. They cover distinct paths: crop followed by resizing despite matching input/output dimensions, and split-specific options applied across views with structured state slicing.
  • Keep the existing entrypoint-test extensions and registration parameterization. They add useful coverage without another fixture or simulation.
  • Cover the renderer defect with one configuration-only regression; no GPU matrix is needed.

@AntoineRichard AntoineRichard self-assigned this Nov 25, 2026
@KumoLiu

KumoLiu commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

Hi @AntoineRichard, thanks for the quick review.
The updated 100k SFT checkpoint (https://huggingface.co/nvidia/s2r_models_dev/tree/main/mingxinz/sft/g1/trocar_install_segfixed/rot_0_10_320ep_sim_78ep_real_8gpu_100k) is uploaded privately, and we’re waiting for Ruchik’s help to make it public. I’ve added the matching link back to the documentation.

The asset updates align the simulated robot, scene and instruments with our real setup. The matching asset package (https://drive.google.com/file/d/1EDkToctifZRvdCVy8lZyYBGauUn36i_w/view?usp=sharing) is also linked now and awaiting public release.

For the remaining comments:

  • Renderer: Fixed the helper to update the rtx alternative. One configuration-only regression verifies that all three cameras retain the task’s rendering settings; no GPU matrix was added.
  • RLinf scope: Moved the shared RLinf support, including success_observation and rlinf_runner_context, into Support external RLinf tasks and explicit episode success #9217 (Support external RLinf tasks and explicit episode success #9217), together with its tests, documentation and changelogs.
  • Padded actions: Folded this case into the existing mid-chunk reset test, preserving the padding assertions.
  • Camera tests: Kept both tests covering the distinct preprocessing paths.
  • Entrypoint and registration tests: Kept the existing extensions and parameterization.

The demo PRs now reference the separate Lab dependencies.

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

can we put this to draft until the checkpoint is public?

hf download --repo-type model nvidia/Assemble_Trocar --local-dir /path/to/local/models
- Multi-GPU setup recommended (FSDP requires at least 1 GPU)
The updated ``assemble_trocar`` task also requires the matching
`asset pack <https://drive.google.com/file/d/1EDkToctifZRvdCVy8lZyYBGauUn36i_w/view?usp=sharing>`__.

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.

is there a reason we can't host this on S3 with other assets?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

es, we plan to publish the updated assets to S3 alongside the other Isaac Lab assets. The Google Drive link is temporary. We will update the task to reference the public S3 assets directly and remove the ASSET_LOCAL configuration and related setup instructions.
Also moved to draft for now.

@KumoLiu
KumoLiu marked this pull request as draft November 26, 2026 05:22
kellyguo11 pushed a commit that referenced this pull request Nov 30, 2026
## Summary

Support installed external tasks in RLinf training and playback while
keeping task and service implementations downstream. These shared
changes are separate from #9148 and do not require its Trocar assets or
task update.

- Register external tasks in simulator workers and consistently forward
task selection, retaining distinct train/eval IDs when no CLI override
is supplied.
- Preserve split-specific settings while replacing recipe keys
overridden by the CLI, including physics/renderer preset selectors.
- Read success from pre-reset `final_obs` and preserve the first
completed episode’s outcome through the action chunk. Reset-episode
frames cannot erase a win or turn a completed failure into a win; legacy
recipes retain their metrics.
- Keep deterministic, device-preserving resizing in
`isaaclab.utils.images`, round uint8 pixels to nearest, and leave
augmentation in task observation processors. Resolve worker split
settings once and document tensor layout and storage ownership.
- Require paired GPU resize dimensions for GR00T N1.5 and validate
matching train/eval output sizes and adapt a metadata copy without
mutating checkpoint metadata.
- Select an optional `runner.isaaclab_context` in the training recipe to
manage worker initialization/training, without adding Gym constructor
kwargs. Preserve padded hold actions after mid-chunk resets.

Consumers: [medical-pad GR00T/GRPO
demo](isaac-sim/isaaclab_demos#14) and [Trocar
Cosmos demo](isaac-sim/isaaclab_demos#13). Only
the latter also requires the task changes in #9148.

## Release backport

- [x] <!-- backport-active-release --> Backport this pull request to the
active release branch after it merges into `main`

## Validation

- RLinf adapter: **39 passed**; entrypoints: **67 passed**; image
utilities: **54 passed**.
- Medical-pad integration/configuration/action codec: **14 passed**
against this standalone branch.
- Trocar demo: **11 passed** against the combined Lab snapshot; the
explicit-RTX configuration regression also passed.
- Native RLinf 16-action chunk dispatch with real Lab autoreset passed
success and failure checks on CPU, using stand-in world-model/classifier
dependencies. The success observation becomes false immediately on
reset, so this does not rely on tracker caching.
- Incompatible train/eval sizes and legacy augmentation keys fail on the
driver before RLinf validation or cluster startup.
- Trocar task crop/configuration/rendering: **3 passed**; updated
PhysX/RTX smoke with task cropping enabled passed.
- Full `isaaclab --format` checks, including changelog validation,
passed.

## GPU image-preprocessing measurement

Baseline:
[`a3ff0b523`](KumoLiu@a3ff0b5).
Candidate: combined snapshot
[`806b6f1fa`](KumoLiu@806b6f1),
including the task-owned crop processor from #9148 and this PR's
deterministic resizing.

NVIDIA A100 80 GB PCIe, PyTorch 2.11.0+cu130, GPU 0. Process 32
environments × 3 uint8 BHWC views, 320×240 → 224×224 after a 5% crop.
Each case uses 50 warmups and 250 measured observations, with
interleaved baseline/candidate batches and synchronization at batch
boundaries. The measurement includes the actual crop/resize functions
and observation-manager image copies; it excludes simulation, IPC,
policy inference and extra-view stacking.

| Processing | Baseline ms/observation | Candidate ms/observation |
| --- | ---: | ---: |
| Center crop | 0.958 | 1.057 |
| Random crop | 1.526 | 1.586 |

With matching crop offsets, pixel differences are at most one uint8
level because conversion now rounds rather than truncates. These results
quantify preprocessing cost only and do not establish end-to-end
training throughput or success-rate parity.

<details>
<summary>Reproduce the preprocessing measurement</summary>

Run from the tested combined snapshot with its task dependencies
installed and the baseline commit available locally:

```bash
CUDA_VISIBLE_DEVICES=0 uv run --no-sync python - <<'PYCODE'
"""Compare the actual policy image functions, including observation-manager storage ownership."""
import ast,json,statistics,subprocess,time
from pathlib import Path
import torch
from isaaclab.utils.images import resize_images
from isaaclab_tasks.contrib.assemble_trocar.mdp.observations import crop_policy_camera
LAB=Path.cwd()
BASELINE='a3ff0b5235847231d6191dd487176699cb8e077f'
source=subprocess.check_output(['git','show',BASELINE+':source/isaaclab/isaaclab/utils/images.py'],cwd=LAB,text=True)
node=next(n for n in ast.parse(source).body if isinstance(n,ast.FunctionDef) and n.name=='crop_and_resize_images')
ns={'torch':torch};exec(ast.get_source_segment(source,node),ns);old_resize=ns['crop_and_resize_images']
images=[torch.randint(256,(32,240,320,3),device='cuda:0',dtype=torch.uint8) for _ in range(3)]
results=[]
with torch.inference_mode():
 for random in (False,True):
  def old():
   return [old_resize(image.clone(),height=224,width=224,crop_scale=.05,random_crop=random) for image in images]
  def new():
   # ObservationManager copies processor inputs and copies borrowed processor outputs.
   return [resize_images(crop_policy_camera(image.clone(),scale=.05,random_crop=random).clone(),height=224,width=224) for image in images]
  torch.cuda.manual_seed_all(13);before=old()
  torch.cuda.manual_seed_all(13);after=new()
  max_delta=max(int((a.to(torch.int16)-b.to(torch.int16)).abs().max()) for a,b in zip(before,after))
  assert max_delta<=1,max_delta
  for fn in (old,new):
   for _ in range(50):fn()
  torch.cuda.synchronize();samples={'baseline':[],'candidate':[]};functions={'baseline':old,'candidate':new}
  for repeat in range(10):
   order=['baseline','candidate'] if repeat%2==0 else ['candidate','baseline']
   for name in order:
    torch.cuda.synchronize();start=time.perf_counter()
    for _ in range(25):functions[name]()
    torch.cuda.synchronize();samples[name].append((time.perf_counter()-start)*1000/25)
  results.append({'crop':'random' if random else 'center','max_pixel_difference':max_delta,**{name:{'mean_ms':statistics.mean(values),'min_ms':min(values),'max_ms':max(values)} for name,values in samples.items()}})
report={'baseline':BASELINE,'candidate':subprocess.check_output(['git','rev-parse','HEAD'],cwd=LAB,text=True).strip(),'gpu':torch.cuda.get_device_name(0),'torch':torch.__version__,'envs':32,'views':3,'input_hw':[240,320],'output_hw':[224,224],'crop_scale':.05,'warmup':50,'measured':250,'includes':'actual crop and resize functions plus observation-manager image clones; excludes simulation, RPC, model inference','results':results}
path=Path('policy-image-processing.json');path.write_text(json.dumps(report,indent=2));print(json.dumps(report,indent=2))
PYCODE
```

</details>

Based on main `c1afcee17`, including #9155 checkpoint selector fixes for
separate train/eval task IDs.

## Runner context configuration

Training recipes can set `runner.isaaclab_context: module:callable`. The
callable receives the runner and merged training environment overrides
(recipe plus CLI), then returns a context manager. The optional hook is
used by the Trocar Cosmos demo to manage service GPU residency during
collection and policy updates. Unset recipes use the normal training
path. The context wraps worker initialization and training, including
exception cleanup, and is never stored in Gym task constructor kwargs.

## Type of change

- Bug fix
- New feature
- Documentation update

---------

Co-authored-by: Fanxing-LI <[email protected]>
kellyguo11 pushed a commit to kellyguo11/IsaacLab-public that referenced this pull request Nov 30, 2026
…9217)

## Summary

Support installed external tasks in RLinf training and playback while
keeping task and service implementations downstream. These shared
changes are separate from isaac-sim#9148 and do not require its Trocar assets or
task update.

- Register external tasks in simulator workers and consistently forward
task selection, retaining distinct train/eval IDs when no CLI override
is supplied.
- Preserve split-specific settings while replacing recipe keys
overridden by the CLI, including physics/renderer preset selectors.
- Read success from pre-reset `final_obs` and preserve the first
completed episode’s outcome through the action chunk. Reset-episode
frames cannot erase a win or turn a completed failure into a win; legacy
recipes retain their metrics.
- Keep deterministic, device-preserving resizing in
`isaaclab.utils.images`, round uint8 pixels to nearest, and leave
augmentation in task observation processors. Resolve worker split
settings once and document tensor layout and storage ownership.
- Require paired GPU resize dimensions for GR00T N1.5 and validate
matching train/eval output sizes and adapt a metadata copy without
mutating checkpoint metadata.
- Select an optional `runner.isaaclab_context` in the training recipe to
manage worker initialization/training, without adding Gym constructor
kwargs. Preserve padded hold actions after mid-chunk resets.

Consumers: [medical-pad GR00T/GRPO
demo](isaac-sim/isaaclab_demos#14) and [Trocar
Cosmos demo](isaac-sim/isaaclab_demos#13). Only
the latter also requires the task changes in isaac-sim#9148.

## Release backport

- [x] <!-- backport-active-release --> Backport this pull request to the
active release branch after it merges into `main`

## Validation

- RLinf adapter: **39 passed**; entrypoints: **67 passed**; image
utilities: **54 passed**.
- Medical-pad integration/configuration/action codec: **14 passed**
against this standalone branch.
- Trocar demo: **11 passed** against the combined Lab snapshot; the
explicit-RTX configuration regression also passed.
- Native RLinf 16-action chunk dispatch with real Lab autoreset passed
success and failure checks on CPU, using stand-in world-model/classifier
dependencies. The success observation becomes false immediately on
reset, so this does not rely on tracker caching.
- Incompatible train/eval sizes and legacy augmentation keys fail on the
driver before RLinf validation or cluster startup.
- Trocar task crop/configuration/rendering: **3 passed**; updated
PhysX/RTX smoke with task cropping enabled passed.
- Full `isaaclab --format` checks, including changelog validation,
passed.

## GPU image-preprocessing measurement

Baseline:
[`a3ff0b523`](KumoLiu@a3ff0b5).
Candidate: combined snapshot
[`806b6f1fa`](KumoLiu@806b6f1),
including the task-owned crop processor from isaac-sim#9148 and this PR's
deterministic resizing.

NVIDIA A100 80 GB PCIe, PyTorch 2.11.0+cu130, GPU 0. Process 32
environments × 3 uint8 BHWC views, 320×240 → 224×224 after a 5% crop.
Each case uses 50 warmups and 250 measured observations, with
interleaved baseline/candidate batches and synchronization at batch
boundaries. The measurement includes the actual crop/resize functions
and observation-manager image copies; it excludes simulation, IPC,
policy inference and extra-view stacking.

| Processing | Baseline ms/observation | Candidate ms/observation |
| --- | ---: | ---: |
| Center crop | 0.958 | 1.057 |
| Random crop | 1.526 | 1.586 |

With matching crop offsets, pixel differences are at most one uint8
level because conversion now rounds rather than truncates. These results
quantify preprocessing cost only and do not establish end-to-end
training throughput or success-rate parity.

<details>
<summary>Reproduce the preprocessing measurement</summary>

Run from the tested combined snapshot with its task dependencies
installed and the baseline commit available locally:

```bash
CUDA_VISIBLE_DEVICES=0 uv run --no-sync python - <<'PYCODE'
"""Compare the actual policy image functions, including observation-manager storage ownership."""
import ast,json,statistics,subprocess,time
from pathlib import Path
import torch
from isaaclab.utils.images import resize_images
from isaaclab_tasks.contrib.assemble_trocar.mdp.observations import crop_policy_camera
LAB=Path.cwd()
BASELINE='a3ff0b5235847231d6191dd487176699cb8e077f'
source=subprocess.check_output(['git','show',BASELINE+':source/isaaclab/isaaclab/utils/images.py'],cwd=LAB,text=True)
node=next(n for n in ast.parse(source).body if isinstance(n,ast.FunctionDef) and n.name=='crop_and_resize_images')
ns={'torch':torch};exec(ast.get_source_segment(source,node),ns);old_resize=ns['crop_and_resize_images']
images=[torch.randint(256,(32,240,320,3),device='cuda:0',dtype=torch.uint8) for _ in range(3)]
results=[]
with torch.inference_mode():
 for random in (False,True):
  def old():
   return [old_resize(image.clone(),height=224,width=224,crop_scale=.05,random_crop=random) for image in images]
  def new():
   # ObservationManager copies processor inputs and copies borrowed processor outputs.
   return [resize_images(crop_policy_camera(image.clone(),scale=.05,random_crop=random).clone(),height=224,width=224) for image in images]
  torch.cuda.manual_seed_all(13);before=old()
  torch.cuda.manual_seed_all(13);after=new()
  max_delta=max(int((a.to(torch.int16)-b.to(torch.int16)).abs().max()) for a,b in zip(before,after))
  assert max_delta<=1,max_delta
  for fn in (old,new):
   for _ in range(50):fn()
  torch.cuda.synchronize();samples={'baseline':[],'candidate':[]};functions={'baseline':old,'candidate':new}
  for repeat in range(10):
   order=['baseline','candidate'] if repeat%2==0 else ['candidate','baseline']
   for name in order:
    torch.cuda.synchronize();start=time.perf_counter()
    for _ in range(25):functions[name]()
    torch.cuda.synchronize();samples[name].append((time.perf_counter()-start)*1000/25)
  results.append({'crop':'random' if random else 'center','max_pixel_difference':max_delta,**{name:{'mean_ms':statistics.mean(values),'min_ms':min(values),'max_ms':max(values)} for name,values in samples.items()}})
report={'baseline':BASELINE,'candidate':subprocess.check_output(['git','rev-parse','HEAD'],cwd=LAB,text=True).strip(),'gpu':torch.cuda.get_device_name(0),'torch':torch.__version__,'envs':32,'views':3,'input_hw':[240,320],'output_hw':[224,224],'crop_scale':.05,'warmup':50,'measured':250,'includes':'actual crop and resize functions plus observation-manager image clones; excludes simulation, RPC, model inference','results':results}
path=Path('policy-image-processing.json');path.write_text(json.dumps(report,indent=2));print(json.dumps(report,indent=2))
PYCODE
```

</details>

Based on main `c1afcee17`, including isaac-sim#9155 checkpoint selector fixes for
separate train/eval task IDs.

## Runner context configuration

Training recipes can set `runner.isaaclab_context: module:callable`. The
callable receives the runner and merged training environment overrides
(recipe plus CLI), then returns a context manager. The optional hook is
used by the Trocar Cosmos demo to manage service GPU residency during
collection and policy updates. Unset recipes use the normal training
path. The context wraps worker initialization and training, including
exception cleanup, and is never stored in Gym task constructor kwargs.

## Type of change

- Bug fix
- New feature
- Documentation update

---------

Co-authored-by: Fanxing-LI <[email protected]>
(cherry picked from commit 05e3a7d)

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

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants