Repository navigation
Conversation
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.
There was a problem hiding this comment.
🤖 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
-
Solid Architecture: Clean separation between orchestrator (
--mode both), per-config runners (--mode base/wrist), and aggregation (--mode summarize). -
Multi-GPU Support: Properly reads
RANK/WORLD_SIZEfrom torchrun environment and handles per-rank CSV output with correct aggregation. -
Reproducibility: Seeds are correctly offset per-rank while staying matched between modes for apples-to-apples comparison.
-
Video Encoding Workaround: Good documentation of the cv2.VideoWriter/Kit libavcodec conflict and the imageio_ffmpeg solution.
-
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.txtor 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 13. 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 codeThis 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 internallyConsider adding return types to public functions like main() -> int.
🔍 Minor Issues
-
Unused import potential:
statisticsis imported at module level — confirm it's needed (it is, forfmean/stdev). -
Docstring completeness:
setup_env_cfgreturns a value but the docstring says "Build" rather than "Return". Minor, but worth aligning. -
CLI documentation: The module docstring shows
source ../tools/activate.shwhich 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.
There was a problem hiding this comment.
🤖 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_dirchecked forargs.jsonexistence to detect orchestrator-resolved paths, but this broke when runningtorchrun --mode base/wrist/summarizedirectly (each mode created its own timestamped directory). - After: Single-mode runs now use
--out_diras-is, while--mode bothcontinues 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 presetIf 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 codeHowever, 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 imageioThis 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
-
Second commit fix is correct: The
_resolve_out_dirlogic now properly distinguishes orchestrator mode from single-mode runs. -
Good docstring update: The expanded docstring for
_resolve_out_dirclearly documents the intended behavior for each mode. -
Consistent patterns: The script follows existing benchmark patterns in the codebase (see
benchmark_cameras.py). -
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
|
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:
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 🤖 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. |
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
Screenshots
Please attach before and after screenshots of the change if applicable.
Checklist
pre-commitchecks with./isaaclab.sh --formatconfig/extension.tomlfileCONTRIBUTORS.mdor my name already exists there