Fixes benchmark scripts when tensorboard logs are missing#5564
Fixes benchmark scripts when tensorboard logs are missing#5564kellyguo11 wants to merge 2 commits intoisaac-sim:developfrom
Conversation
Greptile SummaryThis PR guards the
Confidence Score: 4/5Safe to merge; the fix correctly targets the crash path and leaves the always-present performance timing metrics untouched. The change is small and well-scoped. The only concern is that Both changed files carry the same Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[parse_tf_logs] --> B{rewards key present?}
B -- "None (missing)" --> C[Print WARNING: missing rewards]
B -- "list of values" --> D[log_rl_policy_rewards]
D --> E[log_convergence]
C --> F{check_convergence flag?}
F -- yes --> G[Print WARNING: cannot check convergence]
F -- no --> H[skip]
E --> I[log_success / finalize]
G --> I
H --> I
A --> J{episode_lengths key present?}
J -- "None (missing)" --> K[Print WARNING: missing episode lengths]
J -- "list of values" --> L[log_rl_policy_episode_lengths]
L --> I
K --> I
|
There was a problem hiding this comment.
🤖 Isaac Lab Review Bot
Summary
Fixes a KeyError crash in benchmark scripts when num_iterations is below the reward logging threshold. The fix replaces direct dict access (log_data["key"]) with .get() + conditional processing and appropriate warnings. Clean, well-scoped defensive fix applied consistently to both benchmark_rlgames.py and benchmark_rsl_rl.py.
Design Assessment
Design is sound. The fix correctly converts hard crashes into graceful degradation with user-visible warnings. The warning pattern (print("[WARNING]...")) is consistent with existing conventions in the benchmark scripts and utils.py.
Findings
🔵 Suggestion: Consider if rewards is not None: for consistency — scripts/benchmarks/benchmark_rsl_rl.py:291
The code uses if rewards: (truthiness) but the adjacent success_rates check uses if success_rates is not None:. Both protect against missing keys, but the truthiness check also treats empty lists as "missing." In practice this is fine — TensorBoard won't produce empty lists for registered tags, and log_rl_policy_rewards() would crash on max([]) anyway — but is not None would be more semantically precise and consistent with the existing pattern. Not a bug, just a consistency nit.
Test Coverage
- Tests not practical — standalone GPU benchmark scripts lack unit-test infrastructure
- The fix is mechanical (
.get()+ guard) with very low regression risk - Acceptable without additional tests
CI Status
- Check for Broken Links: ✅ pass
- Most other checks: ⏳ pending
Verdict
Ship it ✅
Clean, correct, and well-scoped bug fix. The if rewards: truthiness check is safe for the actual data patterns produced by parse_tf_logs(). The consistency suggestion is a minor polish, not a blocker.
| episode_length_tag="Train/mean_episode_length", | ||
| task=args_cli.task, | ||
| workflow="rsl_rl", | ||
| should_check_convergence=args_cli.check_convergence, |
There was a problem hiding this comment.
🔵 Suggestion: For consistency with the success_rates is not None check a few lines below, consider using if rewards is not None: here (and for episode_lengths). Both work correctly in practice — parse_tf_logs returns None for missing keys — but is not None makes the intent clearer and matches the existing pattern in this file.
Non-blocking — the truthiness check is also safe since an empty list from TensorBoard is practically impossible, and log_rl_policy_rewards would crash on max([]) anyway.
Description
When benchmarking scripts are executed with num_iterations set to below the threshold for reward logging, the run can produce missing reward data. However, the scripts are hardcoded to always parse rewards from tensorboard, which may not exist in these cases. This change patches the RL benchmarking scripts to only process rewards logging if they were written to tensorboard.
Type of change
Checklist
pre-commitchecks with./isaaclab.sh --formatconfig/extension.tomlfileCONTRIBUTORS.mdor my name already exists there