Repository navigation
Conversation
There was a problem hiding this comment.
Isaac Lab Review Bot
Needs attention: Design and architecture (1), Scope and over-engineering (1), Compatibility and deprecation (1), Implementation (1), Style consistency (3), Test quality (1). Other reviewed categories look good.
- PR description: Title and scope match; retain reported validation, remove test-edit narration, and benchmark per-observation camera processing with baseline/candidate revisions, command, hardware, backend, environment count, warmup, and latency.
- Design and architecture: Generic crop/resize processing violates the contribution guide’s utils.images ownership rule; move the transformation there and retain RLinf configuration translation in the adapter.
- Scope and over-engineering: Minimal implementation: Extend train_rlinf.py for context lifecycle, cli_args_rlinf.py for forwarding, play_rlinf.py for evaluation, and extension.py for worker adaptation; resolve split configuration once and move generic image processing to utils.images, eliminating per-observation dictionary merges. No source modules were added, and no parallel layer is required. Scope is cohesive; no split recommended.
- API: API changes look good.
- Compatibility and deprecation: Breaking changes: registering rlinf_runner_context adds a constructor keyword that existing task environments may reject; keep the hook outside Gym constructor kwargs or strip it before construction.
- Implementation: GR00T metadata uses training resize dimensions while evaluation images use split-specific dimensions, causing validation failures; derive metadata from the consuming split or reject incompatible dimensions.
- Style consistency: The camera helper omits its BHWC, dtype, and storage-aliasing contract; document these constraints so callers can distinguish borrowed storage from newly allocated output.
- Test quality: Camera and entrypoint cases protect distinct boundaries, but crossing padding with every device repeats adapter behavior already covered by transfer tests; retain one padded case.
Significant concerns. Posted 8 inline findings.
Automated review; human maintainers own approval decisions.
| rl_head_config=model_cfg.rl_head_config, | ||
| ) | ||
|
|
||
| if "gpu_resize_width" in cfg or "gpu_resize_height" in cfg: |
There was a problem hiding this comment.
🔴 Critical · Implementation — Match metadata to evaluation images
Model metadata uses training resize settings, while evaluation workers apply their own settings. Different dimensions fail GR00T video validation; derive metadata from the consuming split or reject incompatible split dimensions.
| runner.run() | ||
| spec = registry.get(task_id) | ||
| context = nullcontext() | ||
| if spec and (entry_point := spec.kwargs.get("rlinf_runner_context")): |
There was a problem hiding this comment.
🔴 Critical · Compatibility — Keep context out of constructor kwargs
Gym forwards specification kwargs to gym.make, so a registered rlinf_runner_context reaches task constructors that do not accept it. Store the hook separately or remove it before environment construction.
| logger.debug(f"REGISTER_ISAACLAB_ENVS now contains: {list(REGISTER_ISAACLAB_ENVS.keys())}") | ||
|
|
||
|
|
||
| def _prepare_camera_image(image: torch.Tensor, cfg: dict) -> torch.Tensor: |
There was a problem hiding this comment.
🟡 Warning · Design Architecture — Move image processing to utils.images
The contribution guide assigns image processing to utils.images. This generic crop/resize helper creates a second owner in the RLinf adapter; move the transformation there and keep configuration translation here.
|
|
||
|
|
||
| def _prepare_camera_image(image: torch.Tensor, cfg: dict) -> torch.Tensor: | ||
| """Crop a batch of RGB frames and resize to the policy input dimensions on the image device.""" |
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Document camera tensor ownership
The helper requires BHWC input and can return the original tensor, a view, or a new tensor. Document shapes, dtype preservation, and aliasing so callers know whether the result owns storage.
| camera_obs = obs.get("camera_images", {}) | ||
|
|
||
| cfg = _get_isaaclab_cfg() | ||
| cfg = {**_get_isaaclab_cfg(), **self.cfg.get("isaaclab", {})} |
There was a problem hiding this comment.
🟡 Warning · Scope Complexity — Resolve split settings once
Every observation allocates and merges the same configuration dictionary. Resolve fixed split settings during worker initialization and reuse them for observations and held-action padding.
|
|
||
|
|
||
| @pytest.mark.parametrize("explicit_success", [True, False], ids=["success-observation", "legacy-termination"]) | ||
| def test_episode_success_distinguishes_failure_and_timeout(explicit_success, set_config_env): |
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Annotate the test return
This new test omits the required -> None return annotation used by neighboring tests. Add it.
| class TestObsConversion: | ||
| """Tests for ``_convert_isaaclab_obs_to_gr00t``.""" | ||
|
|
||
| def test_camera_crop_applies_when_resize_matches_input(self, set_config_env) -> None: |
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Correct the test class description
The new tests exercise worker _wrap_obs, but the enclosing class says it tests _convert_isaaclab_obs_to_gr00t. Broaden the description or move these tests.
| "hold_pose,device,prefix_pad,suffix_pad", | ||
| [ | ||
| (False, "cpu", 0, 0), | ||
| *((True, device, prefix, suffix) for device in test_devices() for prefix, suffix in ((0, 0), (2, 1))), |
There was a problem hiding this comment.
🟡 Warning · Test Quality — Avoid crossing padding with devices
Padding adds no device-specific adapter branch, while existing unpadded rows cover device transfers. Keep one padded row rather than repeating it on every device.
[Medium impact] The changes affect RLinf task setup and policy inputs across training and playback workflows. Fix conflicting preset overrides before merging; a CLI physics change can currently stop training or playback. FindingsSummaryThis PR lets simulator workers discover external tasks and adds explicit episode success, per-split camera settings, and a task-provided training context.
Reviews (1) · Last reviewed commit: "Support external RLinf tasks with split ..." · Reviewed by Greptile |
| configured = list(cfg.env[split].init_params.get("env_overrides") or ()) | ||
| cfg.env[split].init_params.env_overrides = configured + args_cli.env_overrides |
There was a problem hiding this comment.
If a recipe contains physics=physx and the user passes physics=newton_mjwarp, appending the lists sends both choices to resolve_task_config. _pick_alternative then raises ValueError because they select different alternatives for the same field. Training fails instead of using the CLI choice. Playback has the same problem.
Replace matching recipe selectors before appending CLI overrides.
| if "gpu_resize_width" in cfg or "gpu_resize_height" in cfg: | ||
| # GR00T validates incoming video against the recording metadata. The env worker has already resized RGB. | ||
| input_metadata = model.metadata.model_copy(deep=True) | ||
| for video in input_metadata.modalities.video.values(): | ||
| width, height = video.resolution | ||
| video.resolution = (cfg.get("gpu_resize_width", width), cfg.get("gpu_resize_height", height)) | ||
| modality_transform.set_metadata(input_metadata) |
There was a problem hiding this comment.
Metadata changes lack direct tests
No test calls the patched loader to exercise this metadata update. Existing tests only check whether the loader was replaced and separately check camera pixels. Swapped dimensions or changes to the wrong metadata object could pass all those tests.
Add a loader test with non-square resize dimensions. Check the metadata passed to set_metadata, verify the original metadata stays unchanged, and cover setting only one dimension.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| """ | ||
|
|
||
|
|
||
| def crop_and_resize_images( |
There was a problem hiding this comment.
Could this function be moved to external downsteam projects? because it is for visual data augmentation while isaaclab internal functions perfer to provide pre-processing such as normalization.
There was a problem hiding this comment.
Thanks, I moved crop augmentation to the task observation processor and removed the crop options from the RLinf adapter. The shared helper now only handles resizing.
There was a problem hiding this comment.
This function is implemented here rather than building in GR00T where it transfers data between GPU and CPU for such function, in order to save time. But it looks different from others in this .py, I am not sure whether it should be here. @ooctipus
| image.permute(0, 3, 1, 2).float(), size=size, mode="bilinear", align_corners=False, antialias=True | ||
| ).permute(0, 2, 3, 1) | ||
| if image.dtype == torch.uint8: | ||
| resized = resized.clamp(0, 255) |
There was a problem hiding this comment.
Maybe here insert a round() could retain fractional part better before to uint8
There was a problem hiding this comment.
Added rounding before conversion back to uint8, with a regression test covering fractional interpolation values.
| if not data_config_class or model_type == "gr00t_n1d7": | ||
| return | ||
|
|
||
| evaluation_cfg = {**cfg, **_load_full_cfg().get("env", {}).get("eval", {}).get("isaaclab", {})} |
There was a problem hiding this comment.
This ValueError may could never be thrown out. See RLinf/scheduler/cluster/utils.py:90-110, where RLinf will catch the Exception and show another info at terminal.
There was a problem hiding this comment.
Good point. Both train and play now validate the merged image configuration on the driver before launching workers, so configuration errors are reported directly.
| import gymnasium as gym | ||
|
|
||
| from isaaclab.app import launch_simulation | ||
| from isaaclab.cli import load_external_tasks | ||
|
|
||
| from isaaclab_tasks.utils import parse_env_cfg |
There was a problem hiding this comment.
move "import" to the beginning
There was a problem hiding this comment.
Moved the Gym, app, and CLI imports to module scope. Task imports remain inside the simulator subprocess to avoid registering tasks in actor and rollout workers.
| cfg = _get_isaaclab_cfg() | ||
| cfg = self._isaaclab_cfg | ||
| success_cfg = cfg.get("success_observation") | ||
| self._success_observation = ( |
There was a problem hiding this comment.
This observation is the first obs of one new episode after reset returned by step(), not the final obs.
There was a problem hiding this comment.
You're right. Success metrics now read the pre-reset final_obs, rather than the returned observation. They also preserve the completed episode’s outcome across the remaining chunk steps.
validate_image_config rejects gpu_crop_scale and gpu_crop_random whenever they are present. The H2 Sharpa recipes still carried neutral values that no code reads, so their documented train and play commands failed at startup. Add a test that launches every RLinf recipe shipped in isaaclab_tasks through train_rlinf up to the worker boundary, then validates the raw recipe file the way the extension's register() does.
| """ | ||
|
|
||
|
|
||
| def crop_and_resize_images( |
There was a problem hiding this comment.
This function is implemented here rather than building in GR00T where it transfers data between GPU and CPU for such function, in order to save time. But it looks different from others in this .py, I am not sure whether it should be here. @ooctipus
|
run-ci |
|
run-ci |
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.
final_obsand 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.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.runner.isaaclab_contextin 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 and Trocar Cosmos demo. Only the latter also requires the task changes in #9148.
Validation
isaaclab --formatchecks, including changelog validation, passed.GPU image-preprocessing measurement
Baseline:
a3ff0b523. Candidate: combined snapshot806b6f1fa, 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.
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.
Reproduce the preprocessing measurement
Run from the tested combined snapshot with its task dependencies installed and the baseline commit available locally:
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