Skip to content

Add dexsuite wrist-camera FPS/quality benchmark - #5717

Closed
nblauch wants to merge 2 commits into
isaac-sim:developfrom
nblauch:nblauch/dexsuite-wrist-camera-bench
Closed

nblauch wants to merge 2 commits into
isaac-sim:developfrom
nblauch:nblauch/dexsuite-wrist-camera-bench

Conversation

@nblauch

@nblauch nblauch commented May 21, 2026

Copy link
Copy Markdown
Contributor

New scripts/benchmarks/benchmark_dexsuite_wrist_camera.py runs the dexsuite-reorient task twice with identical settings except the camera mount (static base vs wrist-mounted under Robot/ee_link/palm_link), records per-env observation-camera mp4s, and reports per-mode FPS for objective comparison of moving-camera quality and performance.

Supports single-GPU (--mode both spawns matched base/wrist subprocesses) and multi-GPU (--distributed under torchrun writes per-rank fps CSVs; --mode summarize aggregates totals as a final rank-0-only step).

Uses imageio_ffmpeg for video encoding because cv2.VideoWriter mp4v silently drops frames inside Kit's loaded libavcodec context.

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context.
List any dependencies that are required for this change.

Fixes # (issue)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (existing functionality will not work without user modification)
  • Documentation update

Screenshots

Please attach before and after screenshots of the change if applicable.

Checklist

  • I have read and understood the contribution guidelines
  • I have run the pre-commit checks with ./isaaclab.sh --format
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the changelog and the corresponding version in the extension's config/extension.toml file
  • I have added my name to the CONTRIBUTORS.md or my name already exists there

New scripts/benchmarks/benchmark_dexsuite_wrist_camera.py runs the
dexsuite-reorient task twice with identical settings except the camera
mount (static base vs wrist-mounted under Robot/ee_link/palm_link),
records per-env observation-camera mp4s, and reports per-mode FPS for
objective comparison of moving-camera quality and performance.

Supports single-GPU (--mode both spawns matched base/wrist subprocesses)
and multi-GPU (--distributed under torchrun writes per-rank fps CSVs;
--mode summarize aggregates totals as a final rank-0-only step).

Uses imageio_ffmpeg for video encoding because cv2.VideoWriter mp4v
silently drops frames inside Kit's loaded libavcodec context.
@github-actions github-actions Bot added the isaac-lab Related to Isaac Lab team label May 21, 2026

@isaaclab-review-bot isaaclab-review-bot Bot 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.

🤖 Automated Code Review

Summary

This PR adds a new benchmark script (scripts/benchmarks/benchmark_dexsuite_wrist_camera.py) for comparing static base camera vs wrist-mounted camera performance in the dexsuite-reorient task. The script is well-structured with multi-GPU support and comprehensive output artifacts.


✅ Strengths

  1. Solid Architecture: Clean separation between orchestrator (--mode both), per-config runners (--mode base/wrist), and aggregation (--mode summarize).

  2. Multi-GPU Support: Properly reads RANK/WORLD_SIZE from torchrun environment and handles per-rank CSV output with correct aggregation.

  3. Reproducibility: Seeds are correctly offset per-rank while staying matched between modes for apples-to-apples comparison.

  4. Video Encoding Workaround: Good documentation of the cv2.VideoWriter/Kit libavcodec conflict and the imageio_ffmpeg solution.

  5. Output Artifacts: Comprehensive outputs (FPS CSVs, summary files, args.json, videos) enable post-hoc analysis.


⚠️ Suggestions for Improvement

1. Missing Dependency Declaration

The script uses imageio (with imageio_ffmpeg backend) but this dependency may not be in the project's requirements. Consider:

  • Adding to requirements.txt or documenting as an optional dependency
  • Adding a runtime check with a helpful error message:
try:
    import imageio.v2 as imageio
except ImportError:
    raise RuntimeError("Video recording requires imageio and imageio_ffmpeg. Install with: pip install imageio imageio-ffmpeg")

2. Error Handling in CSV Operations

The CSV file operations lack explicit error handling. Consider wrapping in try/except:

# Line ~310
try:
    fps_csv = fps_csv_path.open("w", newline="")
except IOError as e:
    print(f"Failed to open {fps_csv_path}: {e}", file=sys.stderr)
    return 1

3. Resource Cleanup Enhancement

The finally block only closes fps_csv. Consider using context managers throughout:

with fps_csv_path.open("w", newline="") as fps_csv:
    # ... rest of the code

This would ensure proper cleanup even if env.close() raises.

4. Potential Race Condition in Distributed Mode

In _resolve_out_dir, multiple ranks calling mkdir(parents=True, exist_ok=True) simultaneously should be safe, but the args.json check could race. Consider using a file lock or having only rank 0 create the directory.

5. Magic Number Documentation

n_video_envs = max(0, min(args.num_video_envs, args.num_envs, 3))  # Why cap at 3?

Add a comment explaining the cap (memory constraints? diminishing returns?).

6. Type Hints

Adding type hints would improve maintainability:

def _read_fps_csv(csv_path: Path) -> list[tuple[int, float, bool]]:
    rows: list[tuple[int, float, bool]] = []  # ✓ Already done internally

Consider adding return types to public functions like main() -> int.


🔍 Minor Issues

  1. Unused import potential: statistics is imported at module level — confirm it's needed (it is, for fmean/stdev).

  2. Docstring completeness: setup_env_cfg returns a value but the docstring says "Build" rather than "Return". Minor, but worth aligning.

  3. CLI documentation: The module docstring shows source ../tools/activate.sh which assumes a specific working directory. Consider using a more portable path or clarifying the expected CWD.


📋 Checklist Observations

  • Tests: No test file added. Consider adding a minimal smoke test that validates argument parsing and CSV output format.
  • Documentation: The module docstring is good, but consider adding a README section in scripts/benchmarks/ if one exists.
  • Changelog: Per the PR template, ensure changelog is updated.

Verdict

Overall: This is a well-implemented benchmark script with good multi-GPU support and comprehensive output artifacts. The suggestions above are improvements rather than blockers. The code demonstrates good understanding of Isaac Lab's architecture and distributed computing patterns.

Automated review by Isaac Lab Review Bot

The previous _resolve_out_dir reused base_out_dir only when an args.json
already lived inside it; otherwise it created a fresh timestamped
subdir. That worked for the --mode both orchestrator (which writes
args.json up front) but broke multi-GPU local runs: each torchrun
--mode base call made its own timestamped subdir, --mode wrist made
another, --mode summarize made a third — so summarize never found the
per-rank fps CSVs.

Now --mode base | wrist | summarize use --out_dir as-is. The
orchestrator still wraps a timestamped subdir around the user's path
before spawning subprocesses, so single-process --mode both behaves
identically. Callers running torchrun directly own picking a unique
path, which matches what the experiment shell script already passes.

@isaaclab-review-bot isaaclab-review-bot Bot 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.

🤖 Automated Code Review — Updated for 31731e3

This review covers both commits in the PR, including the fix for multi-GPU CSV discovery.


✅ Update Summary

The second commit (31731e3) correctly addresses the multi-GPU output directory issue:

  • Before: _resolve_out_dir checked for args.json existence to detect orchestrator-resolved paths, but this broke when running torchrun --mode base/wrist/summarize directly (each mode created its own timestamped directory).
  • After: Single-mode runs now use --out_dir as-is, while --mode both continues to create timestamped subdirectories. This matches the intended workflow where torchrun users share a single path across modes.

🔬 Technical Findings

🟡 Warning: Missing Error Handling for Camera Sensor Access — line 407

rgb = env.unwrapped.scene["base_camera"].data.output["rgb"]

If the scene does not have a base_camera entity (e.g., user passed wrong presets), this raises a KeyError with no helpful message. Consider:

try:
    camera = env.unwrapped.scene["base_camera"]
except KeyError:
    raise RuntimeError(
        "Scene missing 'base_camera' entity. Ensure env.scene=single_camera preset is active."
    ) from None
rgb = camera.data.output["rgb"]

🟡 Warning: Config Attribute Access Without Validation — line 321

cam = env_cfg.scene.base_camera  # already-resolved CameraCfg from preset

If the preset resolution fails or a different scene preset is used, base_camera may not exist on env_cfg.scene. The comment documents the assumption, but a runtime check would prevent confusing AttributeError:

if not hasattr(env_cfg.scene, "base_camera"):
    raise ValueError(
        f"env_cfg.scene has no 'base_camera' attribute. "
        f"Ensure env.scene=single_camera is set (got: {type(env_cfg.scene).__name__})"
    )

🔵 Improvement: File Handle Resource Safety — line 350

fps_csv = fps_csv_path.open("w", newline="")
fps_writer = csv.writer(fps_csv)
# ... many lines later in finally block:
fps_csv.close()

The current structure uses a finally block to close the file, which works but is fragile if code is refactored. Using a context manager would be more robust:

with fps_csv_path.open("w", newline="") as fps_csv:
    fps_writer = csv.writer(fps_csv)
    # ... rest of the code

However, the current code does need the file open across the with launch_simulation() block, so this may require restructuring. The current approach is acceptable given the constraint.

🔵 Improvement: imageio Import Error Handling — line 425

import imageio.v2 as imageio

This import is inside the video encoding block, which is good for conditional loading. However, if imageio or imageio_ffmpeg is not installed, users get a generic ModuleNotFoundError. Consider:

try:
    import imageio.v2 as imageio
except ImportError:
    print(f"{tag_prefix} WARNING: imageio not installed, skipping video encoding", file=sys.stderr)
    print(f"{tag_prefix} Install with: pip install imageio imageio-ffmpeg", file=sys.stderr)
    frame_buffers.clear()
    # Skip to env.close()

Or raise with a helpful message if video recording is considered mandatory when --video_length > 0.


📋 Test Coverage Note

This is a benchmark script, not core library code. Benchmark scripts in scripts/benchmarks/ typically don't have unit tests (see benchmark_cameras.py, benchmark_rsl_rl.py). The existing pattern is integration testing via CI workflows. No test gap here.


✅ Positive Observations

  1. Second commit fix is correct: The _resolve_out_dir logic now properly distinguishes orchestrator mode from single-mode runs.

  2. Good docstring update: The expanded docstring for _resolve_out_dir clearly documents the intended behavior for each mode.

  3. Consistent patterns: The script follows existing benchmark patterns in the codebase (see benchmark_cameras.py).

  4. Proper distributed handling: Seed offsetting per-rank and rank-0-only video encoding are correctly implemented.


Verdict

Ship it with minor improvements — The core functionality is correct. The suggestions above would improve error messages for edge cases but are not blocking.


Automated review updated for commit 31731e3 by Isaac Lab Review Bot

@AntoineRichard

AntoineRichard commented Aug 25, 2026 •

Copy link
Copy Markdown
Collaborator

Hi @nblauch — thanks for putting this one up! 🙏

We're doing a cleanup pass over the Isaac Lab PR backlog, which had grown past 400 open pull requests, and we're closing out the ones that have gone quiet so the queue is reviewable again.

Why this PR is being closed: Here is exactly what we found on this PR when we reviewed the backlog:

Opened 2026-05-21 (about 3 months ago)
Last commit on the branch 2026-05-21
Last activity from the author about 3 months ago
Target branch develop
Review status Never reviewed by a maintainer — nobody on the team got to it. Sorry about that.
Merge status Unknown
Size 2 commit(s), 1 file(s) changed, +476 / -0

It was picked up by the sweep because it is still marked as a draft, and it has been open for about 3 months. It was then put in the "close" bucket because the author has been silent for about 3 months — which is the signal we used to tell apart pull requests that are still being worked on from ones that have genuinely been set aside.

We deliberately did not close pull requests that were approved and ready to land, or that were small and clearly still fixing a live bug — there were 27 of those, and we are merging them rather than closing them.

No judgement on the change itself — this is purely backlog hygiene.

If this is still wanted, please reopen it or re-submit against develop. 💚


🤖 This comment was drafted with AI assistance as part of a maintainer-led sweep of the Isaac Lab pull request backlog. A maintainer is behind this cleanup — but if this closure looks wrong, it may well be, so please push back and we'll take another look.

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

Labels

isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants